From 70cb8a686f710b237c6f7c7524b47d2649f6751a Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 15 Dec 2011 14:36:37 +0100 Subject: [PATCH] dracut: add --add-fstab and --mount option --add-fstab [FILE] Add file to the initramfs fstab --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" Mount device [DEV] on mountpoint [MP] with filesystem [FSTYPE] and options [FSOPTS] in the initramfs --- dracut | 40 ++++++++++++++++++++++++++++++++++++ modules.d/95fstab-sys/mount-sys.sh | 4 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/dracut b/dracut index 46694f8..8449fc1 100755 --- a/dracut +++ b/dracut @@ -85,6 +85,10 @@ Creates initial ramdisk images for preloading modules -H, --hostonly Host-Only mode: Install only what is needed for booting the local host instead of a generic host. --fstab Use /etc/fstab to determine the root device. + --add-fstab [FILE] Add file to the initramfs fstab + --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" + Mount device [DEV] on mountpoint [MP] with filesystem + [FSTYPE] and options [FSOPTS] in the initramfs -i, --include [SOURCE] [TARGET] Include the files in the SOURCE directory into the Target directory in the final initramfs. @@ -207,6 +211,8 @@ while (($# > 0)); do -I|--install) push_arg install_items_l "$@" || shift;; --fwdir) push_arg fw_dir_l "$@" || shift;; --fscks) push_arg fscks_l "$@" || shift;; + --add-fstab) push_arg add_fstab_l "$@" || shift;; + --mount) push_arg fstab_lines "$@" || shift;; --nofscks) nofscks_l="yes";; -k|--kmoddir) read_arg drivers_dir_l "$@" || shift;; -c|--conf) read_arg conffile "$@" || shift;; @@ -332,6 +338,18 @@ if (( ${#fscks_l[@]} )); then done fi +if (( ${#add_fstab_l[@]} )); then + while pop add_fstab_l val; do + add_fstab+=" $val " + done +fi + +if (( ${#fstab_lines_l[@]} )); then + while pop fstab_lines_l val; do + push fstab_lines $val + done +fi + if (( ${#install_items_l[@]} )); then while pop install_items_l val; do push install_items $val @@ -526,6 +544,21 @@ if [[ $hostonly ]]; then 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" \ @@ -668,6 +701,13 @@ while pop install_items items; do done unset item +while pop fstab_lines line; do + echo "$line 0 0" >> "${initdir}/etc/fstab" +done + +for f in $add_fstab; do + cat $f >> "${initdir}/etc/fstab" +done if [[ $kernel_only != yes ]]; then # make sure that library links are correct and up to date diff --git a/modules.d/95fstab-sys/mount-sys.sh b/modules.d/95fstab-sys/mount-sys.sh index f44351d..a8fbd50 100755 --- a/modules.d/95fstab-sys/mount-sys.sh +++ b/modules.d/95fstab-sys/mount-sys.sh @@ -25,6 +25,6 @@ fstab_mount() { return 0 } -for r in $NEWROOT /; do - fstab_mount "$r/etc/fstab.sys" && break +for r in $NEWROOT/etc/fstab.sys /etc/fstab; do + fstab_mount $r && break done