From 40ee8c1814510bc95ab0d5dffd17af28c14df182 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 22 Jul 2011 11:21:24 +0200 Subject: [PATCH] 99base/init: try to mount /usr, if init lives on /usr --- TODO | 1 + modules.d/99base/init | 27 +++++++++++++++++++++++++-- modules.d/99base/module-setup.sh | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 7dcf8dc..e5abef0 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,7 @@ INITRAMFS TODO - The hard-coded list of udev rules that we care about is kind of lame. - automatic kexec fallback - panic fallback +- fsck for $NEWROOT/usr GENERATOR TODO diff --git a/modules.d/99base/init b/modules.d/99base/init index 5975b25..1fac580 100755 --- a/modules.d/99base/init +++ b/modules.d/99base/init @@ -306,10 +306,33 @@ getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot source_hook pre-pivot # by the time we get here, the root filesystem should be mounted. -# Try to find init. +# Try to find init and mount /usr, if needed to access init. +unset __usr_found for i in "$(getarg real_init=)" "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do [ -n "$i" ] || continue - if ! [ -d "$NEWROOT$i" ] && [ -L "$NEWROOT$i" -o -x "$NEWROOT$i" ]; then + + __p=$(readlink -m "$NEWROOT$i") + if [ -n "$__p" ] \ + && [ "x$__usr_found" = "x" ] \ + && [ ! -x "$__p" ] \ + && strstr "$__p" "$NEWROOT/usr" \ + ; then + # we have to mount /usr + while read dev mp fs opts rest; do + if [ "$mp" = "/usr" ]; then + echo "$dev $NEWROOT$mp $fs ${opts},ro $rest" + __usr_found="1" + break + fi + done < "$NEWROOT/etc/fstab" >> /etc/fstab + if [ "x$__usr_found" != "x" ]; then + info "Mounting /usr" + mount "$NEWROOT/usr" 2>&1 | vinfo + fi + fi + + __p=$(readlink -f "$NEWROOT$i") + if [ -x "$__p" ]; then INIT="$i" break fi diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh index 20454f9..40c94f6 100755 --- a/modules.d/99base/module-setup.sh +++ b/modules.d/99base/module-setup.sh @@ -14,7 +14,7 @@ depends() { install() { local _d dracut_install mount mknod mkdir modprobe pidof sleep chroot \ - sed ls flock cp mv dmesg rm ln rmmod mkfifo umount + sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink dracut_install -o less if [ ! -e "${initdir}/bin/sh" ]; then dracut_install bash