InLinux systems,initrd (initialramdisk) is a scheme for loading a temporary rootfile system intomemory, to be used as part of theLinux startup process.initrd andinitramfs (frominitialRAM file system) refer to two different methods of achieving this. Both are commonly used to make preparations before the realroot file system can bemounted.
ManyLinux distributions ship a single, genericLinux kernel image—one which the distribution's developers create specifically to boot on a wide variety of hardware.[citation needed] Thedevice drivers for this generic kernel image are included asloadable kernel modules because statically compiling many drivers into one kernel causes the kernel image to be much larger, perhaps too large to boot on computers with limited memory, or in some cases to cause boot-time crashes or other problems due to probing for nonexistent or conflicting hardware. This static-compiled kernel approach also leaves modules in kernel memory which are no longer used or needed, and raises the problem of detecting and loading the modules necessary to mount the root file system at boot time, or for that matter, deducing where or what the root file system is.[1]
To further complicate matters, the root file system may be on a softwareRAID volume,LVM,NFS (on diskless workstations), or on an encrypted partition. All of these require special preparations to mount.[2]
Another complication is kernel support forhibernation, which suspends the computer to disk by dumping an image of the entire contents of memory to aswap partition or a regular file, then powering off. On next boot, this image has to be made accessible before it can be loaded back into memory.
To avoid having to hardcode handling for so many special cases into the kernel, an initial boot stage with a temporary root file-system—now dubbedearly user space—is used. This root file-system can contain user-space helpers which perform the hardware detection, module loading and device discovery necessary to mount the actual file-system.[2]

mkinitcpio, a program to generate initramfs onArch Linux and related distributions
dracut, another program to generate initramfs on some Linux distributionsAnimage of this initial root file system (along with the kernel image) must be stored somewhere accessible by the Linuxbootloader or the boot firmware of the computer. This can be the root file system itself, aboot image on anoptical disc, a small partition on a local disk (aboot partition, usually usingext2 orFAT file systems), or aTFTP server (on systems that can boot fromEthernet).
The bootloader will load the kernel and initial root file system image into memory and then start the kernel, passing in the memory address of the image. At the end of its boot sequence, the kernel tries to determine the format of the image from its first few blocks of data, which can lead either to the initrd or initramfs scheme.
In theinitrd scheme, the image may be a file system image (optionally compressed), which is made available in a specialblock device (/dev/ram) that is then mounted as the initial root file system.[3] The driver for that file system must be compiled statically into the kernel. Many distributions originally used compressedext2 file system images, while the others (includingDebian 3.1) usedcramfs in order to boot on memory-limited systems, since the cramfs image can be mounted in-place without requiring extra space for decompression. Once the initial root file system is up, the kernel executes/linuxrc as its first process;[4] when it exits, the kernel assumes that the real root file system has been mounted and executes/sbin/init to begin the normal user-space boot process.[3]
In theinitramfs scheme (available since the Linux kernel 2.6.13), the image may be acpio archive (optionally compressed) or a concatenation of such archives. The archive is unpacked by the kernel into a special instance of atmpfs that becomes the initial root file system. This scheme has the advantage of not requiring an intermediate file system or block drivers to be compiled into the kernel.[5] Some systems use thedracut package to create an initramfs image.[6] In the initramfs scheme, the kernel executes/init as its first process that is not expected to exit.[5] For some applications, initramfs can use thecasper utility to create a writable environment usingunionfs to overlay apersistence layer over a read-only root filesystem image. For example, overlay data can be stored on aUSB flash drive, while a compressedSquashFS read-only image stored on alive CD acts as a root filesystem.[7][8]
Depending on which algorithms were compiled statically into it, the kernel can unpack initrd/initramfs images compressed withgzip,bzip2,LZMA,XZ,LZO,LZ4,[9] andzstd.
Some Linux distributions such asDebian will generate a customized initrd image which contains only whatever is necessary to boot some particular computer, such asATA,SCSI and filesystemkernel modules. These typically embed the location and type of the root file system.
Other Linux distributions (such asFedora andUbuntu) generate a more generic initrd image. These start only with the device name of the root file system (or itsUUID) and must discover everything else at boot time. In this case, the software must perform a complex cascade of tasks to get the root file system mounted:
Some distributions use anevent-driven hotplug agent such asudev, which invokes helper programs as hardware devices, disk partitions and storage volumes matching certain rules come online. This allows discovery to run in parallel, and to progressively cascade into arbitrary nestings of LVM, RAID or encryption to get at the root file system.
When the root file system finally becomes visible, any maintenance tasks that cannot run on a mounted root file system are done, the root file system is mounted read-only, and any processes that must continue running (such as the splash screen helper and its commandFIFO) are hoisted into the newly mounted root file system.
The final root file system cannot simply be mounted over/, since that would make the scripts and tools on the initial root file system inaccessible for any final cleanup tasks:
Most initial root file systems implement/linuxrc or/init as a shell script and thus include a minimal shell (usually/bin/ash) along with some essential user-space utilities (usually theBusyBox toolkit). To further save space, the shell, utilities and their supporting libraries are typically compiled with space optimizations enabled (such as withgcc's "-Os" flag) and linked againstklibc, a minimal version of theC library written specifically for this purpose.[11]
Installers for Linux distributions typically run entirely from an initramfs, as they must be able to host the installer interface and supporting tools before any persistent storage has been set up.[citation needed]
Tiny Core Linux[12] andPuppy Linux[13][failed verification] can run entirely from initrd.
This sectionneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources in this section. Unsourced material may be challenged and removed.(August 2015) (Learn how and when to remove this message) |
Since Windows Vista,[14] Windows can boot from aWIM disk image file, for which the file format is published;[15] it is similar to the ZIP format except that it supports hard links, deduplicated chunks, and uses chunk-by-chunk compression. In this case, the whole WIM is initially loaded into RAM, followed by the kernel initialisation. Next, the loaded WIM is available as a SystemRoot with an assigned drive letter. The Windows installer uses this so it boots from BOOT.WIM, and then uses INSTALL.WIM as the collection of the Windows files to be installed.
Also,Windows Preinstallation Environment (Windows PE) uses the same, being a base for separate-boot versions of some antivirus and backup/disaster recovery software.
It is also possible to install Windows so that it will always boot from a WIM or VHD file placed on a physical drive. However, this is rarely used since the Windows boot loader is capable of loading the .sys files for boot-time kernel modules itself, which is the task that requires initrd in Linux.
Dracut uses kernel parameters listed on the GRUB kernel command line to configure the initramfs RAM file system on the fly, providing more flexibiltity and furthercutting down on RAM file system code.