RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1760760 - RFE: Provide a way to amend the host_devs table transparently
Summary: RFE: Provide a way to amend the host_devs table transparently
Keywords:
Status: CLOSED INSUFFICIENT_DATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dracut
Version: 8.1
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: 8.0
Assignee: Lukáš Nykrýn
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-11 09:23 UTC by Renaud Métrich
Modified: 2022-05-04 05:41 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-04 05:41:24 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Renaud Métrich 2019-10-11 09:23:38 UTC
Description of problem:

Early when dracut starts, around lines 1200, the host_devs table is constructed based on various stuff:
- presence of some directories, /, /usr, /boot, ...
- swaps
- x-initrd.mount in /etc/fstab

This table is hence "statically" built and cannot be amended by some dracut module, since modules are not read at that time yet.

Specifically for Clevis, I would need to amend the table to include basically all file systems hosted on LUKS devices which have not the _netdev flag.

This is needed because when using Clevis, "root" file systems must be decrypted early in the initramfs. "root" file systems are standard /, /usr but also all other directories such as /var, /var/log, /tmp or /opt.
Indeed, /var and /tmp for example need to be mounted early after switching root, or else system services won't start.
At that time, there is potentially no network anymore and the clevis-luks-askpath service is not running.

The current workaround for this limitation is to use "x-initrd.mount" in /etc/fstab but this is suboptimal (there is no need to mount the filesystems in the initramfs at all) and also requires system administrator intervention to adjust /etc/fstab, whereas without Clevis, there was no need for that at all.
Additionally, the administrator, unless "hostonly_cmdline=yes" is specified in a drop-in in /etc/dracut.conf.d, needs to add all the rd.luks.uuid and rd.lvm.lv entries manually to kernel's command line.

Comment 1 Renaud Métrich 2019-10-15 14:38:22 UTC
The solution for Clevis may be to include all file systems found in /etc/fstab not having _netdev option or not known to be remote, but I don't know if this could impact other modules behaviour at all.

Comment 2 Renaud Métrich 2019-10-16 13:01:36 UTC
The following code snippet automatically adds all local filesystems to "host_devs" array:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
--- /usr/bin/dracut.orig	2019-10-16 13:25:24.807000000 +0200
+++ /usr/bin/dracut	2019-10-16 13:59:35.012000000 +0200
@@ -245,6 +245,19 @@
 EOF
 }
 
+_network_filesystems=( "afs" "cifs" "smbfs" "sshfs" "ncpfs" "ncp" "nfs" "nfs4"
+			"gfs" "gfs2" "glusterfs" "pvfs2" "ovfs2" "lustre" )
+
+# Returns 0 is the filesystem is a known network filesystem
+is_network_filesystem() {
+	local fstype="${1##fuse.}"
+	if [[ " ${_network_filesystems[@]} " =~ " $fstype " ]]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
 # Fills up host_devs stack variable and makes sure there are no duplicates
 push_host_devs() {
     local _dev
@@ -1256,6 +1269,26 @@
             _dev=$(expand_persistent_dev "$_d")
             _dev="$(readlink -f "$_dev")"
             [[ -b $_dev ]] || continue
+
+            push_host_devs "$_dev"
+            if [[ "$_t" == btrfs ]]; then
+                for i in $(btrfs_devs "$_m"); do
+                    push_host_devs "$i"
+                done
+            fi
+        done < /etc/fstab
+    fi
+
+    # collect all non-network file systems entries from /etc/fstab
+    if [[ -f /etc/fstab ]]; then
+        while read _d _m _t _o _r || [ -n "$_d" ]; do
+            [[ "$_d" == \#* ]] && continue
+            [[ $_d ]] || continue
+            [[ "$_o" != *_netdev* ]] || continue
+	    is_network_filesystem $_t && continue
+            _dev=$(expand_persistent_dev "$_d")
+            _dev="$(readlink -f "$_dev")"
+            [[ -b $_dev ]] || continue
 
             push_host_devs "$_dev"
             if [[ "$_t" == btrfs ]]; then
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This introduces a new _network_filesystems array which contains a static list of known network filesystems, which of course must be kept in sync with systemd's list.

Of course, such code is suboptimal when *not* using Clevis, since this will integrate unlocking of the devices in the initramfs, even when a passphrase is used.
Still, it's better than mounting the file systems early.

Comment 6 David Tardon 2022-02-28 15:13:58 UTC
I'm not sure I understand the problem... The host_devs variable is accessible to modules and they should be able to add more stuff to it in install(). The real work of setting up the devices to be waited for during boot happens in 99base:install(), which should run after install() of pretty much every other module... Or am I missing something?

Comment 7 Renaud Métrich 2022-05-04 05:41:24 UTC
Hi David,

Honestly this RFE is so old that I don't remember why I wanted this.
I guess it is for clevis dracut module to automatically include all LUKS local file systems for decryption in the initramfs, in replacement to having to configure with x-initrd.mount.
Let's close this for now until I have some time to experiment again to see what are the issues I wanted to solve.


Note You need to log in before you can comment on or make changes to this bug.