How to create an initrd and linuxrc

As already mentioned, initrd is a file containing the contents of the ram disk (=root file system) that will be used during the boot.

In the chrooted environment that you have if you setup Gentoo Linux according its handbook, create a directory mkdir /root/USBHD that will get all necessary files including the linuxrc script. The previous section has described how to find out what files are necessary. A more simple approach is downloading a prepared initrd and if necessary customize it. This is described in the next section.

To convert the /root/USBHD files in initrd.gz create first the mounting point mkdir /mnt/initrd.

The necessary commands to create the initrd.gz file might have to be repeated until the desired result is achieved. To do this get the script:

cd /root


tar -xzvf mkinitrd.tar.gz

The script takes all files from /root/USBHD, creates the necessary /dev files and creates from that the initrd.gz file.

Observing the script shows that an empty initrd file with a certain size is first created by mkinitrd. Then this file will be formated as ext2 and mounted to /mnt/initrd. Now it can be accessed as it would be a regular filesystem on a memory stick. So all files can be copied there and /dev nodes can be created.

Finally the /mnt/initrd has to be unmounted and the now no more empty initrd has to be zipped to initrd.gz.

The script mkinitrd assumes that it has been put in /root. After having put the necessary files in /root/USBHD and successfully running /root/mkinitrd /root/initrd.gz can be found. Finally cp /root/initrd.gz /boot

Linurs startpage