Author: eelco
Date: 2010-06-07 12:15:55 +0000 (Mon, 07 Jun 2010)
New Revision: 22165

You can view the changes in this commit at:
   https://svn.nixos.org/viewvc/nix?rev=22165&view=rev

Modified:
   nixos/branches/boot-order/modules/services/ttys/mingetty.nix
   nixos/branches/boot-order/modules/tasks/filesystems.nix

Log:
* If mountall fails to mount all filesystems, start an emergency shell
  to allow the user to fix or ignore the problem.


Changes:

Modified: nixos/branches/boot-order/modules/services/ttys/mingetty.nix
===================================================================
--- nixos/branches/boot-order/modules/services/ttys/mingetty.nix        
2010-06-07 12:14:47 UTC (rev 22164)
+++ nixos/branches/boot-order/modules/services/ttys/mingetty.nix        
2010-06-07 12:15:55 UTC (rev 22165)
@@ -55,7 +55,7 @@
     # 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}";
       

Modified: nixos/branches/boot-order/modules/tasks/filesystems.nix
===================================================================
--- nixos/branches/boot-order/modules/tasks/filesystems.nix     2010-06-07 
12:14:47 UTC (rev 22164)
+++ nixos/branches/boot-order/modules/tasks/filesystems.nix     2010-06-07 
12:15:55 UTC (rev 22165)
@@ -157,17 +157,67 @@
     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
+          '';
       };
 
   };

_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to