Slashdot Mirror


Discover the Anatomy of initrd

IdaAshley writes "The Linux initial RAM disk (initrd) is a temporary root file system that is mounted during system boot to support the two-state boot process. It contains various executables and drivers that permit the real root file system to be mounted, after which the initrd RAM disk is unmounted and its memory freed. In this article explore the initial RAM disk for Linux 2.6, including its creation and use in the Linux kernel. In many embedded Linux systems, the initrd is the final root file system."

6 of 41 comments (clear)

  1. More trouble... by misleb · · Score: 3, Interesting

    Is it just me, or does maintaining initrd seem like more trouble than it is worth? I guess it is good for generic distributions which want to support every hardware config under the sun and keep the kernel small, but if you know the (set of) hardware you are going to be running a given kernel on, you might as well just blow that initrd crap away. Whenever I recompile a kernel, initrd is the first thing to go. All you need in the kernel to make initrd irrelevent is disk and filesystem (and maybe software RAID modules) support. You can keep everything else as modules.

    -matthew

    --
    "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    1. Re:More trouble... by xiox · · Score: 2, Interesting

      We use initrd do to diskless booting. The initrd does dhcp and mounts an nfs partition as root and switches over to that. This is quite cool as the initrd can be quite intelligent, for instance using different root disks depending on which computer it runs on.

  2. Initramfs? by qbwiz · · Score: 2, Interesting

    I thought that initramfs was the hotness? Why would we want to use initrd over initramfs (or vice versa, for that matter)?

    --
    Ewige Blumenkraft.
  3. Nontrivial Boot Environments by KagatoLNX · · Score: 3, Interesting

    There are definitely times where it is required.

    Take, for example, booting onto a root on a SAN--specifically a Coraid Ethernet SAN.

    During boot, you must bring up the ethernet interface, load the AoE module, probe for the SAN, wait for it to quiesce, then enable clustering, join the cluster, join the fence domain, allow the cluster to quiesce, load the DLM, enable CLVM, probe and activate everything, then mount your root GFS (or OCFS2 if you can get that working).

    This would not be possible without a good initrd.

    Also, not so obviously, distros aren't the only people who deploy a single kernel on lots of hardware. When you have 300 old Dells, 150 old gateways, 75 custom built boxen, and a handful of laptops, maintaining a single kernel and initrd beats maintaining ten of them. Not your use case, but definitely important.

    --
    I think Mauve has the most RAM. --PHB (Dilbert Comic)
  4. initramfs vs. initrd by ColonelPanic · · Score: 2, Interesting

    We use both in our port of Linux to proprietary Cray architectures.

    Initramfs is synthesized from the stock page and dentry caches. The nice thing about
    initramfs is that RAM gets released to the dynamic pool when an inode is deleted. So
    it's a good choice for files that need to be present at boot time but not kept around,
    like kernel modules. The bad thing: each file occupies at least one page, and that's
    64KiB here. An initramfs with lots of little files can waste beaucoup bytes.

    RAM "disks" are devices that occupy statically allocated memory. Storage doesn't get
    reclaimed, but no storage is wasted by rounding up file sizes. An initrd is an image
    of a RAM disk, possibly compressed.

    Note that a cpio archive, possibly compressed, that's loaded in place of an initrd image
    gets automatically
    expanded and copied into the initramfs.

    Confusingly, the kernel also has its own compressed cpio archive within its own text containing
    the initial content of the initramfs. At a minimum, it holds /, /dev, and /dev/console.

    If you're using an architecture with small pages (read: x86), use initramfs. Otherwise,
    you may need a clever hybrid solution, such as populating initramfs from a compressed cpio
    archive and then moving some of its content into a RAM disk.

    --
    "Skill shows through where genius wears thin." -Wittgenstein || Religion: uniting aviation and architecture.
  5. Options for fast booting by wall0159 · · Score: 5, Interesting


    I don't know much about this, but am curious.

    Why, once the system is booted cleanly, can't it save its state in initrd, and just load the state the next time without going through the boot process? Would that result in fast booting?