]> 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 46f3a5b91ea965a2e3e6f3b839692eb5443897b8..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;;
@@ -810,7 +813,7 @@ if [[ $prefix ]]; then
 fi
 
 if [[ $kernel_only != yes ]]; then
-    for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/log var/run var/lock $libdirs; do
+    for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/log $libdirs; do
         [[ -e "${initdir}${prefix}/$d" ]] && continue
         if [ -L "/$d" ]; then
             inst_symlink "/$d" "${prefix}/$d"
@@ -827,8 +830,8 @@ if [[ $kernel_only != yes ]]; then
         fi
     done
 
-    ln -sfn /run "$initdir/var/run"
-    ln -sfn /run/lock "$initdir/var/lock"
+    ln -sfn ../run "$initdir/var/run"
+    ln -sfn ../run/lock "$initdir/var/lock"
 else
     for d in lib "$libdir"; do
         [[ -e "${initdir}${prefix}/$d" ]] && continue
@@ -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