bash> cp/home/wave/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/arm-xilinx-linux-gnueabi/libc/usr/bin/* usr/bin/ -r
4. 目录创建和配置 切换到"_rootfs" 目录下
bash> mkdir dev etc etc/dropbear etc/init.d mnt opt proc root sys tmp var var/log var/www
创建内容如下的文件 "etc/fstab":
LABEL=/ / tmpfs defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
none /tmp tmpfs defaults 0 0
创建内容如下的文件"etc/inittab"
::sysinit:/etc/init.d/rcS
# /bin/ash
#
# Start an askfirst shell on the serial ports
ttyPS0::respawn:-/bin/ash
# What to do when restarting the init process
::restart:/sbin/init
# What to do before rebooting
::shutdown:/bin/umount -a -r
创建内容如下的文件"etc/passwd":
root:$1$qC.CEbjC$SVJyqm.IG.gkElhaeM.FD0:0:0:root:/root:/bin/sh
创建内容如下的文件"etc/init.d/rcS":
#!/bin/sh
echo "Starting rcS..."
echo "++ Mounting filesystem"
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /tmp
echo "++ Setting up mdev"
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
mkdir -p /dev/pts
mkdir -p /dev/i2c
mount -t devpts devpts /dev/pts
echo "++ Starting telnet daemon"
telnetd -l /bin/sh
echo "++ Starting http daemon"
httpd -h /var/www
echo "++ Starting ftp daemon"
tcpsvd 0:21 ftpd ftpd -w /&
echo "++ Starting dropbear (ssh) daemon"
dropbear
echo "rcS Complete"
设置"etc/init.d/rcS"的权限:
bash> chmod 755 etc/init.d/rcS
bash> sudo chown root:root etc/init.d/rcS
5. 创建ramdisk image
bash> cd ~
bash> dd if=/dev/zero of=ramdisk.img bs=1024 count=8192
bash> mke2fs -F ramdisk.img -L "ramdisk" -b 1024 -m 0
bash> tune2fs ramdisk.img -i 0
bash> chmod 777 ramdisk.img
bash> mkdir ramdisk
bash> sudo mount -o loop ramdisk.img ramdisk/
bash> sudo cp -R _rootfs/* ramdisk
bash> sudo umount ramdisk/
bash> gzip -9 ramdisk.img
给ramdisk image增加u-boot header:
bash> mkimage-A arm-T ramdisk-C gzip-d ramdisk.img.gz uramdisk.image.gz
奇怪的是,自己生成的ramdisk image是3.6MB,prebuilt image是5.1MB。将prebuilt rootfs的u-boot header截掉并将内容导出,发现ramdisk的size是16MB,并且里面多了些内容,比如更新QSPI FLASH的工具等。 来源:赛灵思中文社区论坛