]> git.ipfire.org Git - thirdparty/dracut.git/blobdiff - dracut.sh
Add a dracut option --device to bring up a device in initramfs
[thirdparty/dracut.git] / dracut.sh
index dc2c3004d1de12dca71a1de62a742543b52b31a6..a6f619322feea97b974e3f4b94fba8d5559a3649 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -133,6 +133,7 @@ Creates initial ramdisk images for preloading modules
   --mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
                         Mount device [DEV] on mountpoint [MP] with filesystem
                         [FSTYPE] and options [FSOPTS] in the initramfs
+  --device "[DEV]"      Bring up [DEV] in initramfs
   -i, --include [SOURCE] [TARGET]
                         Include the files in the SOURCE directory into the
                          Target directory in the final initramfs.
@@ -261,6 +262,7 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \
     --long fscks: \
     --long add-fstab: \
     --long mount: \
+    --long device: \
     --long nofscks: \
     --long ro-mnt \
     --long kmoddir: \
@@ -327,6 +329,7 @@ while :; do
         --fscks)       push fscks_l              "$2"; shift;;
         --add-fstab)   push add_fstab_l          "$2"; shift;;
         --mount)       push fstab_lines          "$2"; shift;;
+        --device)      push host_devs            "$2"; shift;;
         --nofscks)     nofscks_l="yes";;
         --ro-mnt)      ro_mnt_l="yes";;
         -k|--kmoddir)  drivers_dir_l="$2"; shift;;
@@ -903,6 +906,22 @@ done
 
 dinfo "*** Including modules done ***"
 
+get_persistent_dev() {
+    local i _tmp
+    local _dev=${1##*/}
+
+    for i in /dev/disk/by-id/*; do
+        _tmp=$(readlink $i)
+        [ "${_tmp##*/}" = "$_dev" ] && echo $i && return
+    done
+}
+
+## save host_devs which we need bring up
+for _dev in ${host_devs[@]}; do
+    _pdev=$(get_persistent_dev $_dev)
+    [ -n "$_pdev" ] && echo $_pdev >> $initdir/etc/host_devs
+done
+
 ## final stuff that has to happen
 if [[ $no_kernel != yes ]]; then