* If mountall fails to mount all filesystems, start an emergency shell

to allow the user to fix or ignore the problem.

svn path=/nixos/branches/boot-order/; revision=22165
This commit is contained in:
Eelco Dolstra 2010-06-07 12:15:55 +00:00
parent 5702557a65
commit 6290788247
2 changed files with 54 additions and 4 deletions

View File

@ -55,7 +55,7 @@ with pkgs.lib;
# Generate a separate job for each tty.
jobs = listToAttrs (map (tty: nameValuePair tty {
startOn = "started udev and local-filesystems";
startOn = "started udev and filesystem";
exec = "${pkgs.mingetty}/sbin/mingetty --loginprog=${pkgs.shadow}/bin/login --noclear ${tty}";

View File

@ -157,17 +157,67 @@ in
jobs.mountall =
{ startOn = "started udev";
task = true;
script =
''
exec > /dev/console 2>&1
echo "mounting filesystems..."
export PATH=${config.system.sbin.mount}/bin:${makeSearchPath "sbin" ([pkgs.utillinux] ++ fsPackages)}:$PATH
${pkgs.mountall}/sbin/mountall --verbose --debug
echo DONE
${pkgs.mountall}/sbin/mountall
'';
};
# The `mount-failed' event is emitted synchronously, but we don't
# want `mountall' to wait for the emergency shell. So use this
# intermediate job to make the event asynchronous.
jobs.mountFailed =
{ name = "mount-failed";
task = true;
startOn = "mount-failed";
script =
''
start --no-wait emergency-shell \
DEVICE="$DEVICE" MOUNTPOINT="$MOUNTPOINT"
'';
};
jobs.emergencyShell =
{ name = "emergency-shell";
task = true;
stopOn = "filesystem";
extraConfig = "console owner";
task = true;
script =
''
exec < /dev/console > /dev/console 2>&1
cat <<EOF
<<< Emergency shell >>>
The filesystem \`$DEVICE' could not be mounted on \`$MOUNTPOINT'.
Please do one of the following:
- Repair the filesystem (\`fsck $DEVICE') and exit the emergency
shell to resume booting.
- Ignore any failed filesystems and continue booting by running
\`initctl emit filesystem'.
- Remove the failed filesystem from the system configuration in
/etc/nixos/configuration.nix and run \`nixos-rebuild switch'.
EOF
${pkgs.shadow}/bin/login root || false
initctl start --no-wait mountall
'';
};
};