diff --git a/boot/boot-stage-2-init.sh b/boot/boot-stage-2-init.sh
index a29b874c032..02e33b91912 100644
--- a/boot/boot-stage-2-init.sh
+++ b/boot/boot-stage-2-init.sh
@@ -59,6 +59,9 @@ for o in $(cat /proc/cmdline); do
# !!! argh, can't pass a startup event to Upstart yet.
exec @shell@
;;
+ safemode)
+ safeMode=1
+ ;;
esac
done
@@ -75,6 +78,10 @@ needWritableDir /root 0700
# Miscellaneous boot time cleanup.
rm -rf /var/run
+if test -n "$safeMode"; then
+ touch /var/run/safemode
+fi
+
# Create the minimal device nodes needed before we run udev.
mknod -m 0666 /dev/null c 1 3
diff --git a/configuration/options.nix b/configuration/options.nix
index d128f6c8e33..aaafca84e99 100644
--- a/configuration/options.nix
+++ b/configuration/options.nix
@@ -84,6 +84,33 @@
}
+ {
+ name = ["boot" "hardwareScan"];
+ default = true;
+ description = "
+ Whether to try to load kernel modules for all detected hardware.
+ Usually this does a good job of providing you with the modules
+ you need, but sometimes it can crash the system or cause other
+ nasty effects. If the hardware scan is turned on, it can be
+ disabled at boot time by adding the safemode
+ parameter to the kernel command line.
+ ";
+ }
+
+
+ {
+ name = ["boot" "kernelModules"];
+ default = [];
+ description = "
+ The set of kernel modules to be loaded in the second stage of
+ the boot process. That is, these modules are not included in
+ the initial ramdisk, so they'd better not be required for
+ mounting the root file system. Add them to
+