The initial RAM disk (initrd) is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system.
initrd provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root filesystem and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then moved to a directory and can be subsequently unmounted.
How initrd works
initrd provides the capability to load a RAM disk by the bootloader. This RAM disk can then be mounted as the root fileystem and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. Theprevious root (from initrd) is then moved to a directory andcan be subsequently unmounted. initrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd.
When using initrd, the system typically boots as follows:
- The boot loader loads the kernel and the initial RAM disk
- The kernel converts initrd into a “normal” RAM disk and frees the memory used by initrd
- initrd is mounted read-write as root
- /linuxrc is executed (this can be any valid executable, including shell scripts; it is run with uid 0 and can do
basically everything init can do)
- linuxrc mounts the “real” root file system
- linuxrc places the root file system at the root directory using the pivot_root system call
- The usual boot sequence (e.g. invocation of /sbin/init) is performed on the root file system
8) The initrd file system is removed
That changing the root directory does not involve unmounting it. It is therefore possible to leave processes running on initrd during that procedure. Also note that file systems mounted under initrd continue to be accessible.