一个脚本,搞定ramdisk根文件系统
# vi mkinitrd.sh
----------------------------------------
#!/bin/bash
#------------- make file system
cd /tftpboot
rm -fr ramdisk &> /dev/null
umount /mnt &> /dev/null
dd if=/dev/zero of=ramdisk bs=1k count=8192 &>/dev/null
mkfs.ext2 -F ramdisk &> /dev/null
mount -o loop ramdisk /mnt &> /dev/null
#------------- make directory
cd /mnt
rm -r *
mkdir lib dev proc etc mnt usr bin sbin tmp sys
#------------- cp lib
cd /usr/local/arm/3.4.1/arm-linux/lib
for file in libc libcrypt libdl libm libpthread libresolv libutil
do
cp $file-*.so /mnt/lib
cp -d $file.so.[*0-9] /mnt/lib
done
cp -d ld*.so* /mnt/lib
#------------- cp busybox
cd /home/zxl/s3c2410/source/busybox/busybox-1.7.0
cp -rf _install/* /mnt/
cp -r examples/bootfloppy/etc/init.d/ /mnt/etc/
#------------- edit /etc/init.d/rcS (0)
echo "echo /sbin/mdev > /proc/sys/kernel/hotplug" >>/mnt/etc/init.d/rcS
echo "/sbin/mdev -s" >>/mnt/etc/init.d/rcS
#------------- make device file (1)
cd /mnt/dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3
#------------- make etc file
cat > /mnt/etc/inittab << EOF
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/msh
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
EOF
cat > /mnt/etc/fstab << EOF
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
EOF
#------------- make zip file
cd /
umount /mnt
cd /tftpboot
rm -fr ramdisk.gz &>/dev/null
gzip -9 ramdisk
(0) 配置mdev
(1) 由于2.6.19中已经不包含devfs,所以还需要在root filesystem中配置console和null设备,否则将不能进入交互界面(不会出现提示符#)