Skip to contentSkip to conversation

Enhancements and bug fixes for --mount

PATCH Applied Cong Wang 2 participants 14 messages Dec 20, 2011 – Jan 13, 2012 7 messages not in the archive

lore
Share & tools
lore

Cong Wang

author
#0 lore raw

cover Enhancements and bug fixes for --mount

From: Cong Wang <[email protected]>

This patchset is based on "usrmove" branch, contains several bug fixes and some enhancements for the new option '--mount'.

With these patches applied, kdump works well with dracut (the lvm case).

All patches are available at:

git://github.com/congwang/dracut.git #kdump

Cong Wang (6):
Add mount points even not in hostonly mode
Check module dependencies of mount points
Fix get_maj_min() to follow symlink
Pass device name instead of major:minor in for_each_host_dev_fs()
nfs: fix regex patterns in check()
lvm: pass the correct rd.lvm.lv parameter

 dracut                                  |   83 ++++++++++++++++---------------
 dracut-functions                        |   81 ++++++++++++++++++++++++++---
 modules.d/00bootchart/module-setup.sh   |    1 +
 modules.d/10i18n/module-setup.sh        |    1 +
 modules.d/10rpmversion/module-setup.sh  |    1 +
 modules.d/50plymouth/module-setup.sh    |    1 +
 modules.d/90btrfs/module-setup.sh       |    2 +-
 modules.d/90crypt/module-setup.sh       |    2 +-
 modules.d/90dmraid/module-setup.sh      |    2 +-
 modules.d/90lvm/module-setup.sh         |   17 ++----
 modules.d/90mdraid/module-setup.sh      |    2 +-
 modules.d/95fcoe/module-setup.sh        |    2 +-
 modules.d/95nfs/module-setup.sh         |    8 ++--
 modules.d/97biosdevname/module-setup.sh |    1 +
 modules.d/98usrmount/module-setup.sh    |    1 +
 15 files changed, 135 insertions(+), 70 deletions(-)
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

author
#2 lore raw

PATCH 1/6 Allow to add mount points even not in hostonly mode

From: Cong Wang <[email protected]>

Don't force --mount only working in hostonly mode, let users decide. With this patch, people can still combine -H --mount '...' if they want to use it in hostonly mode.

---
 dracut |   77 +++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 38 insertions(+), 39 deletions(-)
dracut +38 -39
index 8449fc1..3a7c4fe 100755
@@ -525,40 +525,25 @@ trap 'exit 1;' SIGINT
 # Need to be able to have non-root users read stuff (rpcbind etc)
 chmod 755 "$initdir"
 
+for line in "${fstab_lines[@]}"; do
+    set -- $line
+    #dev mp fs fsopts
+    dev="$(get_maj_min $1)"
+    push host_devs "${dev:-$1}"
+    push host_fs_types "$dev|$3"
+done
+
+for f in $add_fstab; do
+    [ -e $f ] || continue
+    while read dev rest; do
+        push host_devs $dev
+    done < $f
+done
+
 if [[ $hostonly ]]; then
     # in hostonly mode, determine all devices, which have to be accessed
     # and examine them for filesystem types
 
-    unset host_fs_types
-
-    _get_fs_type() (
-        [[ $1 ]] || return
-        if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
-            echo "$1|$ID_FS_TYPE"
-            return 1
-        fi
-        if fstype=$(find_dev_fstype $1); then
-            echo "$1|$fstype"
-            return 1
-        fi
-        return 1
-    )
-
-    for line in "${fstab_lines[@]}"; do
-        set -- $line
-        #dev mp fs fsopts
-        dev="$(get_maj_min $1)"
-        push host_devs "${dev:-$1}"
-        push host_fs_types "$dev|$3"
-    done
-
-    for f in $add_fstab; do
-        [ -e $f ] || continue
-        while read dev rest; do
-            push host_devs $dev
-        done < $f
-    done
-
     push host_mp \
         "/" \
         "/etc" \
@@ -573,17 +558,31 @@ if [[ $hostonly ]]; then
         mountpoint "$mp" >/dev/null 2>&1 || continue
         push host_devs $(find_block_device "$mp")
     done
-    for dev in "${host_devs[@]}"; do
-        unset fs_type
-        for fstype in $(_get_fs_type $dev) \
-            $(check_block_and_slaves _get_fs_type $dev); do
-            if ! strstr " ${host_fs_types[*]} " " $fstype ";then
-                push host_fs_types "$fstype"
-            fi
-        done
-    done
 fi
 
+_get_fs_type() (
+    [[ $1 ]] || return
+    if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
+        echo "$1|$ID_FS_TYPE"
+        return 1
+    fi
+    if fstype=$(find_dev_fstype $1); then
+        echo "$1|$fstype"
+        return 1
+    fi
+    return 1
+)
+
+for dev in "${host_devs[@]}"; do
+    unset fs_type
+    for fstype in $(_get_fs_type $dev) \
+        $(check_block_and_slaves _get_fs_type $dev); do
+        if ! strstr " ${host_fs_types[*]} " " $fstype ";then
+            push host_fs_types "$fstype"
+        fi
+    done
+done
+
 export initdir dracutbasedir dracutmodules drivers \
     fw_dir drivers_dir debug no_kernel kernel_only \
     add_drivers mdadmconf lvmconf filesystems \
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-2-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Applied
#4 lore raw

Re: [PATCH 1/6] Allow to add mount points even not in hostonly mode

Quoted 10 lines · Cong Wang

From: Cong Wang <[email protected]>

Don't force --mount only working in hostonly mode, let users decide. With this patch, people can still combine -H --mount '...' if they want to use it in hostonly mode.

---
 dracut |   77 +++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 38 insertions(+), 39 deletions(-)

applied

author
#6 lore raw

PATCH 2/6 Check module dependencies of mount points

In reply to a message not in the archive

From: Cong Wang <[email protected]>

Like -H, we need to poll every module to check if it is needed to mount a specific device in '--mount'.

---
 dracut                                  |    5 ++-
 dracut-functions                        |   68 +++++++++++++++++++++++++++++-
 modules.d/00bootchart/module-setup.sh   |    1 +
 modules.d/10i18n/module-setup.sh        |    1 +
 modules.d/10rpmversion/module-setup.sh  |    1 +
 modules.d/50plymouth/module-setup.sh    |    1 +
 modules.d/90btrfs/module-setup.sh       |    2 +-
 modules.d/90crypt/module-setup.sh       |    2 +-
 modules.d/90dmraid/module-setup.sh      |    2 +-
 modules.d/90lvm/module-setup.sh         |    2 +-
 modules.d/90mdraid/module-setup.sh      |    2 +-
 modules.d/95fcoe/module-setup.sh        |    2 +-
 modules.d/95nfs/module-setup.sh         |    2 +-
 modules.d/97biosdevname/module-setup.sh |    1 +
 modules.d/98usrmount/module-setup.sh    |    1 +
 15 files changed, 82 insertions(+), 11 deletions(-)
dracut +4 -1
index 3a7c4fe..452067d 100755
@@ -633,9 +633,12 @@ else
     done
 fi
 
+mods_to_load=""
 # check all our modules to see if they should be sourced.
 # This builds a list of modules that we will install next.
-check_module_dir
+for_each_module_dir check_module
+for_each_module_dir check_mount
+
 modules_loaded=" "
 # source our modules.
 for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
dracut-functions +65 -3

85 lines not on this page · raw message

modules.d/00bootchart/module-setup.sh +1 -0
index bf71b14..17dd137 100755
@@ -3,6 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
+    [[ "$mount_needs" ]] && return 1
     [ -x /sbin/bootchartd ] || return 1
     return 255
 }
modules.d/10i18n/module-setup.sh +1 -0
index 6248607..f389d14 100755
@@ -3,6 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
+    [[ "$mount_needs" ]] && return 1
     return 0
 }
 
modules.d/10rpmversion/module-setup.sh +1 -0
index 676775f..4c021ad 100755
@@ -3,6 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
+    [[ "$mount_needs" ]] && return 1
     [ -f /etc/redhat-release ]
 }
 
modules.d/50plymouth/module-setup.sh +1 -0
index 338371f..0b65ee0 100755
@@ -3,6 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
+    [[ "$mount_needs" ]] && return 1
     [[ -x /sbin/plymouthd && -x /bin/plymouth && -x /usr/sbin/plymouth-set-default-theme ]]
 }
 
modules.d/90btrfs/module-setup.sh +1 -1
index f89713f..53ba3a2 100755
@@ -11,7 +11,7 @@ check() {
     . $dracutfunctions
     [[ $debug ]] && set -x
 
-    [[ $hostonly ]] && {
+    [[ $hostonly ]] || [[ $mount_needs ]] && {
         local _found
         for fs in $host_fs_types; do
             [[ "$fs" = "|btrfs" ]] && _found="1"
modules.d/90crypt/module-setup.sh +1 -1
index 42c6b48..a92c187 100755
@@ -23,7 +23,7 @@ check() {
         echo " rd.luks.uuid=${ID_FS_UUID} " >> "${initdir}/etc/cmdline.d/90crypt.conf"
     }
 
-    [[ $hostonly ]] && {
+    [[ $hostonly ]] || [[ $mount_needs ]] && {
         [[ -d "${initdir}/etc/cmdline.d" ]] || mkdir -p "${initdir}/etc/cmdline.d"
         for_each_host_dev_fs check_crypt
         [ -f "${initdir}/etc/cmdline.d/90crypt.conf" ] || return 1
modules.d/90dmraid/module-setup.sh +1 -1
index 9de6c63..19f2ce6 100755
@@ -38,7 +38,7 @@ check() {
         echo " rd.dm.uuid=${DM_NAME} " >> "${initdir}/etc/cmdline.d/90dmraid.conf"
     }
 
-    [[ $hostonly ]] && {
+    [[ $hostonly ]] || [[ $mount_needs ]] && {
         [[ -d "${initdir}/etc/cmdline.d" ]] || mkdir -p "${initdir}/etc/cmdline.d"
         for_each_host_dev_fs check_dmraid
         [ -f "${initdir}/etc/cmdline.d/90dmraid.conf" ] || return 1
modules.d/90lvm/module-setup.sh +1 -1
index 87751cb..c910f13 100755
@@ -23,7 +23,7 @@ check() {
         echo " rd.lvm.lv=${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
     }
 
-    [[ $hostonly ]] && {
+    [[ $hostonly ]] || [[ $mount_needs ]] && {
         [[ -d "${initdir}/etc/cmdline.d" ]] || mkdir -p "${initdir}/etc/cmdline.d"
         for_each_host_dev_fs check_lvm
         [ -f "${initdir}/etc/cmdline.d/90lvm.conf" ] || return 1
modules.d/90mdraid/module-setup.sh +1 -1
index 05e0127..8c3e2bb 100755
@@ -38,7 +38,7 @@ check() {
         echo " rd.md.uuid=${MD_UUID} " >> "${initdir}/etc/cmdline.d/90mdraid.conf"
     }
 
-    [[ $hostonly ]] && {
+    [[ $hostonly ]] || [[ $mount_needs ]] && {
         [[ -d "${initdir}/etc/cmdline.d" ]] || mkdir -p "${initdir}/etc/cmdline.d"
         for_each_host_dev_fs check_mdraid
         [[ -f "${initdir}/etc/cmdline.d/90mdraid.conf" ]] || return 1
modules.d/95fcoe/module-setup.sh +1 -1
index b4cee97..e66798b 100755
@@ -6,7 +6,7 @@ check() {
     # FIXME
     # If hostonly was requested, fail the check until we have some way of
     # knowing we are booting from FCoE
-    [[ $hostonly ]] && return 1
+    [[ $hostonly ]] || [[ $mount_needs ]] && return 1
 
     return 0
 }
modules.d/95nfs/module-setup.sh +1 -1
index bb3b793..641d917 100755
@@ -7,7 +7,7 @@ check() {
     type -P rpcbind >/dev/null || type -P portmap >/dev/null || return 1
     type -P rpc.statd mount.nfs mount.nfs4 umount >/dev/null || return 1
 
-    [[ $hostonly ]] && {
+    [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in ${host_fs_types[@]}; do
             strstr "$fs" "|nfs"  && return 0
             strstr "$fs" "|nfs3" && return 0
modules.d/97biosdevname/module-setup.sh +1 -0
index 834831f..4d492a9 100755
@@ -3,6 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
+    [[ "$mount_needs" ]] && return 1
     type -P biosdevname >/dev/null || return 1
     return 0
 }
modules.d/98usrmount/module-setup.sh +1 -0
index 8f7be10..5844383 100755
@@ -3,6 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 check() {
+    [[ $mount_needs ]] && return 1
     return 0
 }
 
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-3-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

author
#9 lore raw

PATCH 3/6 Fix get_maj_min() to follow symlink

In reply to a message not in the archive

From: Cong Wang <[email protected]>

Otherwise get_maj_min /dev/mapper/vg_cr0-lv_home will return 0:0.

---
 dracut-functions |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
dracut-functions +1 -1
index 54b1c30..618e884 100755
@@ -180,7 +180,7 @@ get_fs_uuid() (
 
 get_maj_min() {
     local _dev
-    _dev=$(stat -c '$((0x%T)):$((0x%t))' "$1" 2>/dev/null)
+    _dev=$(stat -L -c '$((0x%T)):$((0x%t))' "$1" 2>/dev/null)
     _dev=$(eval "echo $_dev")
     echo $_dev
 }
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-4-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Applied
#11 lore raw

Re: [PATCH 3/6] Fix get_maj_min() to follow symlink

Quoted 9 lines · Cong Wang

From: Cong Wang <[email protected]>

Otherwise get_maj_min /dev/mapper/vg_cr0-lv_home will return 0:0.

---
 dracut-functions |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

applied

author
#12 lore raw

PATCH 4/6 Pass device name instead of major:minor in for_each_host_dev_fs()

In reply to a message not in the archive

From: Cong Wang <[email protected]>

---
 dracut           |   11 +++++------
 dracut-functions |   11 ++++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)
dracut +5 -6
index 452067d..85228b8 100755
@@ -528,9 +528,8 @@ chmod 755 "$initdir"
 for line in "${fstab_lines[@]}"; do
     set -- $line
     #dev mp fs fsopts
-    dev="$(get_maj_min $1)"
-    push host_devs "${dev:-$1}"
-    push host_fs_types "$dev|$3"
+    push host_devs "$1"
+    push host_fs_types "$1|$3"
 done
 
 for f in $add_fstab; do
@@ -556,13 +555,13 @@ if [[ $hostonly ]]; then
 
     for mp in "${host_mp[@]}"; do
         mountpoint "$mp" >/dev/null 2>&1 || continue
-        push host_devs $(find_block_device "$mp")
+        push host_devs $(readlink -f "/dev/block/$(find_block_device "$mp")")
     done
 fi
 
 _get_fs_type() (
     [[ $1 ]] || return
-    if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
+    if [[ -b $1 ]] && get_fs_env $1; then
         echo "$1|$ID_FS_TYPE"
         return 1
     fi
@@ -576,7 +575,7 @@ _get_fs_type() (
 for dev in "${host_devs[@]}"; do
     unset fs_type
     for fstype in $(_get_fs_type $dev) \
-        $(check_block_and_slaves _get_fs_type $dev); do
+        $(check_block_and_slaves _get_fs_type $(get_maj_min $dev)); do
         if ! strstr " ${host_fs_types[*]} " " $fstype ";then
             push host_fs_types "$fstype"
         fi
dracut-functions +6 -5
index 618e884..3dd72e9 100755
@@ -247,16 +247,17 @@ find_root_block_device() { find_block_device /; }
 for_each_host_dev_fs()
 {
     local _func="$1"
+    local _dev
+    local _fs
     for f in ${host_fs_types[@]}; do
         OLDIFS="$IFS"
         IFS="|"
         set -- $f
         IFS="$OLDIFS"
-        dev=$1
-        [[ -b /dev/block/$dev ]] && dev="/dev/block/$dev"
-        [[ -b $dev ]] || continue
-        fs="$2"
-        $_func $dev $fs
+        _dev="$1"
+        [[ -b "$_dev" ]] || continue
+        _fs="$2"
+        $_func $_dev $_fs
     done
 }
 
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-5-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Applied
#14 lore raw

Re: [PATCH 4/6] Pass device name instead of major:minor in for_each_host_dev_fs()

Quoted 8 lines · Cong Wang

From: Cong Wang <[email protected]>

---
 dracut           |   11 +++++------
 dracut-functions |   11 ++++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

applied

author
#15 lore raw

PATCH 5/6 nfs: fix regex patterns in check()

In reply to a message not in the archive

From: Cong Wang <[email protected]>

---
 modules.d/95nfs/module-setup.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
modules.d/95nfs/module-setup.sh +3 -3
index 641d917..6778f28 100755
@@ -9,9 +9,9 @@ check() {
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in ${host_fs_types[@]}; do
-            strstr "$fs" "|nfs"  && return 0
-            strstr "$fs" "|nfs3" && return 0
-            strstr "$fs" "|nfs4" && return 0
+            strstr "$fs" "\|nfs"  && return 0
+            strstr "$fs" "\|nfs3" && return 0
+            strstr "$fs" "\|nfs4" && return 0
         done
         return 255
     }
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-6-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

author
#18 lore raw

PATCH 6/6 lvm: pass the correct rd.lvm.lv parameter

In reply to a message not in the archive

From: Cong Wang <[email protected]>

rd.lvm.lv accepts ${DM_VG_NAME}/${DM_LV_NAME}, not ${DM_LV_NAME}.

---
 modules.d/90lvm/module-setup.sh |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
modules.d/90lvm/module-setup.sh +5 -10
index c910f13..01bfa8a 100755
@@ -11,16 +11,11 @@ check() {
     [[ $debug ]] && set -x
 
     check_lvm() {
-        local dev=$1
-        DM_LV_NAME=$(udevadm info --query=property --name=$dev \
-            | while read line; do
-                [[ ${line#DM_LV_NAME} = $line ]] && continue
-                eval "$line"
-                echo $DM_LV_NAME
-                break
-                done)
-        [[ ${DM_LV_NAME} ]] || continue
-        echo " rd.lvm.lv=${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
+        unset DM_VG_NAME
+        unset DM_LV_NAME
+        eval $(udevadm info --query=property --name=$1|egrep '(DM_VG_NAME|DM_LV_NAME)=')
+        [[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return
+        echo " rd.lvm.lv=${DM_VG_NAME}/${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
     }
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
Signature · 1 line
1.7.7.4

A message that is not in the archive (sent off-list or not yet received): 1324361401-6908-7-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org