[Spec] Switch to Dracut

Abstract

Switch the default initrd infrastructure from initramfs-tools to Dracut.

Rationale

Ubuntu desktop/server uses initramfs-tools to generate initrds which has following problems/drawbacks:

  1. systemd is not used in the initrd (for point 3 and 5)¹
  2. It lacks features like NVMe over Fabric (NVM-oF) support
  3. There is not much code sharing between the initrd and the root system, increasing maintenance costs
  4. There is not much development work done upstream in the recent years (mostly maintenance work)
  5. There is a lot of Shell code in the initrd²
  6. The initrd generation is pure Shell code²

¹ Ubuntu Core is already using a systemd-based initrd (core-initrd uses Dracut).
² Shell code makes it slow, fragile, hard to understand, and all the usual issues with shell scripts.

Specification

To address the first four points of the Rationale the plan is to change the default initrd generation tool of Ubuntu Desktop and Ubuntu server from initramfs-tools to Dracut. Since systemd is used in Ubuntu, Dracut will use the systemd Dracut module. Using systemd in the initrd will reduce the amount of Shell code in the initrd.

Dracut will provide support for following features (compared to initramfs-tools):

This switch will be done step by step over multiple Ubuntu releases:

  1. Make sure that the common/basic use cases work with Dracut. Allow users testing Dracut for their setup (by installing dracut-core and calling dracut manually). Provide instructions for testing and reporting issues found there. Collect feedback which use cases need work. This is planned for Ubuntu 24.10 (oracular).
  2. Support Dracut as alternative initrd tool: Promote dracut to main (MIR bug #2031304) and change initramfs-tools dependencies in ubuntu-desktop (and similar) to initramfs-tools | dracut (see Support Dracut as alternative initrd tool). Maintainers of prebuilt images can decide to use dracut (e.g. some cloud images). This is planned for Ubuntu 25.04.
  3. Make Dracut the default initrd tool by changing dependencies in ubuntu-desktop (and similar) to `dracut | initramfs-tools`. The installer will install dracut by default. Users can still install initramfs-tools in case of problems. This is proposed for Ubuntu 25.10.
  4. Drop support for initramfs-tools (demote to universe) and only support Dracut. ubuntu-desktop (and similar) will only depend on `dracut`. This is proposed for Ubuntu 26.04.

Issues and missing support for use cases will be tracked on https://bugs.launchpad.net/ubuntu/+source/dracut. Each step can be deferred to a later Ubuntu release in case there are issues reported that need to be addressed first.

The live images use casper and initramfs-tools. These live images need porting to Dracut which supports live systems via dracut-live. Dracut-live supports booting from SquashFS images by specifying root=live:<URL> (where <URL> could be CDLABEL=$ubuntu_label). Dracut needs to be extended to support stacking multiple squashfs images (see upstream bug #700). All casper-bottom scripts need to be ported to Dracut or incorporated into the respective upstream projects (e.g. services could be enabled/disabled via ConditionKernelCommandLine=rd.live.image or similar).

Reducing the amount of Shell code can be done afterwards in the Dracut upstream project, which already has some C code (dracut-install and dracut-utils). Efforts to port more Shell code to a proper language are more likely in Dracut due to the wider community.

Moving to a vendor-built initrd is orthogonal to this spec and is not part of it.

Supported and tested use cases

All disk setup options that you can select in the installer need to be supported by Dracut before making Dracut the default (see point 3):

We will officially only support Dracut when used together with the systemd module. Dracut modules for packages in universe will only get community support.

packages with initramfs-tools integration

Ubuntu ships 77 packages that ship initramfs-tools hooks/scripts/modules:

Source Package Component dracut-support
ntfs-3g ntfs-3g main maybe, ntfs-3g is supported in 90dmsquash-live
brltty brltty main no, brltty and braille not found in source
busybox busybox-initramfs main no, but 05busybox uses /usr/bin/busybox
casper casper main no, needs porting, dracut supports live images
cloud-initramfs-tools cloud-initramfs-copymods main no, copymods or module copying /lib/modules not found in source
cloud-initramfs-tools cloud-initramfs-dyn-netconf main no, but should be covered by network module
cloud-initramfs-tools cloud-initramfs-growroot main no, but cloud-initramfs-tools source has 50growroot module
cloud-initramfs-tools cloud-initramfs-rescuevol main no, rescue not found (except rescue.service from systemd)
cloud-initramfs-tools cloud-initramfs-updateroot main no, updateroot not found in source
kdump-tools kdump-tools main no, needs porting
klibc klibc-utils main no, klibc not found in source
mini-iso-tools mini-iso-tools main no, needs porting
cloud-initramfs-tools overlayroot main no, needs porting to 90overlayfs dracut module
ubuntu-raspi-settings ubuntu-raspi-settings-desktop main no, needs porting, zswap not found in dracut source
walinuxagent walinuxagent main no, but just copies 2 udev rules, azure not found in source
cloud-initramfs-tools cloud-initramfs-rooturl main partial, root=live:<url> supports squashfs but not tarballs
fuse3 fuse3 main partial, in 90dmsquash-live-ntfs module
amd64-microcode amd64-microcode main yes, see early_microcode in dracut.sh
bcache-tools bcache-tools main yes, package ships 90bcache dracut module
btrfs-progs btrfs-progs main yes, in 90btrfs dracut module
cryptsetup cryptsetup-initramfs main yes, 90crypt and 90systemd-cryptsetup and others
dmraid dmraid main yes, 90dmraid module
lvm2 dmsetup main yes, probably by 90dm module
intel-microcode intel-microcode main yes, see early_microcode in dracut.sh
open-iscsi iscsiuio main yes, in 95iscsi module
kbd kbd main yes, in 10i18n module
console-setup keyboard-configuration main yes, in 10i18n module but might need added support
kmod kmod main yes, initramfs-tools hook not needed in dracut
multipath-tools kpartx-boot main yes, in 90multipath module
lvm2 lvm2 main yes, probably by 90lvm module
mdadm mdadm main yes, in 90mdraid module
multipath-tools multipath-tools-boot main yes, in 90multipath module
open-iscsi open-iscsi main yes, in 95iscsi module
plymouth plymouth main yes, in 50plymouth dracut module
reiserfsprogs reiserfsprogs main yes, dracut supports reiserfsck
sg3-utils sg3-utils-udev main yes, 95udev-rules copies the scsi-sg3 udev rules
thin-provisioning-tools thin-provisioning-tools main yes, 90lvm supports thin volumes
systemd udev main yes, in 01systemd-udevd dracut module
xfsprogs xfsprogs main yes, dracut supports xfs
zfs-linux zfs-initramfs main yes, via zfs-dracut
r8125 r8125-dkms multiverse maybe, this hook just copies the r8125 kernel module
nvidia-graphics-drivers-470 nvidia-kernel-common-470 restricted maybe, this hook just copies the nvidia kernel module
nvidia-graphics-drivers-470-server nvidia-kernel-common-470-server restricted maybe, this hook just copies the nvidia kernel module
nvidia-graphics-drivers-535 nvidia-kernel-common-535 restricted maybe, this hook just copies the nvidia kernel module
nvidia-graphics-drivers-535-server nvidia-kernel-common-535-server restricted maybe, this hook just copies the nvidia kernel module
nvidia-graphics-drivers-550 nvidia-kernel-common-550 restricted maybe, this hook just copies the nvidia kernel module
nvidia-graphics-drivers-550-server nvidia-kernel-common-550-server restricted maybe, this hook just copies the nvidia kernel module
librem-ec-acpi librem-ec-acpi-dkms universe maybe, this hook just copies the librem_ec_acpi kernel module
r8168 r8168-dkms universe maybe, this hook just copies the r8168 kernel module
aoetools aoetools universe no, aoe not found in source
bcachefs-tools bcachefs-tools universe no, bcachefs not found in source
bilibop bilibop-lockfs universe no, bilibop and lockfs not found in source
bootcd bootcd universe no, but dracut supports live images
cryptsetup-nuke-password cryptsetup-nuke-password universe no, nuke not found in source
dell-recovery dell-recovery-casper universe no, it hooks into casper, dell not found in source
dropbear dropbear-initramfs universe no, dropbear not found in source
initramfs-tools-devices initramfs-tools-devices universe no, resize not found in source
jasper-initramfs jasper universe no, no resize found in source
kubuntu-settings kubuntu-settings-desktop universe no, needs porting (but is a simple one-liner)
kxd kxc universe no, kxc not found in source
live-boot live-boot-initramfs-tools universe no, needs porting to root=live:<url>
ltsp ltsp universe no, ltsp not found in source
mandos mandos-client universe no, mandos not found in source
open-infrastructure-system-tools open-infrastructure-system-boot universe no, project has dracut backend but it contains FIXME
osk-sdl osk-sdl universe no, osk not found in source
qcom-phone-utils qcom-phone-utils universe no, neither mobile nor qcomsoc found in source
toybox toybox universe no, toybox not found in source
ubuntukylin-theme ubuntukylin-theme universe no, neither truetype nor droid found in source
ubuntustudio-default-settings ubuntustudio-default-settings universe no, org.kde.discover.notifier.desktop can be disabled differently
unl0kr unl0kr universe no, unl0kr not found in source
v86d v86d universe no, v86d not found in source
xubuntu-default-settings xubuntu-live-settings universe no, ubiquity not found in source
yubikey-luks yubikey-luks universe no, yubikey not found in source
fuse fuse universe partial, in 90dmsquash-live-ntfs module
acpi-override acpi-override-initramfs universe yes, set acpi_override and acpi_table_dir
clevis clevis-initramfs universe yes, via clevis-dracut
nbd nbd-client universe yes, in 95nbd module

Further Information

As of 2024-09-20 subiquity contains a proof of concept for installing Ubuntu with NVMe/TCP firmware support.

Considered options

Following solutions were considered:

  1. Switch to dracut
  2. Add support for systemd in initramfs-tools
  3. Switch to mkosi-initrd

Some of the reasons for switching to Dracut were mentioned above. Dracut is an upstream project which is used in several distributions. It has an active community and responsive maintainers. As of 2024-09-18 Benjamin Drung contributed 69 commits upstream and considers the upstream collaboration excellent.

Add support for systemd in initramfs-tools was decided against, because the expected amount of time for implementation is bigger than switching to Dracut. Also the maintenance work will be bigger, because initramfs-tools is a Debian-specific tool and the load cannot be shared with other distributions (except maybe Debian).

mkosi-initrd takes another approach than initramfs-tools/Dracut. It uses the distro packages to construct the initrd. Current status of mkosi-initrd: It works for simple use cases, but the initrd is still bigger than the alternatives. Upstream is focusing on the infrastructure first. It will be a long road to support all the different use cases. mkosi-initrd relies on the distro packages to be available and does not support running on installed distro packages. See also
the All Systems Go! 2024 talk “mkosi-initrd: initrds built from system packages”
So switching to mkosi-initrd is not viable in the short or medium term, but could be considered in the future. A smoother approach could be taken: Work on the upstream projects to work out of the box in the initrd. This will reduce the needed Shell script in Dracut but also pave the road to make these projects work with mkosi-initrd.

5 Likes

The casper file has been replaced by a systemd service in ubuntustudio-live-settings which is only installed in the live session. This should now be fully compatible.

1 Like

I tried dracut on Plucky and Oracular and found no problems, but don’t all those unsupported components hinder the transition to dracut?

That’s the point; so that developers can get these components updated to work with dracut. For instance, I already updated the item that I’m responsible for.

I’m confused by this. Why no Btrfs?

2 Likes

Can we have with dracut the command update-initramfs or similar, like update-initrd or update-dracut? I think these update-* commands are nice and useful. I frequently use them, like update-initramfs itself, and update-grub. I just installed dracut to replace initramfs on Ubuntu 24.10, and I miss something like update-initramfs -k all -u to recreate all the initramfs. Ok, I know there is dracut --force --regenerate-all that does the same, but I still think update-* commands are nice and keep things standardized.

There are equivalent dracut calls to update-initramfs, but we could add a update-initramfs wrapper to the dracut package (keeping the same interface). @mhalano, can you file a bug against dracut to add this script?

I’m currently using Dracut with btrfs on my Thinkpad T480s, it works just fine. :slight_smile:

It should be added to the list.

2 Likes

Done: Bug #2098525 “Add dracut support for update-initramfs command” : Bugs : dracut package : Ubuntu

1 Like