Code Monkey home page Code Monkey logo

dracut-ng's Introduction

dracut-ng

dracut-ng is an event driven initramfs infrastructure.

Contributor Covenant Packaging status latest packaged version(s)

dracut-ng (the tool) is used to create an initramfs image by copying tools and files from an installed system and combining it with the dracut framework, usually found in /usr/lib/dracut/modules.d.

Unlike other implementations, dracut hard-codes as little as possible into the initramfs. The initramfs has (basically) one purpose in life -- getting the rootfs mounted so that we can transition to the real rootfs. This is all driven off of device availability. Therefore, instead of scripts hard-coded to do various things, we depend on udev to create device nodes for us and then when we have the rootfs's device node, we mount and carry on. This helps to keep the time required in the initramfs as little as possible so that things like a 5 second boot aren't made impossible as a result of the very existence of an initramfs.

Most of the initramfs generation functionality in dracut is provided by a bunch of generator modules that are sourced by the main dracut script to install specific functionality into the initramfs. They live in the modules.d subdirectory, and use functionality provided by dracut-functions to do their work.

Documentation:

Currently dracut-ng is developed on github.com.

The release tarballs are here.

Chat (Matrix):

See News for information about changes in the releases and the Wiki to share information.

See the GitHub issue tracker for things which still need to be done. This is also the main place used for discussions. See Hacking for some instructions on how to get started.

Licensed under the GPLv2

dracut-ng's People

Contributors

aafeijoo-suse avatar aidecoe avatar arvidjaar avatar bdrung avatar bengal avatar daveyoung avatar ddiss avatar dillow avatar dtardon avatar fgrose avatar haraldh avatar henrik66 avatar jlebon avatar johannbg avatar katzj avatar laszlogombos avatar lkundrak avatar lnykryn avatar mrc0mmand avatar msoltyspl avatar nabijaczleweli avatar puleglot avatar ryncsn avatar seewer avatar steffen-maier avatar tblume avatar victorlowther avatar watologo1 avatar wgwoods avatar yuwata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dracut-ng's Issues

Nothing depends on systemd-pcrphase

Describe the bug
systemd-pcrphase module needs to be manually added because no other module depends on it and check() returns 255 if the binaries exist.

Distribution used
Gentoo

Dracut version
060_pre20240104-r4^t

Init system
Systemd

Expected behavior
systemd-pcrphase is added to the initramfs when secureboot and TPM2 measurements are enabled.

Additional context
Does measured boot require a separate config flag, or would it be better if dracut recognizes if measuring is enabled by default?

install hwdb on demand

Adding a module to install hwdb. Further extensions might make only selected part of hwdb installable, to save space. The module is not included by default.

Including the module adds 2MB of compressed data (on Fedora, the file has 12MB).

hwdb is needed in case of custom HW, like a keyboard/mouse or various interfaces.

Original PR: dracutdevs/dracut#1681

CC @pvalena

detect and generate initrd.img-${kernel}

https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ refers to initramfs as "initrd".

One of the most popular distro's (Debian) expects /boot/initrd.img-${kernel} instead of initramfs-${kernel}.img, see https://kernel-team.pages.debian.net/kernel-handbook/ch-packaging.html#s-arch-dep

Let's look for a way to detect in a reliable way what should be the default output file that is more inclusive.

Possibly related openSUSE patch downstream: dracutdevs/dracut@f68649c

`LiveOS/squashfs.img` missing an (empty) `/proc` folder results in broken boot

dracut currently requires in some cases folder /proc to be existing inside the LiveOS/squashfs.img. No image should require to come with an empty /proc folder.

dmsquash-live-root.sh

    elif [ -d /run/initramfs/squashfs/proc ]; then

This seems wrong. /proc is created at boot time. There should be no need for an image to come with an empty /proc folder.

Was also pointed out by @FGrose here: dracutdevs/dracut#1820 (comment) (and also been the committer 789668d).

I guess the intention is to check if the mounting of the LiveOS/squashfs.img has resulted in a usable image? How about checking /usr instead? Images without /etc might be available at some point but probably not without /usr which seems more appropriate.

consistent dracut messages

dracut[I]: *** Creating image file '/var/tmp/dracut-test.RsZ2rj/initramfs.makeroot' ***
dracut[I]: Using auto-determined compression method 'pigz'
dracut[I]: *** Creating initramfs image file '/var/tmp/dracut-test.RsZ2rj/initramfs.makeroot' done ***

Some messages comes with *** some do not. Make it hard to read and inconsistent. Project should decide one way or another and make it consistent.

CC @Conan-Kudo @aafeijoo-suse @pvalena for feedback

rd.live.overlay.overlayfs doesn't seem to work when $DRACUT_SYSTEMD=1

dracutdevs/dracut#1820

Issue can be reproduced by running test-16 with the following change in the source tree

--- a/test/TEST-16-DMSQUASH/test.sh
+++ b/test/TEST-16-DMSQUASH/test.sh
@@ -136,8 +136,8 @@ SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="ntfs", ENV{ID_FS_TYPE}="ntfs3"
 EOF
 
     "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-        --modules "test dash dmsquash-live qemu" \
+        --modules "test dash dmsquash-live qemu dracut-systemd" \

Factoring out initqueue into its own dracut module for systemd-enabled initrds

An idea has been floating around to support a dracut configuration where systemd dracut modules are included with the exception of the dracut-systemd module. This would remove the initqueue from initrd and just use systemd to schedule.

Generating such as initrd is already supported by adding -o dracut-systemd to the dracut command line option, but such an initrd might not be fully functional. Systemd itself however supports this use case as some initrd generators (such as mkosi, mkinitramfs) generate initrds without an extra initqueue.

Mainly dropping issue this here just for visibility and to at least not work against this potential project goal. I myself not planning to work on it, but perhaps someone else is interested.

CC @lnykryn @pvalena

rd.live.overlay.overlayfs=1 is broken on Fedora 39 LiveOS #2645

Describe the bug
A clear and concise description of what the error is.

rd.live.overlay.overlayfs=1 is supposed to provide a non-persistent (i.e. deleted after reboot of Live Image) and temporary storage in RAM at /run/overlayfs which is by default 32GiB unless another parameter is supplied : rd.live.overlay.size=<size_MiB> . See dracut documentation #Booting live images

Using rd.live.overlay.overlayfs=1 as kernel command line parameter has two issues

  1. sudo dmesg | grep overlayfs includes an error:
    [ 13.317280] overlayfs: failed to resolve '/run/overlayfs': -2

  2. Installing any rpm package once Fedora 39 LiveOS is running, results with the same errors
    error: lsetfilecon: (33 /usr/bin/make-dummy-cert;66130180, system_u:object_r:bin_t:s0) Permission denied
    error: Plugin selinux: hook fsm_file_prepare failed
    [...]
    Error unpacking rpm package
    Failed:
    Error: Transaction failed

Below an example with openssl

 sudo dnf install -y openssl`
Last metadata expiration check: 1:44:39 ago on Sun 07 Apr 2024 08:41:58 PM CEST.
Dependencies resolved.
===============================================================================
 Package                  Architecture            Version                            Repository               Size
===============================================================================
Installing:
 openssl                  x86_64                  1:3.1.1-4.fc39                     fedora                  1.0 M

Transaction Summary
===============================================================================
Install  1 Package

Total download size: 1.0 M
Installed size: 1.6 M
Downloading Packages:
openssl-3.1.1-4.fc39.x86_64.rpm                                                    1.4 MB/s | 1.0 MB     00:00    
-------------------------------------------------------------------------------------------------------------------
Total                                                                              802 kB/s | 1.0 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                           1/1 
  Installing       : openssl-1:3.1.1-4.fc39.x86_64                                                             1/1 
error: lsetfilecon: (33 /usr/bin/make-dummy-cert;66130180, system_u:object_r:bin_t:s0) Permission denied
error: Plugin selinux: hook fsm_file_prepare failed

Error unpacking rpm package openssl-1:3.1.1-4.fc39.x86_64
  Verifying        : openssl-1:3.1.1-4.fc39.x86_64                                                             1/1 

Failed:
  openssl-1:3.1.1-4.fc39.x86_64                                                                                    

Error: Transaction failed

Distribution used
Which distribution was this behaviour seen in?
Fedora 39 LiveOS

Dracut version
Which dracut version was this behaviour seen in?
Fedora 39 dracut-059-16.fc39
Init system
Which init system is being used?
systemd
To Reproduce
Steps or code to reproduce the behavior.
Insert alongside your kernel command line parameter on Fedora 39 Live ISO (for example in a grub.cfg menuentry) rd.live.overlay.overlayfs=1 after the parameter rd.live.image
Expected behavior
A clear and concise description of what you expected to happen.

We should have with this parameter :

  1. a root live filesystem with 32GiB of available RAM space instead of 4.9G is used and 1.5G is available space out of a total size of 6.4G if this parameter is not used

  2. the ability to install rpm packages with sudo dnf install <package> until the available RAM is depleted

Additional context
Add any other context you like about the problem here.

a. Users of Fedora Linux have been reporting related bugs here: https://discussion.fedoraproject.org/t/fedora-liveos-root-system-and-available-ram/82531/1

CC @gregory-lee-bartholomew

(Cherry-picked commit from dracutdevs/dracut#2604 and dracut-ng #61)

b. The Booting Live Images documentation section could need be more "verbose" with more explanations, examples, use-cases. IMHO

Test 40 - seems to be green even when failing

From the log

grep: /var/tmp/dracut-test.q2jsMX//var/tmp/dracut-test.q2jsMX/marker.img: No such file or directory

Seen it failing/timeout only on alpine and void (non-systemd) container.

Test 30, 35 on Debian and Ubuntu

From dracutdevs/dracut#2497 and dracutdevs/dracut#2498

Test 30 seem to be passing both on non-Debian based distributions (Fedora, openSUSE, Arch, Gentoo)

dracut[I]: *** Including module: iscsi ***
Failed to enable unit, unit iscsiuio.socket does not exist.

Test 35. seems to have a similar issue as Test 30.

In the Fedora and Arch test container /lib/systemd/system/iscsiuio.socket file exists. In the Debian and Ubuntu test container it does not. Installing the iscsiuio might be required for in the Debian and Ubuntu test container, but even installing that package does not seems to install iscsiuio.socket file.

Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1056733

LLVM's objdump do not work in generating uki

Describe the bug
Generating UKI using LLVM's objdump would result in the following error:

dracut[F]: Failed to get the size of /usr/lib/systemd/boot/efi/linuxx64.efi.stub to create UEFI image file

Distribution used
Gentoo (using stage3-amd64-musl-llvm-20240414T161904Z.tar.tz)

Dracut version
sys-kernel/dracut-060_pre20240104-r4

Init system
OpenRC

To Reproduce

  1. Set up a Gentoo installation with musl libc and llvm
  2. echo "sys-kernel/installkernel dracut uki" > /etc/portage/package.use/installkernel
  3. emerge sys-kernel/installkernel && emerge sys-kernel/gentoo-kernel-bin

Additional context

Run objdump -h /usr/lib/systemd/boot/efi/linuxx64.efi.stub manually(https://github.com/dracut-ng/dracut-ng/blob/ffeb32b2d2caecc2111bfd93b6919dc4f09d3c2d/dracut.sh#L2508C14-L2508C15), it seems there are LMA, file offset and align column missing:

LLVM:

flysoft / # objdump -h /usr/lib/systemd/boot/efi/linuxx64.efi.stub

/usr/lib/systemd/boot/efi/linuxx64.efi.stub:    file format coff-x86-64

Sections:
Idx Name          Size     VMA              Type
  0 .text         0000edb6 000000014df91000 TEXT
  1 .rodata       0000292c 000000014dfa0000 DATA
  2 .data         000002d8 000000014dfa3000 DATA
  3 .sdmagic      00000027 000000014dfa4000 DATA
  4 .sbat         000000cb 000000014dfa5000 DATA
  5 .reloc        00000080 000000014dfa6000 DATA

GNU binutils:

/usr/lib/systemd/boot/efi/linuxx64.efi.stub:     file format pei-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         0000edb6  000000014df91000  000000014df91000  00000400  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       0000292c  000000014dfa0000  000000014dfa0000  0000f200  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data         000002d8  000000014dfa3000  000000014dfa3000  00011c00  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  3 .sdmagic      00000027  000000014dfa4000  000000014dfa4000  00012000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .sbat         000000cb  000000014dfa5000  000000014dfa5000  00012200  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .reloc        00000080  000000014dfa6000  000000014dfa6000  00012400  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

With dracut 100, nvme kernel drivers are not included in hostonly mode

Describe the bug
When building the initrd with dracut --hostonly --no-hostonly-cmdline nvme kernel drivers are not included even though there are nvme devices installed and used in the system. Downgrading to 059 includes these drivers.

Distribution used
Arch Linux

Dracut version
100

Init system
systemd

Please let me know if I can provide any further information.

undesired log messages

2024-04-08T21:53:47.2628692Z dracut[I]: *** Including module: net-lib ***
2024-04-08T21:53:47.2816632Z dracut[I]: *** Including module: drm ***
2024-04-08T21:53:47.5988159Z dracut[I]: *** Including module: plymouth ***
2024-04-08T21:53:48.1605172Z find: '/usr/share/X11/locale/am_ET.UTF-8': No such file or directory
2024-04-08T21:53:48.1615524Z find: '/usr/share/X11/locale/cs_CZ.UTF-8': No such file or directory
2024-04-08T21:53:48.1627410Z find: '/usr/share/X11/locale/el_GR.UTF-8': No such file or directory
2024-04-08T21:53:48.1751232Z find: '/usr/share/X11/locale/fi_FI.UTF-8': No such file or directory
2024-04-08T21:53:48.1762436Z find: '/usr/share/X11/locale/ja_JP.UTF-8': No such file or directory
2024-04-08T21:53:48.1773763Z find: '/usr/share/X11/locale/km_KH.UTF-8': No such file or directory
2024-04-08T21:53:48.1785602Z find: '/usr/share/X11/locale/ko_KR.UTF-8': No such file or directory
2024-04-08T21:53:48.1797110Z find: '/usr/share/X11/locale/pt_BR.UTF-8': No such file or directory
2024-04-08T21:53:48.1808538Z find: '/usr/share/X11/locale/pt_PT.UTF-8': No such file or directory
2024-04-08T21:53:48.1819548Z find: '/usr/share/X11/locale/ru_RU.UTF-8': No such file or directory
2024-04-08T21:53:48.1832225Z find: '/usr/share/X11/locale/sr_RS.UTF-8': No such file or directory
2024-04-08T21:53:48.1843496Z find: '/usr/share/X11/locale/th_TH.UTF-8': No such file or directory
2024-04-08T21:53:48.1854665Z find: '/usr/share/X11/locale/zh_CN.UTF-8': No such file or directory
2024-04-08T21:53:48.1866524Z find: '/usr/share/X11/locale/zh_HK.UTF-8': No such file or directory
2024-04-08T21:53:48.1878256Z find: '/usr/share/X11/locale/zh_TW.UTF-8': No such file or directory
2024-04-08T21:53:48.8090304Z dracut[I]: *** Including module: btrfs ***
2024-04-08T21:53:48.8691684Z dracut[I]: *** Including module: crypt ***
2024-04-08T21:53:49.0376470Z dracut[I]: *** Including module: dm ***
2024-04-08T21:53:49.2033856Z dracut[I]: *** Including module: dmraid ***
2024-04-08T21:53:49.2565349Z dracut[I]: *** Including module: kernel-modules ***
2024-04-08T21:53:49.2765705Z dracut[I]: *** Including module: kernel-modules-extra ***
2024-04-08T21:53:49.2899208Z dracut[I]: *** Including module: kernel-network-modules ***
2024-04-08T21:53:49.9435920Z dracut[I]: *** Including module: lvm ***
2024-04-08T21:53:50.0196883Z dracut[I]: *** Including module: mdraid ***
2024-04-08T21:53:50.1798314Z dracut[I]: *** Including module: multipath ***
2024-04-08T21:53:50.4275932Z dracut[I]: *** Including module: nvdimm ***

Seen on Arch CI. Plymouth module. Not a regression.

drop-in dracut modules

Pick up dracut modules from /etc/dracut.conf.d/modules.d/ in addition to /usr/lib/dracut/modules.d/

Warning running with -H: grep: warning: stray \ before x

Describe the bug
When using hostonly dracut triggers grep warning:

...
dracut[I]: *** Including module: rootfs-block ***
grep: warning: stray \ before x
dracut[I]: *** Including module: terminfo ***
...

Distribution used
Archlinux

Dracut version
Released 060 and git head as of commit 7f35206

Init system
systemd

To Reproduce
dracut -H ...

Expected behavior
No warnings from greo

Additional context
bash: 5.2.026
grep: 3.11

hostonly mode prevents mdadm being installed

Describe the bug
Without hostonly mdadm is included when --mdadmconf is specified (or put in dracut config file).
Same command adding -H, and mdadm is no longer installed.

Specifically:

Case 1)

dracut --zstd --early-microcode  --kver '6.9.0-rc2-custom-1' --force /tmp/x.img
...
dracut[I]: *** Including module: mdraid ***
...
lsinitrd /tmp/x.img |grep mdadm
-rw-r--r--   1 root     root         2349 Mar  3 12:01 etc/mdadm.conf
-rwxr-xr-x   1 root     root       628552 Mar  3 12:01 usr/bin/mdadm
-rw-r--r--   1 root     root          494 Mar  3 12:01 usr/lib/systemd/system/[email protected]
-rw-r--r--   1 root     root          237 Mar  3 12:01 usr/lib/systemd/system/[email protected]
-rw-r--r--   1 root     root          179 Mar  3 12:01 usr/lib/systemd/system/[email protected]

case 2)
Does not include mdraid module and subsequently mdadm is ignored.

dracut -H --zstd --early-microcode  --kver '6.9.0-rc2-custom-1' --force /tmp/x.img
lsinitrd /tmp/x.img |grep mdadm
(nothing)

Distribution used
Archlinux

Dracut version
Bopth released "060" and "revert-56-_2231" branch have same problem.

Init system
systemd

To Reproduce
See above

Hostonly error : git HEAD : Could not open '/var/tmp/dracut.xxx/initramfs/lib/dracut/hostonly-files' for writing

Describe the bug
060 does not exhibit this - but running dracut -H now complains multiple times with lines:

dracut-install: Could not open '/var/tmp/dracut.B2dxjA/initramfs/lib/dracut/hostonly-files' for writing.

Distribution used
Archlinux

Dracut version
Which dracut version was this behaviour seen in?
git HEAD as of commit commit 5d2bda4

Init system
systemd

To Reproduce
dracut -H

Expected behavior
Should be able to open() above.

Additional context
May be related to commit 3439d13

[nfs] pick uid/gid for rpc from tmpfiles.d/rpcbind.conf

The nfs dracut module guesses the name for uid/gid. There are better way to guess - e.g. read the rpcbind.conf (D /run/rpcbind entry) if it exists.

The module is not consistently guessing, sometimes it uses rpcuser, sometimes rpc. As an example rpc user does not seem to exists on Gentoo.

It is ok to have default guesses if tmpfiles.d/rpcbind.conf is not available.

Debian carries a patch: https://sources.debian.org/src/dracut/059-4/debian/patches/rpc-user/

Support bcachefs as well as bcachefs encrypted root unlocking

Bcachefs is a new fs built into the kernel since 6.7 it will also be included in fedora 40 when it releases.
It supports filesystem level encryption which has its benefits over normal luks. More information can be found at https://bcachefs.org/Encryption/.

Just like how "crypt" module opens luks encrypted root via cryptsetup. It would be great if dracut could unlock bcachefs encrypted partitions a similar way. In userspace the way to unlock a bcachefs encrypted drive and mount it is:

bcachefs unlock /dev/sdaX
# type password
mount /dev/sdaX /mountpoint

Again there is more of an explanation on their website https://bcachefs.org/Encryption/ as well as resources such as https://wiki.archlinux.org/title/Bcachefs, https://wiki.gentoo.org/wiki/Bcachefs.

[RFC] Automatically generate deps for dlopen() deps?

Many of systemd's library dependencies were turned into dlopen() based dependencies in the recent years/months. For classic initrd generators these are hard to automatically handle, because they are not mentioned in the ELF header.

In this issue over on the systemd project I am proposing to change something about it: systemd/systemd#32234

I was wondering if there's any interest in this from the dracut/dracut-ng camp?

The concept is generic, but systemd would be the first provider of this information I guess. You can extract this kind of "weak" dlopen library dependencies via readelf -p .note.uapi.dlopen or an equivalent command from ELF.

Anyway, would love your input on that issue, in case you are interested in this.

RFC: Extend dracut with the ability to add a package to the generated initramfs

Dracut has the capability (config file and command line options) to add kernel modules and dracut modules and individual files to the generated initramfs.

This issue is to discuss extending dracut with the (optional) capability of using the existing underlying package manager and properly install packages into the generated initramfs .

The syntax could be:

--add-package LIST

With recent efforts in package minimization in distributions this approach looks more and more promising. One of the goals is to allow replacing simple dracut modules (single module-setup.sh file without any additional file/script) with its corresponding native distribution package.

As upstream packages evolve, repeating the dependency resolution in dracut seems unnecessary. As systemd is constantly evolving and adding new functionality related to early boot: decryption of disks, access to secrets, new configuration mechanisms, state checks and boot counting. Repeating the dependency resolution in dracut is a constant drain of maintainer time.

One long term goal is to allow a user or distro to configure dracut whereby instead of using systemd dracut modules, dracut would just rely on systemd system package and its dependencies. One motivation here is to allow dracut to focus on scripts that dracut has instead of chasing systemd changes.

Replacing the dracut initqueue with systemd job queue is orthogonal for this issue and should not be discussed here.

While I use systemd as an example, obviously this feature is useful even if you do not use systemd.

Note that this capability will be optional - do not need it than do not use it.

Other initramfs generators (notably mkosi-initrd and mkinitfs) has similar features.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.