Manpage of INITRD
INITRDSection: Linux Programmer's Manual (4)
NAMEinitrd - boot loader initialized RAM disk
CONFIGURATIONThe /dev/initrdis a read-only block device assigned major number 1 and minor number 250. Typically /dev/initrdis owned by root.diskwith mode 0400 (read access by root only). If the Linux system does not have /dev/initrdalready created, it can be created with the following commands:
mknod -m 400 /dev/initrd b 1 250 chown root:disk /dev/initrd
Also, support for both "RAM disk" and "Initial RAM disk" (e.g., CONFIG_BLK_DEV_RAM=yand CONFIG_BLK_DEV_INITRD=y) must be compiled directly into the Linux kernel to use /dev/initrd. When using /dev/initrd, the RAM disk driver cannot be loaded as a module.
DESCRIPTIONThe special file /dev/initrdis a read-only block device. This device is a RAM disk that is initialized (e.g., loaded) by the boot loader before the kernel is started. The kernel then can use /dev/initrd's for a two-phase system boot-up.
Boot-up operationWhen booting up with initrd, the system boots as follows:
- The boot loader loads the kernel program and /dev/initrd's into memory.
- On kernel startup, the kernel uncompresses and copies the of the device /dev/initrdonto device /dev/ram0and then frees the memory used by /dev/initrd.
- The kernel then read-write mounts the device /dev/ram0as the initial root filesystem.
- If the indicated normal root filesystem is also the initial root filesystem (e.g., /dev/ram0) then the kernel skips to the last step for the usual boot sequence.
- If the executable file /linuxrcis present in the initial root filesystem, /linuxrcis executed with UID 0. (The file /linuxrcmust have executable permission. The file /linuxrccan be any valid executable, including a shell script.)
- If /linuxrcis not executed or when /linuxrcterminates, the normal root filesystem is mounted. (If /linuxrcexits with any filesystems mounted on the initial root filesystem, then the behavior of the kernel is UNSPECIFIED. See the NOTES section for the current kernel behavior.)
- If the normal root filesystem has a directory /initrd, the device /dev/ram0is moved from /to /initrd. Otherwise, if the directory /initrddoes not exist, the device /dev/ram0is unmounted. (When moved from /to /initrd, /dev/ram0is not unmounted and therefore processes can remain running from /dev/ram0. If directory /initrddoes not exist on the normal root filesystem and any processes remain running from /dev/ram0when /linuxrcexits, the behavior of the kernel is UNSPECIFIED. See the NOTES section for the current kernel behavior.)
- The usual boot sequence (e.g., invocation of /sbin/init) is performed on the normal root filesystem.
OptionsThe following boot loader options, when used with initrd, affect the kernel's boot-up operation:
- Specifies the file to load as the of /dev/initrd. For LOADLINthis is a command-line option. For LILOyou have to use this command in the LILOconfiguration file /etc/lilo.config. The filename specified with this option will typically be a gzipped filesystem image.
- This boot option disables the two-phase boot-up operation. The kernel performs the usual boot sequence as if /dev/initrdwas not initialized. With this option, any of /dev/initrdloaded into memory by the boot loader are preserved. This option permits the of /dev/initrdto be any data and need not be limited to a filesystem image. However, device /dev/initrdis read-only and can be read only one time after system startup.
- Specifies the device to be used as the normal root filesystem. For LOADLINthis is a command-line option. For LILOthis is a boot time option or can be used as an option line in the LILOconfiguration file /etc/lilo.config. The device specified by the this option must be a mountable device having a suitable root filesystem.
Changing the normal root filesystemBy default, the kernel's settings (e.g., set in the kernel file with rdev(8) or compiled into the kernel file), or the boot loader option setting is used for the normal root filesystems. For an NFS-mounted normal root filesystem, one has to use the nfs_root_nameand nfs_root_addrsboot options to give the NFS settings. For more information on NFS-mounted root see the kernel documentation file Documentation/filesystems/nfsroot.txt. For more information on setting the root filesystem see also the LILOand LOADLINdocumentation.
It is also possible for the /linuxrcexecutable to change the normal root device. For /linuxrcto change the normal root device, /procmust be mounted. After mounting /proc, /linuxrcchanges the normal root device by writing into the proc files /proc/sys/kernel/real-root-dev, /proc/sys/kernel/nfs-root-name, and /proc/sys/kernel/nfs-root-addrs. For a physical root device, the root device is changed by having /linuxrcwrite the new root filesystem device number into /proc/sys/kernel/real-root-dev. For an NFS root filesystem, the root device is changed by having /linuxrcwrite the NFS setting into files /proc/sys/kernel/nfs-root-nameand /proc/sys/kernel/nfs-root-addrsand then writing 0xff (e.g., the pseudo-NFS-device number) into file /proc/sys/kernel/real-root-dev. For example, the following shell command line would change the normal root device to /dev/hdb1:
echo 0x365 >/proc/sys/kernel/real-root-devFor an NFS example, the following shell command lines would change the normal root device to the NFS directory /var/nfsrooton a local networked NFS server with IP number 220.127.116.11 for a system with IP number 18.104.22.168 and named "idefix":
echo /var/nfsroot >/proc/sys/kernel/nfs-root-name echo 22.214.171.124:126.96.36.199::255.255.255.0:idefix \ >/proc/sys/kernel/nfs-root-addrs echo 255 >/proc/sys/kernel/real-root-dev
Note: The use of /proc/sys/kernel/real-root-devto change the root filesystem is obsolete. See the Linux kernel source file Documentation/initrd.txtas well as pivot_root(2) and pivot_root(8) for information on the modern method of changing the root filesystem.
UsageThe main motivation for implementing initrdwas to allow for modular kernel configuration at system installation.
A possible system installation scenario is as follows:
- The loader program boots from floppy or other media with a minimal kernel (e.g., support for /dev/ram, /dev/initrd, and the ext2 filesystem) and loads /dev/initrdwith a gzipped version of the initial filesystem.
- The executable /linuxrcdetermines what is needed to (1) mount the normal root filesystem (i.e., device type, device drivers, filesystem) and (2) the distribution media (e.g., CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach.
- The executable /linuxrcloads the necessary modules from the initial root filesystem.
- The executable /linuxrccreates and populates the root filesystem. (At this stage the normal root filesystem does not have to be a completed system yet.)
- The executable /linuxrcsets /proc/sys/kernel/real-root-dev, unmount /proc, the normal root filesystem and any other filesystems it has mounted, and then terminates.
- The kernel then mounts the normal root filesystem.
- Now that the filesystem is accessible and intact, the boot loader can be installed.
- The boot loader is configured to load into /dev/initrda filesystem with the set of modules that was used to bring up the system. (e.g., Device /dev/ram0can be modified, then unmounted, and finally, the image is written from /dev/ram0to a file.)
- The system is now bootable and additional installation tasks can be performed.
The key role of /dev/initrdin the above is to reuse the configuration data during normal system operation without requiring initial kernel selection, a large generic kernel or, recompiling the kernel.
A second scenario is for installations where Linux runs on systems with different hardware configurations in a single administrative network. In such cases, it may be desirable to use only a small set of kernels (ideally only one) and to keep the system-specific part of configuration information as small as possible. In this case, create a common file with all needed modules. Then, only the /linuxrcfile or a file executed by /linuxrcwould be different.
A third scenario is more convenient recovery disks. Because information like the location of the root filesystem partition is not needed at boot time, the system loaded from /dev/initrdcan use a dialog and/or auto-detection followed by a possible sanity check.
Last but not least, Linux distributions on CD-ROM may use initrdfor easy installation from the CD-ROM. The distribution can use LOADLINto directly load /dev/initrdfrom CD-ROM without the need of any floppies. The distribution could also use a LILOboot floppy and then bootstrap a bigger RAM disk via /dev/initrdfrom the CD-ROM.
- With the current kernel, any filesystems that remain mounted when /dev/ram0is moved from /to /initrdcontinue to be accessible. However, the /proc/mountsentries are not updated.
- With the current kernel, if directory /initrddoes not exist, then /dev/ram0will notbe fully unmounted if /dev/ram0is used by any process or has any filesystem mounted on it. If /dev/ram0is notfully unmounted, then /dev/ram0will remain in memory.
- Users of /dev/initrdshould not depend on the behavior give in the above notes. The behavior may change in future versions of the Linux kernel.
SEE ALSOchown(1), mknod(1), ram(4), freeramdisk(8), rdev(8)
Documentation/initrd.txtin the Linux kernel source tree, the LILO documentation, the LOADLIN documentation, the SYSLINUX documentation
- SEE ALSO
This document was created by man2html, using the manual pages.
Time: 22:28:01 GMT, June 20, 2016