Browse Source

dracut: add --fstab, to ignore /proc/self/mountinfo

master
Harald Hoyer 15 years ago
parent
commit
7c1796860f
  1. 8
      dracut
  2. 41
      dracut-functions

8
dracut

@ -67,8 +67,9 @@ Creates initial ramdisk images for preloading modules @@ -67,8 +67,9 @@ Creates initial ramdisk images for preloading modules
directory instead of the system-wide installed in
/usr/share/dracut/modules.d.
Useful when running dracut from a git checkout.
-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.
--fstab Use /etc/fstab to determine the root device.
-i, --include [SOURCE] [TARGET]
Include the files in the SOURCE directory into the
Target directory in the final initramfs.
@ -107,6 +108,7 @@ while (($# > 0)); do @@ -107,6 +108,7 @@ while (($# > 0)); do
--confdir) confdir="$2"; shift;;
-l|--local) allowlocal="yes" ;;
-H|--hostonly) hostonly_l="yes" ;;
--fstab) use_fstab_l="yes" ;;
-i|--include) include_src="$2"; include_target="$3"; shift 2;;
-I|--install) install_items="$2"; shift;;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
@ -161,6 +163,7 @@ fi @@ -161,6 +163,7 @@ fi
[[ $fw_dir_l ]] && fw_dir=$fw_dir_l
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $hostonly_l ]] && hostonly=$hostonly_l
[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
@ -236,7 +239,8 @@ chmod 755 "$initdir" @@ -236,7 +239,8 @@ chmod 755 "$initdir"

export initdir hookdirs dracutbasedir dracutmodules drivers \
fw_dir drivers_dir debug beverbose no_kernel kernel_only \
add_drivers mdadmconf lvmconf filesystems ignore_kmodules
add_drivers mdadmconf lvmconf filesystems ignore_kmodules \
use_fstab

if [[ $kernel_only != yes ]]; then
# Create some directory structure first

41
dracut-functions

@ -94,6 +94,7 @@ print_vars() { @@ -94,6 +94,7 @@ print_vars() {
}

get_fs_env() {
[[ $1 ]] || return
eval $(udevadm info --query=env --name=$1|egrep 'ID_FS_(TYPE|UUID)=')
[[ $ID_FS_TYPE ]] && return

@ -107,6 +108,13 @@ get_fs_env() { @@ -107,6 +108,13 @@ get_fs_env() {
}

get_fs_type() (
[[ $1 ]] || return
if [[ $1 != ${1#/dev/block/nfs:} ]] \
|| [[ $1 != ${1#/dev/block/nfs3:} ]] \
|| [[ $1 != ${1#/dev/block/nfs4:} ]]; then
echo "nfs"
return
fi
get_fs_env $1 || return
echo $ID_FS_TYPE
)
@ -118,10 +126,35 @@ get_fs_uuid() ( @@ -118,10 +126,35 @@ get_fs_uuid() (

# finds the major:minor of the block device backing the root filesystem.
find_block_device() {
local majmin rootdev blkdev fs type opts misc
while read a b majmin c mpt opts d fs type opts misc; do
[[ $mpt = $1 ]] && { echo $majmin; break; } # we have a winner!
done < /proc/self/mountinfo
local x mpt majmin dev fs misc maj min
if [[ $use_fstab != yes ]]; then
while read x x majmin x mpt x x fs misc; do
[[ $fs = nfs ]] && { echo $dev; return 0;}
[[ $fs = nfs3 ]] && { echo $dev; return 0;}
[[ $fs = nfs4 ]] && { echo $dev; return 0;}
if [[ $mpt = $1 ]] && [[ ${majmin#0:} = $majmin ]]; then
echo $majmin;
return 0 # we have a winner!
fi
done < /proc/self/mountinfo
fi
# fall back to /etc/fstab
while read dev mpt fs misc; do
if [[ $mpt = $1 ]]; then
[[ $fs = nfs ]] && { echo $dev; return 0;}
[[ $fs = nfs3 ]] && { echo $dev; return 0;}
[[ $fs = nfs4 ]] && { echo $dev; return 0;}
[[ $dev != ${dev#UUID=} ]] && dev=/dev/disk/by-uuid/${dev#UUID=}
[[ $dev != ${dev#LABEL=} ]] && dev=/dev/disk/by-label/${dev#LABEL=}
[[ -b $dev ]] || return 1 # oops, not a block device.
ls -nLl "$dev" | {
read x x x x maj min x;
maj=${maj//,/};
echo $maj:$min;
} && return 0
fi
done < /etc/fstab
return 1;
}

find_root_block_device() { find_block_device /; }

Loading…
Cancel
Save