* In stage 1, fsck the root device before mounting it. If automatic
repair fails, drop the user into an emergency shell. svn path=/nixu/trunk/; revision=7117
This commit is contained in:
parent
f0695e9fcd
commit
bb0a2b0d78
@ -40,10 +40,16 @@ rec {
|
||||
# need.
|
||||
extraUtils = pkgs.stdenv.mkDerivation {
|
||||
name = "extra-utils";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
"source $stdenv/setup; ensureDir $out/bin; cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin; nuke-refs $out/bin/*";
|
||||
builder = builtins.toFile "builder.sh" "
|
||||
source $stdenv/setup
|
||||
ensureDir $out/bin
|
||||
cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin
|
||||
cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $out/bin
|
||||
nuke-refs $out/bin/*
|
||||
";
|
||||
buildInputs = [pkgs.nukeReferences];
|
||||
inherit (pkgsStatic) utillinux;
|
||||
e2fsprogs = pkgs.e2fsprogsDiet;
|
||||
};
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ if test -n "@autoDetectRootDevice@"; then
|
||||
|
||||
echo " in $devName..."
|
||||
|
||||
if mount -o ro -t iso9660 $devName /mnt/root; then
|
||||
if mount -n -o ro -t iso9660 $devName /mnt/root; then
|
||||
if test -e "/mnt/root/@rootLabel@"; then
|
||||
found=1
|
||||
break
|
||||
@ -100,7 +100,31 @@ if test -n "@autoDetectRootDevice@"; then
|
||||
else
|
||||
|
||||
# Hard-coded root device.
|
||||
mount -o ro "@rootDevice@" /mnt/root
|
||||
rootDevice="@rootDevice@"
|
||||
|
||||
# Check the root device.
|
||||
fsck -C -a "$rootDevice"
|
||||
fsckResult=$?
|
||||
|
||||
if test $(($fsckResult | 2)) = $fsckResult; then
|
||||
echo "fsck finished, rebooting..."
|
||||
sleep 3
|
||||
# reboot -f -d !!! don't have reboot yet
|
||||
fail
|
||||
fi
|
||||
|
||||
if test $(($fsckResult | 4)) = $fsckResult; then
|
||||
echo "$rootDevice has unrepaired errors, please fix them manually."
|
||||
fail
|
||||
fi
|
||||
|
||||
if test $fsckResult -ge 8; then
|
||||
echo "fsck on $rootDevice failed."
|
||||
fail
|
||||
fi
|
||||
|
||||
# Mount read-writable.
|
||||
mount -n -o rw "$rootDevice" /mnt/root || fail
|
||||
|
||||
fi
|
||||
|
||||
|
@ -21,14 +21,6 @@ done
|
||||
|
||||
# Mount special file systems.
|
||||
|
||||
if test -z "@readOnlyRoot@"; then
|
||||
#rootDev=$(grep "/dev/.* / " /proc/mounts | sed 's/^\([^ ]*\) .*/\1/')
|
||||
if ! mount -t dontcare -o remount,rw /dontcare /; then
|
||||
echo "Couldn't remount / read-writable, starting emergency shell!"
|
||||
exec @shell@
|
||||
fi
|
||||
fi
|
||||
|
||||
needWritableDir() {
|
||||
if test -n "@readOnlyRoot@"; then
|
||||
mount -t tmpfs -o "mode=$2" none $1 $3
|
||||
|
Loading…
Reference in New Issue
Block a user