]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut): allow to set persistent policy based on /dev/mapper device names
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Wed, 7 Sep 2022 13:17:06 +0000 (15:17 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Wed, 21 Dec 2022 16:29:39 +0000 (16:29 +0000)
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
man/dracut.8.asc
man/dracut.conf.5.asc

index a6d925660484054537b50dcea312d57911b7f352..bbb346970e0e0eeb439fe6db5419f7f4f1b39b64 100755 (executable)
--- 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
index d9a4b8daf58100efc4f8e1479c6d6c9cbf39eb0a..5c2b147ab26801eb34e4c5f7ebd62aa0b32ffce7 100644 (file)
@@ -391,8 +391,8 @@ Default:
 
 **--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_ instead of _/proc/self/mountinfo_.
index 45192fa0c406d239c3e4d2588c22c83c32217ef3..dbeaf4d879374d2037191422feaf2782be4bdcdf 100644 (file)
@@ -142,8 +142,8 @@ Configuration files must have the extension .conf; other extensions are ignored.
 
 *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=mapper).
 
 *tmpdir=*"__<temporary directory>__"::
     Specify temporary directory to use.