《根文件系统实验指导》由会员分享,可在线阅读,更多相关《根文件系统实验指导(16页珍藏版)》请在金锄头文库上搜索。
1、嵌入式系统根文件系统制作一、主机环境Linux vm-dev 2.6.9-42.EL RedHatEL4, VMWare6.0.3;gcc version 3.4.6 20060404 (Red Hat 3.4.6-3) Thread model: posixgcc version 3.4.6所需源文件:busybox-1.12.2.tar.bz2;二、用Busybox创建文件系统前提是:通过samba服务器把源码包busybox-1.12.2.tar.bz2拷贝到了虚拟机的/home/uptech目录1、解压busybox-1.12.2.tar.bz2,路径为rootvm-dev cd /h
2、omerootvm-dev homemkdir hqrootvm-dev home# cd hqrootvm-dev hq#mkdir rootfsrootvm-dev hq# cd rootfsrootvm-dev rootfs#cp /home/uptech/busybox-1.12.0.tar.bz2 . -arfrootvm-dev rootfs# lsbusybox-1.12.0.tar.bz2rootvm-dev rootfs# tar -vxjf busybox-1.12.2.tar.bz2 rootvm-dev rootfs# cd busybox-1.12.2rootvm-d
3、ev busybox-1.12.2# pwd/home/hq/rootfs/busybox-1.12.2rootvm-dev busybox-1.12.2# vi Makefilerootvm-dev busybox-1.12.2#修改Makefile中的ARCH和CROSS_COMPILE与本机的路径一致:CROSS_COMPILE ?= arm-linux- .ARCH ?= arm2、编译busybox。先make menuconfig,修改以下: rootvm-dev busybox-1.12.2# make menuconfigBusybox Settings -Build Opti
4、ons -* Build BusyBox as a static binary (no shared libs)/直接编译成静态库,省事点(/opt/crosstools/gcc-3.4.6-glibc-2.3.6/bin/arm-linux-) Cross Compiler prefix/这里和Makefile里保持一致,应该写一处就行了Installation Options - Dont use /usr/使用usr目录Busybox Library Tuning - * Fancy shell prompts /一定要选上,否则很多转意字符无法识别Shells -Choose your
5、 default shell (ash) -/这里选择shell为ash,应该是默认选中的- ash/把ash这档的选项全部选上Miscellaneous Utilities - inotifyd/不选保存退出,直接make,make install。可以看到如下目录rootvm-dev busybox-1.12.2# ls _install/bin linuxrc sbin usrrootvm-dev busybox-1.12.2#3、用shell脚本创建根文件系统的目录结构,并在想要建立根文件系统的地方运行此脚本。我是用root用户登陆的,直接创建了设备节点。rootvm-dev busy
6、box-1.12.2#cd /home/hqrootvm-dev hq#mkdir root_standrootvm-dev hq#cd root_standrootvm-dev root_standpwd/home/hq/root_standrootvm-dev root_stand# vi build_fs.sh #!/bin/shecho makeing rootdirmkdir rootfscd rootfs echo makeing dir: bin dev etc lib proc sbin sys usrmkdir bin dev etc lib proc sbin sys us
7、r #8 dirsmkdir usr/bin usr/lib usr/sbin lib/modules #Dont use mknod, unless you run this Script as mknod -m 600 dev/console c 5 1mknod -m 666 dev/null c 1 3 echo making dir: mnt tmp varmkdir mnt tmp varchmod 1777 tmpmkdir mnt/etc mnt/jiffs2 mnt/yaffs mnt/data mnt/tempmkdir var/lib var/lock var/log v
8、ar/run var/tmpchmod 1777 var/tmp echo making dir: home root bootmkdir home root bootecho done rootvm-dev root_stand#执行这个sh:rootvm-dev root_stand# sh build_fs.sh makeing rootdirmakeing dir: bin dev etc lib proc sbin sys usrmaking dir: mnt tmp varmaking dir: home root bootdone创建出一个主文件夹rootfs,里面有一批文件目录
9、:rootvm-dev root_stand# cd rootfs/rootvm-dev rootfs# lsbin boot dev etc home lib mnt proc root sbin sys tmp usr varrootvm-dev rootfs#4、把busybox源码目录下的etc的容拷贝到这里的etc下rootvm-dev rootfs# cd etc/rootvm-dev etc# lsrootvm-dev etc# cp -a /home/hq/rootfs/busybox-1.12.2/examples/bootfloppy/etc/* ./rootvm-dev
10、etc# lsfstab init.d inittab profilerootvm-dev etc#5、修改拷贝过来的profile文件rootvm-dev etc# vi profile # /etc/profile: system-wide .profile file for the Bourne shellsecho Processing /etc/profile# no-op# Set search library pathecho Set search library pathexport LD_LIBRARY_PATH=/lib:/usr/lib# Set user pathech
11、o Set user pathPATH=/bin:/sbin:/usr/bin:/usr/sbinexport PATH# Set PS1echo Set PS1HOSTNAME=/bin/hostname# 此处让shell提示符显示host名称的。是,不是,要注意# 会在进入根系统后显示Jackyexport PS1=e32m$USER$HOSTNAME wa$e00;37m # 此处e32m是让后面的“$USER$HOSTNAME wa”显示为绿色# e00是关闭效果# e05是闪烁# 37m是让后面的显示为白色# 多个命令可以;号隔开echo All done!echo6、修改初始化文
12、件inittab和fstabInittabrootvm-dev etc# vi inittab:sysinit:/etc/init.d/rcS:respawn:-/bin/sh:restart:/sbin/inittty2:askfirst:-/bin/sh:ctrlaltdel:/bin/umount -a -r:shutdown:/bin/umount -a -r:shutdown:/sbin/swapoff aFstabrootvm-dev etc# vim fstab proc /proc proc defaults 0 0none /tmp ramfs defaults 0 0mde
13、v /dev ramfs defaults 0 0sysfs /sys sysfs defaults 0 07、修改初始化的脚本文件init.d/rcSrootvm-dev etc# vi init.d/rcS #! /bin/shecho Processing etc/init.d/rc.S#hostname $HOSTNAMEhostname up-techecho Mount all/bin/mount -aecho Start mdev./bin/echo /sbin/mdev proc/sys/kernel/hotplugmdev -secho *echo rootfs for s3c2410echo Created by lyj_uptech 2008.11.28echo Good Luckecho .up-tech.echo *echo8、创建一个空的mdev.conf文件,在挂载根文件系统时会用到的rootvm-dev etc# touch mdev.conf9、从本机拷贝passwd、shadow、group文件。rootvm-dev etc# cp /etc/passwd .rootvm-dev etc# cp /etc/shadow .rootvm-dev etc# cp /etc/group .修改passwd文件,把第一行和最后一行的