From 9cc7ceec1e9b4028d1a72bf51f9ea488d7ca11ac Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Wed, 7 Sep 2022 15:17:06 +0200 Subject: [PATCH] fix(dracut): allow to set persistent policy based on /dev/mapper device names Currently, dracut only allows to configure the persistent policy to address disks and partitions using any directory name found in /dev/disk, but there is no defined way to set the default policy based on /dev/mapper device names. So, for example, if the persistent policy is set by the distribution in any configuration file, the user cannot set the default if he wants to. The current workaround is to set persistent_policy="" in a conf file or pass --persistent-policy " " (white space) as an argument. This patch aims to establish a specific value for this case. --- dracut.sh | 12 ++++++++++-- man/dracut.8.asc | 4 ++-- man/dracut.conf.5.asc | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dracut.sh b/dracut.sh index a6d9256604..bbb346970e 100755 --- a/dracut.sh +++ b/dracut.sh @@ -198,8 +198,9 @@ Creates initial ramdisk images for preloading modules necessary network drivers. --persistent-policy [POLICY] Use [POLICY] to address disks and partitions. - POLICY can be any directory name found in /dev/disk. - E.g. "by-uuid", "by-label" + POLICY can be any directory name found in /dev/disk + (e.g. "by-uuid", "by-label"), or "mapper" to use + /dev/mapper device names (default). --fstab Use /etc/fstab to determine the root device. --add-fstab [FILE] Add file to the initramfs fstab. --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" @@ -1301,6 +1302,13 @@ else exit 1 fi +if [[ $persistent_policy == "mapper" ]]; then + unset persistent_policy +elif [[ -n $persistent_policy && ! -d "/dev/disk/${persistent_policy}" ]]; then + dwarn "Invalid persistent policy, your system does not have a /dev/disk/${persistent_policy} directory." + unset persistent_policy +fi + if [[ $enhanced_cpio == "yes" ]]; then enhanced_cpio="$dracutbasedir/dracut-cpio" if [[ -x $enhanced_cpio ]]; then diff --git a/man/dracut.8.asc b/man/dracut.8.asc index d9a4b8daf5..5c2b147ab2 100644 --- a/man/dracut.8.asc +++ b/man/dracut.8.asc @@ -391,8 +391,8 @@ Default: **--persistent-policy** __:: Use __ to address disks and partitions. - __ can be any directory name found in /dev/disk. - E.g. "by-uuid", "by-label" + __ can be any directory name found in /dev/disk (e.g. "by-uuid", + "by-label"), or "mapper" to use /dev/mapper device names (default). **--fstab**:: Use _/etc/fstab_ instead of _/proc/self/mountinfo_. diff --git a/man/dracut.conf.5.asc b/man/dracut.conf.5.asc index 45192fa0c4..dbeaf4d879 100644 --- a/man/dracut.conf.5.asc +++ b/man/dracut.conf.5.asc @@ -142,8 +142,8 @@ Configuration files must have the extension .conf; other extensions are ignored. *persistent_policy=*"____":: Use __ to address disks and partitions. - __ can be any directory name found in /dev/disk. - E.g. "by-uuid", "by-label" + __ can be any directory name found in /dev/disk (e.g. "by-uuid", + "by-label"), or "mapper" to use /dev/mapper device names (default=mapper). *tmpdir=*"____":: Specify temporary directory to use.