Blame SOURCES/0507-dracut.sh-introduce-no-hostonly-default-device-argum.patch

1755ca
From 0e842c4b8b2796b9ae606da81ec92839af1cc27e Mon Sep 17 00:00:00 2001
1755ca
From: Xunlei Pang <xlpang@redhat.com>
1755ca
Date: Wed, 16 Aug 2017 13:55:17 +0800
1755ca
Subject: [PATCH] dracut.sh: introduce "--no-hostonly-default-device" argument
1755ca
1755ca
Kdump doesn't need default host devices like root, swap, fstab, etc,
1755ca
we only care about the dump target which can be added via "--mount"
1755ca
or "--add-device". We met several issues that kdump kernel failed
1755ca
due to one of those host devices added by dracut, additionally, the
1755ca
needless devices(e.g. LVM) consume some appreciable amount of memory
1755ca
which is more likely to cause OOM under memory-limited kdump.
1755ca
1755ca
So this patch introduced "--no-hostonly-default-device" to avoid
1755ca
adding those default devices as host_devs.
1755ca
1755ca
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
1755ca
1755ca
Cherry-picked from: 37f2fe55d
1755ca
Resolves: #1483838
1755ca
---
1755ca
 dracut.8.asc | 4 ++++
1755ca
 dracut.sh    | 9 ++++++++-
1755ca
 2 files changed, 12 insertions(+), 1 deletion(-)
1755ca
1755ca
diff --git a/dracut.8.asc b/dracut.8.asc
1755ca
index 8fd863b9..e097e769 100644
1755ca
--- a/dracut.8.asc
1755ca
+++ b/dracut.8.asc
1755ca
@@ -306,6 +306,10 @@ provide a valid _/etc/fstab_.
1755ca
 **--no-hostonly-cmdline**:
1755ca
     Do not store kernel command line arguments needed in the initramfs
1755ca
 
1755ca
+**--no-hostonly-default-device**:
1755ca
+    Do not generate implicit host devices like root, swap, fstab, etc.
1755ca
+    Use "--mount" or "--add-device" to explicitly add devices as needed.
1755ca
+
1755ca
 **--hostonly-i18n**:
1755ca
     Install only needed keyboard and font files according to the host configuration (default).
1755ca
 
1755ca
diff --git a/dracut.sh b/dracut.sh
1755ca
index f4e85095..0b23a838 100755
1755ca
--- a/dracut.sh
1755ca
+++ b/dracut.sh
1755ca
@@ -141,6 +141,10 @@ Creates initial ramdisk images for preloading modules
1755ca
                         in the initramfs
1755ca
   --no-hostonly-cmdline Do not store kernel command line arguments needed
1755ca
                         in the initramfs
1755ca
+  --no-hostonly-default-device
1755ca
+                        Do not generate implicit host devices like root,
1755ca
+                        swap, fstab, etc. Use "--mount" or "--add-device"
1755ca
+                        to explicitly add devices as needed.
1755ca
   --hostonly-i18n       Install only needed keyboard and font files according
1755ca
                         to the host configuration (default).
1755ca
   --no-hostonly-i18n    Install all keyboard and font files available.
1755ca
@@ -357,6 +361,7 @@ rearrange_params()
1755ca
         --long no-host-only \
1755ca
         --long hostonly-cmdline \
1755ca
         --long no-hostonly-cmdline \
1755ca
+        --long no-hostonly-default-device \
1755ca
         --long persistent-policy: \
1755ca
         --long fstab \
1755ca
         --long help \
1755ca
@@ -545,6 +550,8 @@ while :; do
1755ca
                        i18n_install_all_l="yes" ;;
1755ca
         --no-hostonly-cmdline)
1755ca
                        hostonly_cmdline_l="no" ;;
1755ca
+        --no-hostonly-default-device)
1755ca
+                       hostonly_default_device="no" ;;
1755ca
         --persistent-policy)
1755ca
                        persistent_policy_l="$2";       PARMS_TO_STORE+=" '$2'"; shift;;
1755ca
         --fstab)       use_fstab_l="yes" ;;
1755ca
@@ -1039,7 +1046,7 @@ if (( ${#add_device_l[@]} )); then
1755ca
     done
1755ca
 fi
1755ca
 
1755ca
-if [[ $hostonly ]]; then
1755ca
+if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
1755ca
     # in hostonly mode, determine all devices, which have to be accessed
1755ca
     # and examine them for filesystem types
1755ca