|INITRD(4)||Linux Programmer's Manual||INITRD(4)|
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=y and 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.
- The boot loader loads the kernel program and /dev/initrd's contents into memory.
- On kernel startup, the kernel uncompresses and copies the contents of the device /dev/initrd onto device /dev/ram0 and then frees the memory used by /dev/initrd.
- The kernel then read-write mounts the device /dev/ram0 as 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 /linuxrc is present in the initial root filesystem, /linuxrc is executed with UID 0. (The file /linuxrc must have executable permission. The file /linuxrc can be any valid executable, including a shell script.)
- If /linuxrc is not executed or when /linuxrc terminates, the normal root filesystem is mounted. (If /linuxrc exits 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/ram0 is moved from / to /initrd. Otherwise, if the directory /initrd does not exist, the device /dev/ram0 is unmounted. (When moved from / to /initrd, /dev/ram0 is not unmounted and therefore processes can remain running from /dev/ram0. If directory /initrd does not exist on the normal root filesystem and any processes remain running from /dev/ram0 when /linuxrc exits, 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.
- Specifies the file to load as the contents of /dev/initrd. For LOADLIN this is a command-line option. For LILO you have to use this command in the LILO configuration 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/initrd was not initialized. With this option, any contents of /dev/initrd loaded into memory by the boot loader contents are preserved. This option permits the contents of /dev/initrd to be any data and need not be limited to a filesystem image. However, device /dev/initrd is read-only and can be read only one time after system startup.
- Specifies the device to be used as the normal root filesystem. For LOADLIN this is a command-line option. For LILO this is a boot time option or can be used as an option line in the LILO configuration file /etc/lilo.config. The device specified by the this option must be a mountable device having a suitable root filesystem.
echo 0x365 >/proc/sys/kernel/real-root-dev
For an NFS example, the following shell command lines would change the normal root device to the NFS directory /var/nfsroot on a local networked NFS server with IP number 188.8.131.52 for a system with IP number 184.108.40.206 and named "idefix":
echo /var/nfsroot >/proc/sys/kernel/nfs-root-name echo 220.127.116.11:18.104.22.168::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-dev to change the root filesystem is obsolete. See the Linux kernel source file Documentation/admin-guide/initrd.rst (or Documentation/initrd.txt before Linux 4.10) as well as pivot_root(2) and pivot_root(8) for information on the modern method of changing the root filesystem.
- 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/initrd with a gzipped version of the initial filesystem.
- The executable /linuxrc determines 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 /linuxrc loads the necessary modules from the initial root filesystem.
- The executable /linuxrc creates and populates the root filesystem. (At this stage the normal root filesystem does not have to be a completed system yet.)
- The executable /linuxrc sets /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/initrd a filesystem with the set of modules that was used to bring up the system. (e.g., Device /dev/ram0 can be modified, then unmounted, and finally, the image is written from /dev/ram0 to a file.)
- The system is now bootable and additional installation tasks can be performed.
- With the current kernel, any filesystems that remain mounted when /dev/ram0 is moved from / to /initrd continue to be accessible. However, the /proc/mounts entries are not updated.
- With the current kernel, if directory /initrd does not exist, then /dev/ram0 will not be fully unmounted if /dev/ram0 is used by any process or has any filesystem mounted on it. If /dev/ram0 is not fully unmounted, then /dev/ram0 will remain in memory.
- Users of /dev/initrd should not depend on the behavior give in the above notes. The behavior may change in future versions of the Linux kernel.