Section 4.7. initrd: Using a RAM Disk


4.7. initrd: Using a RAM Disk

Modern Linux distributions use a modular kernel, which allows modules to be added without requiring that the kernel be rebuilt. If your root filesystem is on a device whose driver is a module (as is frequently true of SCSI disks), you can use the initrd facility, which provides a two-stage boot process, to first set up a temporary root filesystem in a RAM disk containing the modules you need to add (e.g., the SCSI driver) and then load the modules and mount the real root filesystem. The RAM disk containing the temporary filesystem is the special device file /dev/initrd.

Similarly, you need to use a RAM disk if your root partition uses the ext3 filesystem and ext3 was not compiled into the kernel image. In that case, the ext3 module must be loaded with initrd.

Before you can use initrd, both RAM disk support (CONFIG_BLK_DEV_RAM=y) and initial RAM disk support (CONFIG_BLK_DEV_INITRD=y) must be compiled into the Linux kernel. Then you need to prepare the normal root filesystem and create the RAM disk image. Your Linux distribution may have utilities to do some of the setup for you; for example, the Red Hat distribution comes with the mkinitrd command, which builds the initrd image. For detailed information, see the initrd manpage and the file initrd.txt (the path may vary, but it is usually something like /usr/src/linux/Documentation/initrd.txt).

Once your Linux system has been set up for initrd, you can do one of the following, depending on which boot loader you are using:

  • If you are using LILO, add the initrd option to the appropriate image section:

         image=/vmlinuz       initrd=/boot/initrd  # The file to load as the contents of /dev/initrd       ...

    Run the /sbin/lilo command, and you can reboot with initrd.

  • If you are using GRUB, add the initrd option to the kernel line of the configuration-file boot entry, or to the kernel command if you are booting from the command-line interface:

         kernel /vmlinuz-2.6.10 ro root=LABEL=/     initrd /initrd-2.6.10

  • If you are using Loadlin, add the initrd option to the command line:

         loadlin c:\linux\vmlinuz initrd=c:\linux\initrd



Linux in a Nutshell
Linux in a Nutshell
ISBN: 0596154488
EAN: 2147483647
Year: 2004
Pages: 147

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net