ubuntu 8.04 定制过程
$sudo mount -t ext3 /dev/sdb1 iCU/ #加载虚拟机硬盘
$cd iCU/
$sudo mksquashfs . ../icu804.squashfs
$cd ..
$ ls -l --block-size M
$ mkdir mnt
#挂载livecd
$ rsync --exclude=/casper/filesystem.squashfs -a /media/Ubuntu\ 8.04\ i386/ mnt/
$ sudo umount /media/Ubuntu\ 8.04\ i386/
$ sudo cp icu804.squashfs mnt/casper/
$ cd mnt/
**************************
3.定製 initrd 文件
其實就是把 /boot/initrd.img-2.6.20-15-generic 拿來稍作修改。
ubuntu 的 initrd 文件中都包含 Live CD 模式啟動腳本,而本系統啟動正是模仿了 Live CD ,所以可以直接借用這些腳本。
解開 initrd.img-2.6.20-15-generic:
mkdir /boot/initrd
cd /boot/initrd
cat ../initrd.img-2.6.20-15-generic | gzip -d | cpio -i
/boot/initrd 目錄中就是 initrd 裡的文件,其實是一個微型的根系統,由 GRUB 加載到內存,內核運行其中的 init
,若檢測到啟動參數中有 boot=casper ,便調用 /scripts/casper 腳本,尋找系統映像,並與 tmpfs 組成 unionfs ,
作為真實根系統啟動。而啟動前會運行 /scripts/casper-bottom 中的腳本,對系統進行配置。
從腳本的名字和註釋大致可以猜到它的功能,我們要做的就是留下有用的,去掉沒用甚至有害的。
我留下了
02_timezone 13swap 22screensaver 31disable_update_notifier
05mountpoints 20xconfig 23networking 32disable_hibernation
12fstab 22gnome_panel_data 25configure_init 40install_driver_updates
可能有些還是顯得多餘,自己斟酌吧。
然後重新打包:
cd /boot/initrd
find . | cpio -L -o -H newc | gzip > ../initrd.gz
***************************
2.6内核的 initrd.gz 解压后多是一个 cpio 格式的文件
可用 cpio 命令取档:
代码:cp */initrd.gz .
gunzip initrd.gz
mkdir tmp
cd tmp
cpio -iF ../initrd.gz修改后,再把它做成 cpio 格式的包。
查看 /usr/sbin/mkinitramfs
find . | cpio -L -o -H newc | gzip -9 > ../initrd.gz***************************
$ sudo rm md5sum.txt
$ sudo find . -type f -print0 | xargs -0 md5sum >md5sum.txt
$ cd ..
$ sudo mkisofs -r -V "Custom Ubuntu 8.04 Live CD" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o custom-dapper-live-i386.iso mnt
- 最新评论