|
|
Subscribe / Log in / New account

Dracut looks to replace the initramfs patchwork

By Jake Edge
February 4, 2009

Creating initramfs images, for use by the kernel at "early boot" time, is a rather messy business. It is made more so by the fact that each individual distribution has its own tools to build the image, as well as its own set of tools inside it. At the 2008 Kernel Summit, Dave Jones spent some time discussing the problem along with his idea to start over by creating a cross-distribution initramfs. That has led to the Dracut project, which was announced by Jeremy Katz in December, and a new mailing list, aptly named "initramfs", in which to discuss it.

An initramfs is a cpio archive of the initial filesystem that gets loaded into memory when the kernel is loaded. That filesystem needs to contain all of the drivers and tools needed to mount the real root filesystem. It isn't strictly necessary to have an initramfs, a minimal /dev along with the required drivers built into the kernel is another alternative. Distributions, though, all use an initramfs and, over time, each has come up with their own way to handle this process. Jones, Katz, and others would like to see something more standardized, that gets pushed upstream into the mainline kernel so that distributions can stop fussing with the problem.

There are a number of advantages to that approach. Building an initramfs from the kernel sources would eliminate problems that users who build their own kernels sometimes run into. If a distribution's initramfs scheme falls behind the pace of kernel development in some fashion, users can find themselves unable to build a kernel+initramfs combination that will work. There is also hope that dracut will help speed up the boot process by using udev, as Katz puts it:

By instead moving to where we're basing everything off of uevents we can hopefully move away from the massive shell scripts of doom, speed up boot and also maybe get to where a more general initramfs can be built _with the kernel_ instead of per-system.

Because initramfs is so integral to the early boot process—and so difficult to debug if problems arise—there is a concern about starting over. It is not surprising, then, that there is some resistance to throwing out years of hard-earned knowledge that is embodied in the various distributions' initramfs handling, leading Maximilian Attems to ask:

btw why do we need dracut at all? your blog has vague allusion against initramfs-tools, which is much better tested and has seen the field.

beside having more features and flexibility it does not hardcode udev usage, nor bash, why should it not be considered at first!?

It is a question that is frequently asked, but one that Jones has a ready answer for:

"why not use the ubuntu one?"
"why not use the suse one?"

they all have some good and bad tradeoffs. Distro X has feature Y which no-one else does. etc.

When the project began we spent some time looking at what everyone else already does, and "lets start over and hope others participate" seemed more attractive than taking an existing one and bending it to fit.

So, the Red Hat folks, at least, are proceeding with dracut. Jones recently posted a status report on his blog that outlined what is working and what still needs to be done. Though it currently is "Fedora-centric, with a few hardcoded assumptions in there, so it'll likely fall over on other distros", fixing that is clearly high on the to-do list. The status report is an effort to get people up-to-speed so that other distributions can start trying it out. In addition, he plans to start trying it on various distributions himself.

In its current form, dracut is rather minimal. It has a script named dracut that will generate a gzipped cpio file for the initramfs image, as well as an init shell script that ends up in that image. Jones says that init "achieves quite a lot in its 119 lines": setting up device nodes, starting udev, waiting for the root device to show up and mounting it, mounting /proc and /sys, and more. If anything goes wrong during that process, init will drop to a shell that will allow diagnosis of the problem. So far, it only supports the simpler cases for the location of the root filesystem:

Currently, dracut supports root on raw disks (/dev/sda), lvm (/dev/mapper...), and mounting root by label or uuid. If you have a more esoteric rootfs setup, such as root-on-nfs, right now it'll fail horribly.

There is only one remaining barrier to getting rid of the unlamented nash, and that is a utility to do a switch_root (i.e. switch to a new root directory and start an init from there). The plan is to write a standalone utility that would be added to the util-linux package. The environment provided by the initramfs would include util-linux, bash, and use glibc, which doesn't sit well with some embedded folks. They generally prefer a statically linked busybox environment. Kay Sievers outlines the reasons for a standard environment:

Busybox is nice as an option to be able to rescue/hack. It should definitely be provided as an optional "plugin" for people who need it. But there is no chance to depend on it by default, for the very same reason klibc, or any other libc is not an option.

Full-featured distros who make their money with support, can just not afford to support tools compiled differently from the tools in the real rootfs. SUSE used klibc for one release, and stopped doing that immediately, because you go crazy if you run into problems with bootup problems on [customer] setups you can not reproduce with the tools from the real rootfs.

There is plenty to do to make dracut into a real tool for creating initramfs images—at least ones that work on more than just Fedora—more root filesystem types need to be handled, hibernation signatures need to be recognized and handled, the udev rules need to be cleaned up, kdump images need to be supported, etc. But the overriding question is: will other distributions start working on dracut as well? If and when Jones (or others) get things at least limping along on Debian/Ubuntu and/or SUSE, will those distributions start getting on board? So far, there is not a lot of evidence of anyone other than Red Hat working on dracut.

But, the plan is to eventually submit dracut upstream to the mainline kernel, so that make initramfs works in a standard kernel tree. It would seem that many kernel hackers see the need for standardizing initramfs and eventually moving it into the kernel, as Ted Ts'o notes:

[...] So the idea that was explored was adding a common mkinitramfs with basic functionality into kernel sources, with the ability for distributions to add various "value add" enhancements if they like. This way if the kernel wants to move more functionality (for example, in the area of resuming from hibernation) out of the kernel into initramfs, it can do so without breaking the ability of older distributions from being able to use kernel.org kernels.

So IMHO, it's important not only that the distributions standardize on a single initramfs framework, but that framework get integrated into the kernel sources.

No one is very happy about losing their particular version of the tools to build an initramfs—if only because of familiarity—but a standardized solution is something whose time has come. Probably any of the existing tools could have been used as a starting point, but for political reasons, it makes sense to start anew. There is a fair amount of cruft that has built up in the existing tools as well, which folks are unlikely to miss, so there are also technical reasons to start over. It should come as no surprise that a project started by Red Hat might be somewhat Fedora-centric in its early form, but the clear intent is to make it distribution-agnostic. It would seem the right time for other distributions and constituencies (embedded for example) to get involved to help shape dracut into something useful for all.


Index entries for this article
KernelDracut
Kernelinitramfs


to post comments

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 2:07 UTC (Thu) by miffe (subscriber, #24478) [Link] (2 responses)

Hmm, my util-linux already contains a pivot_root, itn't that what the proposed switch_root woudld do?

Or am I missing something?

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 3:22 UTC (Thu) by jbailey (guest, #16890) [Link] (1 responses)

pivot_root requires an older-style initrd. It doesn't work with an
initramfs at all.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 8:18 UTC (Thu) by jengelh (guest, #33263) [Link]

That is because initramfs is extracted to the 'rootfs' (some instance of an ramfs), and rootfs is not supposed to be pivoted. Instead, you remove all files and then do a normal chroot. In other words:

$myothercommands;
LD_LIBRARY_PATH=/mnt/lib /mnt/lib64/ld-linux-x86-64.so.2 /mnt/bin/rm -Rf /$everythingButMnt;
exec /mnt/lib64/ld-linux-x86-64.so.2 --library-path "/mnt/lib:/mnt/usr/lib" /mnt/usr/bin/chroot /mnt /sbin/init "$@";

something like that. Of course you can wrap that into a nice C program, but if it works without, you'll probably spare the extra binary.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 2:54 UTC (Thu) by me@jasonclinton.com (subscriber, #52701) [Link]

I'll be surprised if this goes anywhere other than to replace RH's aging, crufty initfs system--so, they need to do the work anyway. I'm glad that they are working on something else--it's a total pain to modify it now.

But, here's why I don't think anyone else will adopt it: I worked for a company a few years ago that built a custom thin-client software stack. I wrote all of the initramfs integration. At the time the project started, I looked around for a nice framework that already existed that I could just reuse so that I didn't have to reinvent the wheel. I evaluated every distro's initramfs generation framework. In short, they all have terrible kludges and assumptions about the host OS and requirements EXCEPT for Debian's initramfs-tools. The design is simple, elegant and completely agnostic. And it works in just about every boot case you can possibly imagine with a fully pluggable boot method system (which we abused liberally).

I think it will take a few years for Dracut or any other solution to reach that level of maturity. And I just don't see any Debian-based system switching to Dracut until its forced on them--because what they have now is so, so nice.

It's a shame that this is yet another Redhat NIH. (And I don't buy the explanation that it was done to encourage adoption. If it's the right technical solution, people will use it.)

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 3:36 UTC (Thu) by jbailey (guest, #16890) [Link] (9 responses)

(obDisclosure: I am the original author and designer of initramfs-tools)

The reason the question keeps coming up about why not reuse the initramfs-
tools code is because by the design of Dracut, it looks like they're trying
to produce the exact same thing that we did, about 3 years after we wrote
that one. Judging by the git tree, it looks like the authors haven't
bothered to look at what existing initramfs' in distros already do.
(Something which I did extensively before writing it. It wasn't like I
*wanted* to do this, just that all of the distros were still using
pivot_root at the time and I'd recently attended a talk at OLS where we
were told this method of booting was going away)

My biggest concerns are things like the authors apparently not being
interested in klibc (initramfs-tools uses that to get a nice small shell
and for embedded cases producing initramfs' that are a fraction the size of
glibc, never mind glibc plus the userspace tools), their use of bashisms,
and the fact that they're starting quite far behind on different boot
scenarios.

Hmm, I wonder if it's worth writing an LWN article on initramfs-tools
pimping it a little harder? Anyone interested in seeing it?

Tks,
Jeff Bailey

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 4:15 UTC (Thu) by linuxjacques (subscriber, #45768) [Link]

I would love to see an initramfs-tools article.

I do embedded and when I hear glibc and bash I think they must be joking.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 4:36 UTC (Thu) by jake (editor, #205) [Link]

> Hmm, I wonder if it's worth writing an LWN article on initramfs-tools
> pimping it a little harder? Anyone interested in seeing it?

Not only are we interested in seeing it, we are interested in paying for it :) See the "Write for LWN" link at the top and if you are still interested, let's talk ...

jake

Req: article on initramfs-tools.

Posted Feb 5, 2009 9:50 UTC (Thu) by k3ninho (subscriber, #50375) [Link]

Jeff, thanks for your work on initramfs-tools. I've had to start using it when I moved up to Debian from Ubuntu. I'd love to hear more about it, especially when other comments in this thread describe it as simple elegant and powerful.

K3n.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 14:55 UTC (Thu) by roblucid (guest, #48964) [Link]

Very interested!

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 16:32 UTC (Thu) by Stephen_Beynon (guest, #4090) [Link]

At the risk of this turning into a 'me too' thread I would also like to see such an
article.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 17:44 UTC (Thu) by lbt (subscriber, #29672) [Link]

Yes please - and don't forget to talk about issues with smaller devices too (eg Nokia N800).

It would be interesting to see 'the right way' to extend initramfs too.

Why not submit it upstream - no-one thinks twice about YAFS so it seems reasonable to have a competing initramfs tool.

Dracut looks to replace the initramfs patchwork

Posted Feb 8, 2009 22:24 UTC (Sun) by apollock (subscriber, #14629) [Link]

Yes, please do write an article. I'd be happy to help. Having dicked around with Ubuntu's initramfs to customisation purposes, it's really a hidden goldmine of flexibility.

Dracut looks to replace the initramfs patchwork

Posted Feb 11, 2009 20:55 UTC (Wed) by tack (guest, #12542) [Link]

One more "me too."

I recently got a thorough education on how initramfs-tools works in troubleshooting recent root-over-lvm-over-md problems, and I must say I was very pleased with the design, flexibility, and customizability.

When I later had to deal with Fedora's initrd toolset, I was one very agitated sysadmin.

Dracut looks to replace the initramfs patchwork

Posted Aug 3, 2010 21:24 UTC (Tue) by bobbytables (guest, #65908) [Link]

+1

I was introduced to initramfs-tools when I started building my kernel.org images with kernel-package/make-kpkg (yet another great Debian tool).

It was a breeze for me so I didn't even appreciate how good it is... until I tried to set up my full disk encryption on another distro (a root partition inside a LVM2 container inside a LUKS partition) - it was pain...

Congrats for your work and I'd really like to see an article!

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 9:43 UTC (Thu) by climent (guest, #7232) [Link] (2 responses)

Not only every basic feature will have to be implemented in dracut, but also every extended feature (read cryptofs/LUKS) will have to be. For all the distros.

The day that happens we have a replacement. Otherwise, I want to be able to boot from my encrypted partitions when i use my laptop.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 14:22 UTC (Thu) by nix (subscriber, #2304) [Link] (1 responses)

Indeed. I have systems here that boot normally, systems here that need to
mount LVM, systems that mount LVM-atop-RAID, one bizarre system that has a
root filesystem on RAID-atop-LVM (!), a couple of systems whose RAID
arrays are assembled over the network block device, and one that never
actually mounts a root filesystem atop the rootfs but does all its work
from there.

Booting can be arbitrarily complicated: it must, no matter what, remain
possible to *replace* whatever standardized initramfs framework goes
upstream, because nothing will ever cope with all the utterly bizarre
corner cases.

Dracut looks to replace the initramfs patchwork

Posted Feb 5, 2009 16:19 UTC (Thu) by iabervon (subscriber, #722) [Link]

You'll never be able to make a single initramfs image that works for everything, but I don't see any reason that a single initramfs project couldn't have a per-kernel build process that would take a set of instructions on mounting the root filesystem as part of its configuration and generate an initramfs image that does it.


Copyright © 2009, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds