99base/init: try to mount /usr, if init lives on /usr

This commit is contained in:
Harald Hoyer 2011-07-22 11:21:24 +02:00
parent a4c235ed3a
commit 40ee8c1814
3 changed files with 27 additions and 3 deletions

1
TODO
View File

@ -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

View File

@ -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

View File

@ -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