localmount: only skip unmounting /usr if it was premounted

Add a test when localmount is started to determine if /usr is mounted
from inside an initramfs for Linux systems. If it is not, we can unmount it when
localmount stops.

On *bsd systems, we always unmount /usr if it is separate.

Reported-by: ryao@gentoo.org
This commit is contained in:
William Hubbs 2012-11-29 10:19:20 -06:00
parent 0a72893c8b
commit 5cce37837b

View File

@ -22,6 +22,9 @@ start()
if [ "$RC_UNAME" = Linux ]; then
no_netdev="-O no_netdev"
if [ mountinfo -q /usr ]; then
touch $rc_svcdir/usr_premounted
fi
fi
ebegin "Mounting local filesystems"
mount -at "$types" $no_netdev
@ -48,7 +51,10 @@ stop()
done
if [ "$RC_UNAME" = Linux ]; then
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*|/usr"
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
if [ -e $rc_svcdir/usr_premounted ]; then
no_umounts_r="$no_umounts_r|/usr"
fi
fi
no_umounts_r="^($no_umounts_r)$"