ArticleslgStudy

science

Initial ramdisk

Initial ramdisk is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Initial ramdisk rather than just read about it. In short: In Linux systems, initrd (initial ramdisk) is a scheme for loading a temporary root file system into memory, to be used as part of the Linux startup process. initrd and initramfs (from initial RAM file system) refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

Initial ramdisk — main illustration
Initial ramdisk — illustration

Key takeaways

  • Initial ramdisk belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Initial ramdisk to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Initial ramdisk from memory before moving on to harder problems.

Reference excerpt

In Linux systems, initrd (initial ramdisk) is a scheme for loading a temporary root file system into memory, to be used as part of the Linux startup process. initrd and initramfs (from initial RAM file system) refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

Rationale Many Linux distributions ship a single, generic Linux kernel image – one which the distribution's developers create specifically to boot on a wide variety of hardware. The device drivers for this generic kernel image are included as loadable 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, which in turn 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. To further complicate matters, the root file system may be on a software RAID volume, LVM, NFS (on diskless workstations), or on an encrypted partition. All of these require special preparations to mount. Another complication is kernel support for hibernation, which suspends the computer to disk by dumping an image of the entire contents of memory to a swap 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 dubbed early 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.

Implementation

An image of this initial root file system (along with the kernel image) must be stored somewhere accessible by the Linux bootloader or the boot firmware of the computer. This can be the root file system itself, a boot image on an optical disc, a small partition on a local disk (a boot partition, usually using ext2 or FAT file systems), or a TFTP server (on systems that can boot from Ethernet). 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 the initrd scheme, the image may be a file system image (optionally compressed), which is made available in a special block device (/dev/ram) that is then mounted as the initial root file system. The driver for that file system must be compiled statically into the kernel. Many distributions originally used compressed ext2 file system images, while the others (including Debian 3.1) used cramfs 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; 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. In the initramfs scheme (available since the Linux kernel 2.6.13), the image may be a cpio archive (optionally compressed) or a concatenation of such archives. The archive is unpacked by the kernel into a special instance of a tmpfs 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. Some systems use the dracut package to create an initramfs image. In the initramfs scheme, the kernel executes /init as its first process that is not expected to exit. For some applications, initramfs can use the casper utility to create a writable environment using unionfs to overlay a persistence layer over a read-only root filesystem image. For example, overlay data can be stored on a USB flash drive, while a compressed SquashFS read-only image stored on a live CD acts as a root filesystem. Depending on which algorithms were compiled statically into it, the kernel can unpack initrd/initramfs images compressed with gzip, bzip2, LZMA, XZ, LZO, LZ4, and zstd.

Mount preparations Some Linux distributions such as Debian will generate a customized initrd image which contains only whatever is necessary to boot some particular computer, such as ATA, SCSI and filesystem kernel modules. These typically embed the location and type of the root file system. Other Linux distributions (such as Fedora and Ubuntu) generate a more generic initrd image. These start only with the device name of the root file system (or its UUID) 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:

… excerpt ends here. Continue reading the full article.

Illustrations

Initial ramdisk: dracut, another program to generate initramfs on some Linux distributions
dracut, another program to generate initramfs on some Linux distributions

Worked examples

Example 1 — a first encounter with Initial ramdisk

Start with the simplest possible case. Write down what Initial ramdisk claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Initial ramdisk before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Initial ramdisk ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Initial ramdisk

In research
Initial ramdisk appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Initial ramdisk in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Initial ramdisk is common in secondary-school and first-year university syllabi. It links to neighbouring topics Booting, Linux kernel, so understanding it makes those chapters shorter.
In everyday life
Look for Initial ramdisk outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Initial ramdisk” →

How to study Initial ramdisk in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Initial ramdisk means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Initial ramdisk out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Initial ramdisk in simple terms?

In Linux systems, initrd (initial ramdisk) is a scheme for loading a temporary root file system into memory, to be used as part of the Linux startup process. initrd and initramfs (from initial RAM file system) refer to two different methods of achieving this. Both are commonly used to make preparat…

Why does Initial ramdisk matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Initial ramdisk?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Initial ramdisk.

Tags

  • Booting
  • Linux kernel

Keep exploring