99base/init, 98usrmount: mount /usr if found in /sysroot/etc/fstab

We cannot boot correctly without /usr, because of
http://www.freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
so, we mount /usr readonly.
This commit is contained in:
Harald Hoyer 2011-11-07 08:52:03 +01:00
parent b0692d0311
commit 470ee2d214
4 changed files with 52 additions and 24 deletions

View File

@ -257,6 +257,7 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/dracut/modules.d/98integrity
%{_datadir}/dracut/modules.d/98selinux
%{_datadir}/dracut/modules.d/98syslog
%{_datadir}/dracut/modules.d/98usrmount
%{_datadir}/dracut/modules.d/99base
%{_datadir}/dracut/modules.d/99fs-lib
%{_datadir}/dracut/modules.d/99shutdown

View File

@ -0,0 +1,16 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
return 0
}
depends() {
return 0
}
install() {
inst_hook pre-pivot 50 "$moddir/mount-usr.sh"
}

View File

@ -0,0 +1,32 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type info >/dev/null 2>&1 || . /lib/dracut-lib.sh
type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh
mount_usr()
{
local _dev _mp _fs _opts _rest _usr_found _ret
# check, if we have to mount the /usr filesystem
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
# we have to mount /usr
fsck_single "$_dev" "$_fs" "$_opts"
_ret=$?
echo $_ret >/run/initramfs/usr-fsck
if [ $_ret -ne 255 ]; then
info "Mounting /usr"
mount "$NEWROOT/usr" 2>&1 | vinfo
fi
fi
}
mount_usr

View File

@ -314,33 +314,12 @@ done
getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
# by the time we get here, the root filesystem should be mounted.
# Try to find init and mount /usr, if needed to access init.
unset __usr_found
# By the time we get here, the root filesystem should be mounted.
# Try to find init.
for i in "$(getarg real_init=)" "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
[ -n "$i" ] || continue
__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")
__p=$(readlink -f "${NEWROOT}/${i}")
if [ -x "$__p" ]; then
INIT="$i"
break