* Added an option `boot.initrd.availableKernelModules' that specifies
modules that should be added to the initrd, but should only be loaded on demand (e.g. by the kernel or by udev). This is especially useful in the installation CD, where we now only load the modules needed by the hardware. * Enable automatic modprobing by udev in the initrd. svn path=/nixos/trunk/; revision=18975
This commit is contained in:
parent
e8372257a1
commit
6c9059e717
|
@ -114,7 +114,7 @@ in
|
|||
|
||||
# The initrd has to contain any module that might be necessary for
|
||||
# mounting the CD/DVD.
|
||||
boot.initrd.kernelModules =
|
||||
boot.initrd.availableKernelModules =
|
||||
[ # SATA/PATA support.
|
||||
"ahci"
|
||||
|
||||
|
@ -160,9 +160,11 @@ in
|
|||
"vfat"
|
||||
|
||||
# And of course we need to be able to mount the CD.
|
||||
"iso9660" "loop" "squashfs"
|
||||
"iso9660"
|
||||
];
|
||||
|
||||
boot.initrd.kernelModules = [ "loop" ];
|
||||
|
||||
# nixos-install will do a pull from this channel to speed up the
|
||||
# installation.
|
||||
installer.nixpkgsURL = http://nixos.org/releases/nixpkgs/channels/nixpkgs-unstable;
|
||||
|
|
|
@ -128,7 +128,7 @@ in
|
|||
(! config.boot.kernelPackages.kernel.features ? aufs)
|
||||
config.boot.kernelPackages.aufs;
|
||||
|
||||
boot.initrd.kernelModules = ["aufs" "squashfs"];
|
||||
boot.initrd.availableKernelModules = [ "aufs" "squashfs" ];
|
||||
|
||||
# Tell stage 1 of the boot to mount a tmpfs on top of the CD using
|
||||
# AUFS. !!! It would be nicer to make the stage 1 init pluggable
|
||||
|
|
|
@ -61,13 +61,65 @@ let kernel = config.boot.kernelPackages.kernel; in
|
|||
The set of kernel modules to be loaded in the second stage of
|
||||
the boot process. Note that modules that are needed to
|
||||
mount the root file system should be added to
|
||||
<option>boot.initrd.availableKernelModules</option> or
|
||||
<option>boot.initrd.kernelModules</option>.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.availableKernelModules = mkOption {
|
||||
default = [];
|
||||
example = [ "sata_nv" "ext3" ];
|
||||
description = ''
|
||||
The set of kernel modules in the initial ramdisk used during the
|
||||
boot process. This set must include all modules necessary for
|
||||
mounting the root device. That is, it should include modules
|
||||
for the physical device (e.g., SCSI drivers) and for the file
|
||||
system (e.g., ext3). The set specified here is automatically
|
||||
closed under the module dependency relation, i.e., all
|
||||
dependencies of the modules list here are included
|
||||
automatically. The modules listed here are available in the
|
||||
initrd, but are only loaded on demand (e.g., the ext3 module is
|
||||
loaded automatically when an ext3 filesystem is mounted, and
|
||||
modules for PCI devices are loaded when they match the PCI ID
|
||||
of a device in your system). To force a module to be loaded,
|
||||
include it in <option>boot.initrd.kernelModules</option>.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.kernelModules = mkOption {
|
||||
default = [
|
||||
# Note: most of these (especially the SATA/PATA modules)
|
||||
];
|
||||
description = "List of modules that are always loaded by the initrd.";
|
||||
};
|
||||
|
||||
system.modulesTree = mkOption {
|
||||
internal = true;
|
||||
default = [];
|
||||
description = ''
|
||||
Tree of kernel modules. This includes the kernel, plus modules
|
||||
built outside of the kernel. Combine these into a single tree of
|
||||
symlinks because modprobe only supports one directory.
|
||||
'';
|
||||
merge = mergeListOption;
|
||||
# Convert the list of path to only one path.
|
||||
apply = pkgs.aggregateModules;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = {
|
||||
|
||||
system.build = { inherit kernel; };
|
||||
|
||||
system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
|
||||
|
||||
boot.kernelModules = [ "loop" ];
|
||||
|
||||
boot.initrd.availableKernelModules =
|
||||
[ # Note: most of these (especially the SATA/PATA modules)
|
||||
# shouldn't be included by default since nixos-hardware-scan
|
||||
# detects them, but I'm keeping them for now for backwards
|
||||
# compatibility.
|
||||
|
@ -100,50 +152,17 @@ let kernel = config.boot.kernelPackages.kernel; in
|
|||
"ohci_hcd"
|
||||
"usbhid"
|
||||
|
||||
# LVM.
|
||||
"dm_mod"
|
||||
|
||||
# All-mod-config case:
|
||||
# Unix domain sockets (needed by udev).
|
||||
"unix"
|
||||
|
||||
# Misc. stuff.
|
||||
"i8042" "pcips2" "serio" "atkbd" "xtkbd"
|
||||
];
|
||||
description = ''
|
||||
The set of kernel modules in the initial ramdisk used during the
|
||||
boot process. This set must include all modules necessary for
|
||||
mounting the root device. That is, it should include modules
|
||||
for the physical device (e.g., SCSI drivers) and for the file
|
||||
system (e.g., ext3). The set specified here is automatically
|
||||
closed under the module dependency relation, i.e., all
|
||||
dependencies of the modules list here are included
|
||||
automatically.
|
||||
'';
|
||||
};
|
||||
|
||||
system.modulesTree = mkOption {
|
||||
internal = true;
|
||||
default = [];
|
||||
description = ''
|
||||
Tree of kernel modules. This includes the kernel, plus modules
|
||||
built outside of the kernel. Combine these into a single tree of
|
||||
symlinks because modprobe only supports one directory.
|
||||
'';
|
||||
merge = mergeListOption;
|
||||
# Convert the list of path to only one path.
|
||||
apply = pkgs.aggregateModules;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = {
|
||||
|
||||
system.build = { inherit kernel; };
|
||||
|
||||
system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
|
||||
|
||||
boot.kernelModules = [ "loop" ];
|
||||
boot.initrd.kernelModules =
|
||||
[ # For LVM.
|
||||
"dm_mod"
|
||||
];
|
||||
|
||||
# The Linux kernel >= 2.6.27 provides firmware.
|
||||
hardware.firmware = [ "${kernel}/lib/firmware" ];
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
targetRoot=/mnt-root
|
||||
|
||||
export LD_LIBRARY_PATH=@extraUtils@/lib
|
||||
export PATH=@extraUtils@/bin:@klibc@/bin
|
||||
|
||||
|
||||
fail() {
|
||||
|
@ -43,16 +44,6 @@ echo "[1;32m<<< NixOS Stage 1 >>>[0m"
|
|||
echo
|
||||
|
||||
|
||||
# Set the PATH.
|
||||
export PATH=/empty
|
||||
for i in @path@; do
|
||||
PATH=$PATH:$i/bin
|
||||
if test -e $i/sbin; then
|
||||
PATH=$PATH:$i/sbin
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Mount special file systems.
|
||||
mkdir -p /etc # to shut up mount
|
||||
echo -n > /etc/fstab # idem
|
||||
|
@ -87,10 +78,11 @@ for o in $(cat /proc/cmdline); do
|
|||
done
|
||||
|
||||
|
||||
# Load some kernel modules.
|
||||
for i in $(cat @modulesClosure@/insmod-list); do
|
||||
# Load the required kernel modules.
|
||||
echo @extraUtils@/bin/modprobe > /proc/sys/kernel/modprobe
|
||||
for i in @kernelModules@; do
|
||||
echo "loading module $(basename $i)..."
|
||||
insmod $i || true
|
||||
modprobe $i || true
|
||||
done
|
||||
|
||||
|
||||
|
@ -113,6 +105,7 @@ fi
|
|||
|
||||
|
||||
# Create device nodes in /dev.
|
||||
echo "running udev..."
|
||||
export UDEV_CONFIG_FILE=@udevConf@
|
||||
mkdir -p /dev/.udev # !!! bug in udev?
|
||||
udevd --daemon
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# the modules necessary to mount the root file system, then calls the
|
||||
# init in the root file system to start the second boot stage.
|
||||
|
||||
{pkgs, config, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
|
@ -30,15 +30,6 @@ let
|
|||
";
|
||||
};
|
||||
|
||||
boot.initrd.allowMissing = mkOption {
|
||||
default = true;
|
||||
description = ''
|
||||
Allow some initrd components to be missing. Useful for
|
||||
custom kernel that are changed too often to track needed
|
||||
kernelModules.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.lvm = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
|
@ -82,6 +73,7 @@ let
|
|||
};
|
||||
|
||||
boot.initrd.extraUtilsCommands = mkOption {
|
||||
internal = true;
|
||||
default = "";
|
||||
merge = pkgs.lib.mergeStringOption;
|
||||
description = ''
|
||||
|
@ -110,9 +102,9 @@ let
|
|||
|
||||
# Determine the set of modules that we need to mount the root FS.
|
||||
modulesClosure = pkgs.makeModulesClosure {
|
||||
rootModules = config.boot.initrd.kernelModules;
|
||||
rootModules = config.boot.initrd.availableKernelModules ++ config.boot.initrd.kernelModules;
|
||||
kernel = modulesTree;
|
||||
allowMissing = config.boot.initrd.allowMissing;
|
||||
allowMissing = true;
|
||||
};
|
||||
|
||||
|
||||
|
@ -125,7 +117,7 @@ let
|
|||
{ buildInputs = [pkgs.nukeReferences];
|
||||
devicemapper = if config.boot.initrd.lvm then pkgs.devicemapper else null;
|
||||
lvm2 = if config.boot.initrd.lvm then pkgs.lvm2 else null;
|
||||
allowedReferences = ["out"]; # prevent accidents like glibc being included in the initrd
|
||||
allowedReferences = [ "out" modulesClosure ]; # prevent accidents like glibc being included in the initrd
|
||||
doublePatchelf = (pkgs.stdenv.system == "armv5tel-linux");
|
||||
}
|
||||
''
|
||||
|
@ -179,8 +171,8 @@ let
|
|||
cp ${pkgs.bash}/bin/bash $out/bin
|
||||
ln -s bash $out/bin/sh
|
||||
|
||||
# Copy insmod.
|
||||
cp ${pkgs.module_init_tools}/sbin/insmod $out/bin
|
||||
# Copy modprobe.
|
||||
cp ${pkgs.module_init_tools}/sbin/modprobe $out/bin/modprobe.real
|
||||
|
||||
${config.boot.initrd.extraUtilsCommands}
|
||||
|
||||
|
@ -191,12 +183,20 @@ let
|
|||
if ! test -L $i; then
|
||||
echo "patching $i..."
|
||||
patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib $i || true
|
||||
if [ "$doublePatchelf" -eq 1 ]; then
|
||||
if [ -n "$doublePatchelf" ]; then
|
||||
patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib $i || true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Make the modprobe wrapper that sets $MODULE_DIR.
|
||||
cat > $out/bin/modprobe <<EOF
|
||||
#! $out/bin/bash
|
||||
export MODULE_DIR=${modulesClosure}/lib/modules
|
||||
exec $out/bin/modprobe.real "\$@"
|
||||
EOF
|
||||
chmod u+x $out/bin/modprobe
|
||||
|
||||
# Make sure that the patchelf'ed binaries still work.
|
||||
echo "testing patched programs..."
|
||||
$out/bin/bash --version
|
||||
|
@ -215,7 +215,7 @@ let
|
|||
$out/bin/reiserfsck -V
|
||||
$out/bin/mdadm --version
|
||||
$out/bin/basename --version
|
||||
$out/bin/insmod --version
|
||||
$out/bin/modprobe --version
|
||||
''; # */
|
||||
|
||||
|
||||
|
@ -234,6 +234,7 @@ let
|
|||
|
||||
cp ${pkgs.udev}/libexec/rules.d/60-cdrom_id.rules $out/
|
||||
cp ${pkgs.udev}/libexec/rules.d/60-persistent-storage.rules $out/
|
||||
cp ${pkgs.udev}/libexec/rules.d/80-drivers.rules $out/
|
||||
|
||||
for i in $out/*.rules; do
|
||||
substituteInPlace $i \
|
||||
|
@ -243,7 +244,8 @@ let
|
|||
--replace path_id ${extraUtils}/bin/path_id \
|
||||
--replace vol_id ${extraUtils}/bin/vol_id \
|
||||
--replace cdrom_id ${extraUtils}/bin/cdrom_id \
|
||||
--replace /sbin/blkid ${extraUtils}/bin/blkid
|
||||
--replace /sbin/blkid ${extraUtils}/bin/blkid \
|
||||
--replace /sbin/modprobe ${extraUtils}/bin/modprobe
|
||||
done
|
||||
|
||||
# Remove rule preventing creation of a by-label symlink
|
||||
|
@ -272,12 +274,14 @@ let
|
|||
|
||||
isExecutable = true;
|
||||
|
||||
inherit modulesClosure udevConf extraUtils;
|
||||
klibc = pkgs.klibcShrunk;
|
||||
|
||||
inherit udevConf extraUtils;
|
||||
|
||||
inherit (config.boot) isLiveCD resumeDevice;
|
||||
|
||||
inherit (config.boot.initrd) checkJournalingFS
|
||||
postDeviceCommands postMountCommands;
|
||||
postDeviceCommands postMountCommands kernelModules;
|
||||
|
||||
# !!! copy&pasted from upstart-jobs/filesystems.nix.
|
||||
mountPoints =
|
||||
|
@ -287,14 +291,6 @@ let
|
|||
devices = map (fs: if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fileSystems;
|
||||
fsTypes = map (fs: fs.fsType) fileSystems;
|
||||
optionss = map (fs: fs.options) fileSystems;
|
||||
|
||||
path = [
|
||||
# `extraUtils' comes first because it overrides the `mount'
|
||||
# command provided by klibc (which isn't capable of
|
||||
# auto-detecting FS types).
|
||||
extraUtils
|
||||
pkgs.klibcShrunk
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ in
|
|||
# All the modules the initrd needs to mount the host filesystem via
|
||||
# CIFS. Also use paravirtualised network and block devices for
|
||||
# performance.
|
||||
boot.initrd.kernelModules =
|
||||
boot.initrd.availableKernelModules =
|
||||
[ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8" ];
|
||||
|
||||
boot.initrd.extraUtilsCommands =
|
||||
|
|
Loading…
Reference in a new issue