Saturday, March 1, 2008

processing the initrd (creating, extracting)

reference: Documentation/initrd.txt


Section A. creating the initrd image
find . | cpio --quiet -c -o | gzip -9 -n > /boot/initrd.img

1. create directories
mkdir tmpdir
cd tmpdir
mkdir {bin,sbin,lib,proc,sys,dev}

example of directories created
bin
sbin
lib
proc
sys
dev

2. create the executable script /sbin/init, (read Documentation/initrd.txt for details)

3. populate /bin with necessary executables, such as (bash or nash, mknod, mount, insmod or modprobe)

4. populate /lib with the necessary shared libraries,
example, to figure out the library used by bash, execute the command

root-shell# ldd /bin/bash
then copy the libraries to /lib

5. create the initrd.img
cd tmpdir
find . | cpio --quiet -c -o | gzip -9 -n > /boot/initrd.img



Section B. extracting the initrd.img
gzip -cd /boot/initrd.img | cpio -imd --quiet


link: initramfs