Rock InitRD Concept

From RockWiki

Jump to: navigation, search

ROCK's initrd is an expandible set of programs and/or shell scripts run before the real root or / file system is mounted.

Abstract, it works like this:

  1. Boot, mount initrd as temporary root file system and run /linuxrc which is stored as /etc/conf/initrd/linuxrc on the real root file system
  2. Setup /dev file system using udev and mount /proc, /sys and /tmp file systems
  3. Run the file /etc/conf/kernel. This file is stored as /etc/conf/kernel on the real root file system
  4. Run the remaining file in the directory /etc/conf. These files are stored as /etc/conf/initrd/initrd_* on the real root file system
  5. If by now the root file system has not been mounted, do so now. The root file system is determined by reading /etc/fstab.
  6. Move the directories /tmp, /sys and /proc to the real root file system
  7. chroot into the real root file system and run /sbin/init

Step 4 is where other initrd plugins can hook in. Currently, the following plugins are available:

To add a plugin, create a new file "/etc/conf/initrd/initrd_myplugin" and add a list of files that should be copied to the initrd. Here is an example, where each line consists of a source and a destination file name:

/etc/conf/myplugin/initrd_myplugin /etc/conf/myplugin
/bin/dd	/bin/dd

Files will be copied from source (relative to your current root directory) to destination (relative to the initrd root directory).
"/etc/conf/myplugin" will be executed when the initrd boots as described above.
Note that you don't have to list libraries that your programs depend on. They will be copied to the initrd automatically.

To recreate the initrd and thus make your changes active, type:

mkinitrd [ <kernel-version> ]

The initrd will be stored in /boot/initrd-<kernel-version>.img (uncompressed) and /boot/initrd-<kernel-version>.img.gz (gzip'ed).
If you don't specify <kernel-version>, this will create an initrd for the running kernel.

Personal tools