what is initrd in Linux?

What is initrd image in Linux

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:

  1. The boot loader loads the kernel and the initial RAM disk
  1. The kernel converts initrd into a “normal” RAM disk and frees the memory used by initrd
  1. initrd is mounted read-write as root
  1. /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)

  1. linuxrc mounts the “real” root file system
  1. linuxrc places the root file system at the root directory using the pivot_root system call
  1. The usual boot sequence (e.g. invocation of /sbin/init) is performed on the root file system

8) The initrd file system is removed

Note

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.

initrd

Advertisements

Posted on June 16, 2015, in Linux (Ubuntu/CentOS). Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: