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
master
Harald Hoyer 2011-12-15 14:36:37 +01:00
parent bb61d657c1
commit 70cb8a686f
2 changed files with 42 additions and 2 deletions

40
dracut
View File

@ -85,6 +85,10 @@ Creates initial ramdisk images for preloading modules
-H, --hostonly Host-Only mode: Install only what is needed for -H, --hostonly Host-Only mode: Install only what is needed for
booting the local host instead of a generic host. booting the local host instead of a generic host.
--fstab Use /etc/fstab to determine the root device. --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] -i, --include [SOURCE] [TARGET]
Include the files in the SOURCE directory into the Include the files in the SOURCE directory into the
Target directory in the final initramfs. Target directory in the final initramfs.
@ -207,6 +211,8 @@ while (($# > 0)); do
-I|--install) push_arg install_items_l "$@" || shift;; -I|--install) push_arg install_items_l "$@" || shift;;
--fwdir) push_arg fw_dir_l "$@" || shift;; --fwdir) push_arg fw_dir_l "$@" || shift;;
--fscks) push_arg fscks_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";; --nofscks) nofscks_l="yes";;
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;; -k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
-c|--conf) read_arg conffile "$@" || shift;; -c|--conf) read_arg conffile "$@" || shift;;
@ -332,6 +338,18 @@ if (( ${#fscks_l[@]} )); then
done done
fi 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 if (( ${#install_items_l[@]} )); then
while pop install_items_l val; do while pop install_items_l val; do
push install_items $val push install_items $val
@ -526,6 +544,21 @@ if [[ $hostonly ]]; then
return 1 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 \ push host_mp \
"/" \ "/" \
"/etc" \ "/etc" \
@ -668,6 +701,13 @@ while pop install_items items; do
done done
unset item 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 if [[ $kernel_only != yes ]]; then
# make sure that library links are correct and up to date # make sure that library links are correct and up to date

View File

@ -25,6 +25,6 @@ fstab_mount() {
return 0 return 0
} }


for r in $NEWROOT /; do for r in $NEWROOT/etc/fstab.sys /etc/fstab; do
fstab_mount "$r/etc/fstab.sys" && break fstab_mount $r && break
done done