initrd(4)
π initrd(4) β the manual page, bestie edition π
okay so we're in section 4 of the kernel interfaces manual, and today's main character is initrd: the boot loader initialized RAM disk. sit down, grab a snack π, this one's a whole journey.
β¨ NAME β¨
initrd β boot loader initialized RAM disk π¦
π CONFIGURATION π
so initrd lives at /dev/initrd, and it's a read-only block device. its major number is 1 and its minor number is 250. typically /dev/initrd is owned by root:disk with mode 0400 β that means read access by root only, no one else invited to the party. π
if your Linux system doesn't already have /dev/initrd created, you can make it yourself with these commands:
mknod -m 400 /dev/initrd b 1 250
chown root:disk /dev/initrd
also!! this is important bestie: support for both "RAM disk" and "Initial RAM disk" (like CONFIG_BLK_DEV_RAM=y and CONFIG_BLK_DEV_INITRD=y) has to be compiled directly into the Linux kernel for /dev/initrd to work at all. and when you're using /dev/initrd, the RAM disk driver cannot be loaded as a module. no cap. that's just how it is. π
πΈ DESCRIPTION πΈ
the special file /dev/initrd is a read-only block device. it's a RAM disk that gets initialized (i.e., loaded) by the boot loader before the kernel starts. then the kernel can use /dev/initrd's contents for a two-phase system boot-up. iconic behavior honestly. β¨
in the first boot-up phase, the kernel starts up and mounts an initial root filesystem from the contents of /dev/initrd (like, a RAM disk initialized by the boot loader). in the second phase, additional drivers or other modules get loaded from the initial root device's contents. after those extra modules are loaded, a new root filesystem (i.e., the normal root filesystem) gets mounted from a different device. slay. π
π Boot-up operation π
when you boot up with initrd, the system boots like this:
- 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/initrdonto device/dev/ram0, and then frees the memory that/dev/initrdwas using. - 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 straight to the last step for the usual boot sequence. shortcut! π - if the executable file
/linuxrcis present in the initial root filesystem,/linuxrcis executed withUID 0. (the file/linuxrcmust have executable permission. the file/linuxrccan be any valid executable, including a shell script. a script girlie, we love to see it. π«Ά) - 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. and that's the whole glow-up. π
π Options π
these boot loader options, when used with initrd, affect the kernel's boot-up operation:
initrd=filename β 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. πnoinitrdβ 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 contents of/dev/initrdloaded into memory by the boot loader contents are preserved. this option permits the contents 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. so use that one read wisely bestie πroot=device-name β 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 it can be used as an option line in the LILO configuration file/etc/lilo.config. the device specified by this option must be a mountable device having a suitable root filesystem. no random device, she has standards. β¨
π¦ Changing the normal root filesystem π¦
by 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, you have to use the nfs_root_name and nfs_root_addrs boot options to give the NFS settings. for more info on NFS-mounted root, see the kernel documentation file Documentation/filesystems/nfs/nfsroot.rst. for more info on setting the root filesystem, see also the LILO and LOADLIN documentation. π
it is also possible for the /linuxrc executable to change the normal root device. for /linuxrc to change the normal root device, /proc must be mounted. after mounting /proc, /linuxrc changes 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 /linuxrc write 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 /linuxrc write the NFS setting into files /proc/sys/kernel/nfs-root-name and /proc/sys/kernel/nfs-root-addrs, and 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-dev
and 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 193.8.232.7 for a system with IP number 193.8.232.2 and named idefix:
echo /var/nfsroot >/proc/sys/kernel/nfs-root-name
echo 193.8.232.2:193.8.232.7::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 fileDocumentation/admin-guide/initrd.rst, as well aspivot_root(2)andpivot_root(8), for information on the modern method of changing the root filesystem. bestie, we moved on. periodt. π
π Usage π
the main motivation for implementing initrd was to allow for modular kernel configuration at system installation. honestly? forward-thinking queen behavior. π
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. it's giving construction site π§) - the executable
/linuxrcsets/proc/sys/kernel/real-root-dev, unmounts/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/initrd in 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. no recompiling?? we love efficiency π
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 /linuxrc file or a file executed by /linuxrc would be different. one file change, whole network served. π
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/initrd can use a dialog and/or auto-detection followed by a possible sanity check. cute and functional. π
last but not least, Linux distributions on CD-ROM may use initrd for easy installation from the CD-ROM. the distribution can use LOADLIN to directly load /dev/initrd from CD-ROM without the need of any floppies. the distribution could also use a LILO boot floppy and then bootstrap a bigger RAM disk via /dev/initrd from the CD-ROM. floppies could never. π
β FILES β
/dev/initrd/dev/ram0/linuxrc/initrd
π NOTES π
- 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. mind the gap bestie π - with the current kernel, if directory
/initrddoes not exist, then/dev/ram0will not be fully unmounted if/dev/ram0is used by any process or has any filesystem mounted on it. if/dev/ram0is not fully unmounted, then/dev/ram0will remain in memory. - users of
/dev/initrdshould not depend on the behavior given in the above notes. the behavior may change in future versions of the Linux kernel. so don't build your whole personality on it, fr fr. π«Ά
β¨ SEE ALSO β¨
okay so you've read the whole thing and you're like "what now" π«Ά here's the homework, bestie. go forth and cross-reference:
chown(1)β for when you need to change who owns what πmknod(1)β for making device nodes, the whole/dev/initrdmoveram(4)β the RAM disk lore, same energy, different pagefreeramdisk(8)β the tool that gives your RAM back (iconic, honestly)rdev(8)β the O.G. root-device fiddler
and for my deep-dive girlies who want the extended universe β¨:
Documentation/admin-guide/initrd.rstin the Linux kernel source tree β the actual, canonical, main-character source- the LILO documentation
- the LOADLIN documentation
- the SYSLINUX documentation
go read them. no cap. it's giving academic excellence π
and that's the whole page, bestie!! you made it through initrd(4) and honestly?? slay π this one came from Linux man-pages 6.20, dated 2026-02-08 β so if you're reading this in the future, hi, you're gorgeous, go touch some grass and then go build your initrd πΈπ¦π
we're SO back. periodt. π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1997, John S. Kallal <kallal@voicenet.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms