linuxrc /usr mounting

Dogfooding of the /usr mount code with the matching OpenRC change to
make the mounts RW revealed some bugs and gotchas in our prior code, now
fixed and verified to work.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
cleanup-cruft
Robin H. Johnson 13 years ago
parent 5eeadc8d26
commit 1077359d86

@ -5,6 +5,12 @@
# Distributed under the GPL v2
# $Id$
09 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> defaults/initrd.scripts,
defaults/linuxrc:
Dogfooding of the /usr mount code with the matching OpenRC change to make the
mounts RW revealed some bugs and gotchas in our prior code, now fixed and
verified to work.
06 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> arch/alpha/config.sh,
arch/arm/config.sh, arch/ia64/config.sh, arch/mips/config.sh,
arch/parisc/config.sh, arch/parisc64/config.sh, arch/ppc/config.sh,

@ -1199,7 +1199,7 @@ get_mounts_list()
' ${NEW_ROOT}/etc/initramfs.mounts
}
get_mount_options()
get_mount_fstype()
{
awk -v fs="$1" '
/^[[:blank:]]*#/ { next }
@ -1207,6 +1207,14 @@ get_mount_options()
' ${NEW_ROOT}/etc/fstab
}
get_mount_options()
{
awk -v fs="$1" '
/^[[:blank:]]*#/ { next }
$2 == fs { print $4 }
' ${NEW_ROOT}/etc/fstab
}
get_mount_device()
{
awk -v fs="$1" '
@ -1215,3 +1223,12 @@ get_mount_device()
' ${NEW_ROOT}/etc/fstab
}
# If the kernel is handed a mount option is does not recognize, it WILL fail to
# mount. util-linux handles auto/noauto, but busybox passes it straight to the kernel
# which then rejects the mount.
# To make like a little easier, busybox mount does not care about leading,
# trailing or duplicate commas.
strip_mount_options()
{
sed -r 's/(,|^)(no)?auto(,|$)/,/g'
}

@ -531,7 +531,7 @@ do
# there is no isofs filesystem to worry about
break
else
good_msg "Mounting root..."
good_msg "Mounting $REAL_ROOT as root..."
if [ "${ROOTFSTYPE}" = 'zfs' ]
then
@ -780,9 +780,14 @@ for fs in $fslist; do
# In this case, it's probably part of the filesystem
# and not a mountpoint
[ -z "$dev" ] && continue
opts="ro,$(get_mount_options \"$fs\")"
if ! mount -o ${opts} $dev ${NEW_ROOT}${fs}; then
rescue_shell "Unable to mount $dev on $fs"
fstype=$(get_mount_fstype $fs)
# ro must be trailing, and the options will always contain at least 'defaults'
opts="$(get_mount_options $fs | strip_mount_options),ro"
mnt=${NEW_ROOT}${fs}
cmd="mount -t $fstype -o $opts $dev $mnt"
good_msg "Mounting $dev as ${fs}: $cmd"
if ! $cmd; then
bad_msg "Unable to mount $dev for $fs"
fi
done

Loading…
Cancel
Save