5 # Find root device from fstab.
7 # @param string $fstab location of /etc/fstab
8 # @output string root device: /dev/hda1, /dev/sys/rootfs, etc
9 # @return false on failure
11 # Sets global variables:
17 local function="${PROGRAM:+$PROGRAM: }find_root"
19 eval $(awk '/^[\t ]*#/ {next} {if ( $2 == "/" ) {print "rootdev=\"" $1 "\"\nrootFs=\"" $3 "\""}}' $fstab)
20 if [ -z "$rootdev" ]; then
21 echo >&2 "$function: can't find real device for rootfs"
27 if [ ! -x /sbin/blkid ]; then
28 echo >&2 "$function: /sbin/blkid is missing"
32 local label=${rootdev#"LABEL="}
33 local dev=$(/sbin/blkid -t LABEL="$label" -o device)
34 if [ "$dev" -a -r "$dev" ]; then
40 if [ ! -x /sbin/blkid ]; then
41 echo >&2 "$function: /sbin/blkid is missing"
45 local uuid=${rootdev#"UUID="}
46 local dev=$(/sbin/blkid -t UUID="$uuid" -o device)
48 if [ "$dev" -a -r "$dev" ]; then
54 if [ ! -r "$rootdev" ]; then
55 echo >&2 "$function: can't find real device for $rootdev"