Thursday, February 15, 2007
Play with initrd
Resources
1. http://www.cpqlinux.com/dig-initrd.html
2. http://www.faqs.org/docs/evms/x3834.html
Unpacking an initrd
#prepare work directorycd ~/temp
#Grap initrd
cp /media/cdrecorder/initrd.gz .
#unzip the file
gunzip initrd.gz
#you will get a new file named initrd
#create a directory as mount point
mkdir initrd.dir
#before mount it, change to super user
su
#mount it
mount initrd initrd.dir -o loop
#access it
cd initrd.dir
Packing an initrd (~/src/initrd/*)
#prepare work directory cd ~/temp
#Create a file with 14M (14000*1k)
dd if=/dev/zero of=initrd bs=1k count=14000
#create a loop device from this file
losetup /dev/loop1 initrd
#create ext2 file system on this device
mkfs -t ext2 -m 0 /dev/loop1
#mount this file system under /mnt
mount /dev/loop1 /mnt
#copy file content from source to /mnt
cd ~/src/initrd/
#use tar to copy in order to keep symbolic links, file group, and permission)
tar cf - . | (cd /mnt; tar xf - )
#clean up
umount /mnt
losetup -d /dev/loop1
#the initrd is ready, zip it
cd ~/temp
gzip -f initrd
--
Pop (Pu Liu)