# 搜索LiveCD所在的设备
for i in /proc/ide/hd*
do
if test `cat $i/media` = "cdrom" ; then
mount -t iso9660 /dev/`basename $i` ${SYSTEM}/cdrom 2>/dev/null
if test $? = 0 ; then
if [ -f ${SYSTEM}/cdrom/LABEL ] ; then
if grep -q "Sunhaiyong’s LiveCD" ${SYSTEM}/cdrom/LABEL ; then
break;
fi
fi
umount ${SYSTEM}/cdrom
fi
fi
done
#转移内核文件系统
mount --move /initrd/dev /dev
mount --move /initrd/proc /proc
mount --move /initrd/sys /sys
mkdir -p /var/{run,log,lock}
touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
chgrp utmp /var/run/utmp /var/log/lastlog
chmod 664 /var/run/utmp /var/log/lastlog
#结束
EOF 目前根据linuxrc用到的命令复制到initrd中
代码:cp -a /bin/{bash,bunzip,bzcat,bzip2,killall,chmod,cp,grep,mount,tar,ln,cat,mkdir} ${INITRD}/bin
cp -a /usr/bin/basename ${INITRD}/bin
cp -a /sbin/pivot_root ${INITRD}/sbin
cp -a /sbin/{udevd,udevsettle,udevtrigger,modprobe} ${INITRD}/sbin复制这些命令所需要的各种动态链接库,可通过ldd命令查看。
代码:cp -a /lib/ld-* ${INITRD}/lib/
cp -a /lib/libc-2.5.1.so ${INITRD}/lib/
cp -a /lib/libc.so.6 ${INITRD}/lib/
cp -a /lib/lib{dl,pthread,rt}-* ${INITRD}/lib/
cp -a /lib/lib{readline,history,ncursesw,dl,bz2,blkid,uuid,rt,pthread}.so* ${INITRD}/lib/ 创建一些必要的文件
代码:touch ${INITRD}/etc/fstab创建LiveCD标签