* Option boot.doHardwareScan to disable the hardware scan. Also, if

the flag "safemode" is specified on the kernel command line, also
  disable the hardware scan.
* Option boot.kernelModules to specify a set of modules to be loaded
  in stage 2 (in addition to the initrd modules in
  boot.initrd.kernelModules).

svn path=/nixos/trunk/; revision=7466
This commit is contained in:
Eelco Dolstra 2006-12-22 23:34:42 +00:00
parent 75e1652f05
commit f25ce41c18
5 changed files with 58 additions and 10 deletions

View File

@ -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

View File

@ -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 <literal>safemode</literal>
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
<option>boot.initrd.extraKernelModules</options> if they are.
";
}
{
name = ["boot" "initrd" "kernelModules"];
default = ["ide-cd" "ide-disk" "ide-generic" "ext3"];
@ -106,7 +133,10 @@
name = ["boot" "initrd" "extraKernelModules"];
default = [];
description = "
Additional kernel modules for the initial ramdisk.
Additional kernel modules for the initial ramdisk. These are
loaded before the modules listed in
<option>boot.initrd.kernelModules</options>, so they take
precedence.
";
}

View File

@ -37,8 +37,8 @@ rec {
rootModules =
(config.get ["boot" "initrd" "kernelModules"]) ++
(config.get ["boot" "initrd" "extraKernelModules"]);
(config.get ["boot" "initrd" "extraKernelModules"]) ++
(config.get ["boot" "initrd" "kernelModules"]);
# Determine the set of modules that we need to mount the root FS.

View File

@ -29,6 +29,8 @@ import ../upstart-jobs/gather.nix {
# Hardware scan; loads modules for PCI devices.
(import ../upstart-jobs/hardware-scan.nix {
inherit (pkgs) kernel module_init_tools;
doHardwareScan = config.get ["boot" "hardwareScan"];
kernelModules = config.get ["boot" "kernelModules"];
})
# Mount file systems.

View File

@ -1,5 +1,5 @@
# !!! Don't like it that I have to pass the kernel here.
{kernel, module_init_tools}:
{kernel, module_init_tools, doHardwareScan, kernelModules}:
{
name = "hardware-scan";
@ -9,13 +9,22 @@ start on udev
script
export MODULE_DIR=${kernel}/lib/modules/
# Try to load modules for all PCI devices.
for i in /sys/bus/pci/devices/*/modalias; do
echo \"Trying to load a module for $(basename $(dirname $i))...\"
${module_init_tools}/sbin/modprobe $(cat $i) || true
echo \"\"
for i in ${toString kernelModules}; do
echo \"Loading kernel module $i...\"
${module_init_tools}/sbin/modprobe $i || true
done
if test -n \"${toString doHardwareScan}\" -a ! -e /var/run/safemode; then
# Try to load modules for all PCI devices.
for i in /sys/bus/pci/devices/*/modalias; do
echo \"Trying to load a module for $(basename $(dirname $i))...\"
${module_init_tools}/sbin/modprobe $(cat $i) || true
echo \"\"
done
fi
end script
";