感谢大家!
分类: LINUX
2008-02-12 23:58:45
mkdir -pv /opt/iso/{boot,modules} cd /opt/iso
cd / mksquashfs bin lib sbin usr SYSTEM
mv /SYSTEM /opt/iso
cd /opt/iso/boot mkdir initrd dd if=/dev/zero of=initrd.img bs=1M count=8 mkfs.ext2 initrd.img mount -o loop initrd.img initrd
export INITRD=/opt/iso/boot/initrd cd ${INITRD} mkdir bin boot dev etc lib proc sbin sys
cp -a /bin/bash ${INITRD}/bin
mv /opt/iso/modules ${INITRD}/lib
cp -a /lib/udev ${INITRD}/lib
cp -a /lib/firmware ${INITRD}/lib
cp -a /dev/{console,null} ${INITRD}/dev
cp -a /etc/udev ${INITRD}/etc
cat > ${INITRD}/linuxrc << "EOF" #!/bin/bash mount -t proc proc /proc mount -t sysfs sysfs /sys # 如果你将loop模块化,那么需要加入 /sbin/modprobe loop # 建立/dev设备目录,并使用udev来创建各种设备文件 mount -n -t tmpfs -o mode=0755 udev /dev cp --preserve=all --recursive --remove-destination /lib/udev/devices/* /dev chmod 1777 /dev/shm echo "" > /sys/kernel/uevent_helper echo "Starting Udev..." /sbin/udevd --daemon mkdir -p /dev/.udev/queue /sbin/udevtrigger /sbin/udevsettle # 创建用户使用环境 # 在/SYSTEM中准备目录结构 export SYSTEM=/SYSTEM mkdir -p ${SYSTEM} mount -t tmpfs tmpfs ${SYSTEM} mkdir -p ${SYSTEM}/{system,cdrom,dev,proc,sys,tmp,mnt,initrd,home,root} chmod 0777 ${SYSTEM}/tmp chmod 0700 ${SYSTEM}/root # 搜索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 # 加载squashfs压缩的主文件系统 mount -o loop -t squashfs ${SYSTEM}/cdrom/SYSTEM ${SYSTEM}/system ln -s /system/bin ${SYSTEM} ln -s /system/sbin ${SYSTEM} ln -s /system/lib ${SYSTEM} ln -s /system/usr ${SYSTEM} # 将根目录从initrd转换到主系统 killall /sbin/udevd echo 0x0100 > /proc/sys/kernel/real-root-dev pivot_root ${SYSTEM} ${SYSTEM}/initrd cd / # 解压缩一些必要的目录和文件 tar xf /cdrom/etc.tar.bz2 -C / #转移内核文件系统 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
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
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
echo "Sunhaiyong's LiveCD" > /opt/iso/LABEL
cd /opt/iso/boot umount initrd gzip -9 initrd.img
cd /opt/iso cp -a /etc ./
tar -cjf etc.tar.bz2 etc rm -r etc
cd /opt/iso mkdir -p boot/grub cp -a /usr/lib/grub/i386-pc/stage2_eltorito boot/grub
cd /opt/iso/boot/grub cat > menu.lst << "EOF" default 0 timeout 3 color green/black light-green/black title MyLiveCD 1.0 root (cd) kernel /boot/kernel initrd /boot/initrd.img.gz
cd /opt mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o mylivecd.iso iso
chinaunix网友2010-12-09 15:33:12
豹哥,按照你的方法。成功制作了一个livecd。我想要做个启动画面绚丽点的,请问怎么办呢?是不是要改menu.lst的启动配置,增加启动画面文件啊?
chinaunix网友2010-09-14 17:13:07
不知道豹哥还在上没?
按照你的方法做了好久,可是一直存在如下错误
VFS: Mounted root (ext2 filesystem).
VFS: Cannot open root device "
chinaunix网友2010-03-07 23:16:54
GCC-4.1.2 - Pass 2时,make完成后,报了错误,和别人在glibc处的差不多,错误: make[2]: leaving directory '/mnt/lfs/sources/gcc-build/gcc' make[1]: *** [all-gcc] Error 2 make[1]: leaving directory '/mnt/lfs/sources/gcc-build' mak: *** [all] Error 2 之后时间make install,也报类似的错误,但进行工具链的调整测试时却完全正常,输出[Requesting program interpreter: /tools/lib/ld-linux.so.2]。我在想这样住后走,可能会影响后面的编译,但已已经重新进行进行第二遍编译GCC过了,还是没有解决,之前没有出现错误,前面的调整测试也是成功的。