* Generate a wrapper around modprobe that sets MODULE_DIR. This is

important for /proc/sys/kernel/modprobe, i.e., modprobing by the
  kernel.

svn path=/nixos/trunk/; revision=8164
This commit is contained in:
Eelco Dolstra 2007-03-04 01:16:24 +00:00
parent 90f1dbe548
commit 119df37858
10 changed files with 49 additions and 32 deletions

View File

@ -36,6 +36,14 @@ mkdir -m 0755 -p $mountPoint/bin
ln -sfn @shell@ $mountPoint/bin/sh
# Allow the kernel to find our wrapped modprobe (which searches in the
# right location in the Nix store for kernel modules). We need this
# when the kernel (or some module) auto-loads a module.
# !!! maybe this should only happen at boot time, since we shouldn't
# use modules that don't match the running kernel.
echo @modprobe@/sbin/modprobe > /proc/sys/kernel/modprobe
# Various log directories.
mkdir -m 0755 -p /var/run

3
system/modprobe Normal file
View File

@ -0,0 +1,3 @@
#! @shell@
export MODULE_DIR=@kernel@/lib/modules
exec @module_init_tools@/sbin/modprobe "$@"

View File

@ -131,9 +131,18 @@ rec {
(map (mod: mod + "/lib") nssModules));
# Wrapper around modprobe to set the path to the modules.
modprobe = pkgs.substituteAll {
dir = "sbin";
src = ./modprobe;
isExecutable = true;
inherit (pkgs) kernel module_init_tools;
};
# The services (Upstart) configuration for the system.
upstartJobs = import ./upstart.nix {
inherit config pkgs nix nssModulesPath;
inherit config pkgs nix modprobe nssModulesPath;
};
@ -155,6 +164,7 @@ rec {
# The packages you want in the boot environment.
systemPathList = [
modprobe # must take precedence over module_init_tools
pkgs.bash
pkgs.bzip2
pkgs.coreutils
@ -220,7 +230,7 @@ rec {
src = ./activate-configuration.sh;
isExecutable = true;
inherit etc wrapperDir systemPath;
inherit etc wrapperDir systemPath modprobe;
inherit (pkgs) kernel;
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
hostName = config.get ["networking" "hostName"];

View File

@ -1,4 +1,4 @@
{config, pkgs, nix, nssModulesPath}:
{config, pkgs, nix, modprobe, nssModulesPath}:
let
@ -31,17 +31,19 @@ import ../upstart-jobs/gather.nix {
# Makes LVM logical volumes available.
(import ../upstart-jobs/lvm.nix {
inherit (pkgs) kernel module_init_tools lvm2;
inherit modprobe;
inherit (pkgs) lvm2;
})
# Activate software RAID arrays.
(import ../upstart-jobs/swraid.nix {
inherit (pkgs) kernel module_init_tools mdadm;
inherit modprobe;
inherit (pkgs) mdadm;
})
# Hardware scan; loads modules for PCI devices.
(import ../upstart-jobs/hardware-scan.nix {
inherit (pkgs) kernel module_init_tools;
inherit modprobe;
doHardwareScan = config.get ["boot" "hardwareScan"];
kernelModules = config.get ["boot" "kernelModules"];
})
@ -60,7 +62,8 @@ import ../upstart-jobs/gather.nix {
# Network interfaces.
(import ../upstart-jobs/network-interfaces.nix {
inherit (pkgs) nettools kernel module_init_tools wirelesstools;
inherit modprobe;
inherit (pkgs) nettools wirelesstools;
nameservers = config.get ["networking" "nameservers"];
defaultGateway = config.get ["networking" "defaultGateway"];
interfaces = config.get ["networking" "interfaces"];
@ -113,7 +116,8 @@ import ../upstart-jobs/gather.nix {
# NTP daemon.
++ optional ["services" "ntp" "enable"]
(import ../upstart-jobs/ntpd.nix {
inherit (pkgs) ntp kernel module_init_tools glibc pwdutils writeText;
inherit modprobe;
inherit (pkgs) ntp glibc pwdutils writeText;
servers = config.get ["services" "ntp" "servers"];
})
@ -136,7 +140,8 @@ import ../upstart-jobs/gather.nix {
# ALSA sound support.
++ optional ["sound" "enable"]
(import ../upstart-jobs/alsa.nix {
inherit (pkgs) kernel module_init_tools alsaUtils;
inherit modprobe;
inherit (pkgs) alsaUtils;
})
# Handles the reboot/halt events.

View File

@ -1,4 +1,4 @@
{kernel, module_init_tools, alsaUtils}:
{modprobe, alsaUtils}:
let
@ -16,9 +16,8 @@ stop on shutdown
start script
# Load some additional modules.
export MODULE_DIR=${kernel}/lib/modules/
for mod in snd_pcm_oss; do
${module_init_tools}/sbin/modprobe $mod || true
${modprobe}/sbin/modprobe $mod || true
done
# Restore the sound state.

View File

@ -1,5 +1,4 @@
# !!! Don't like it that I have to pass the kernel here.
{kernel, module_init_tools, doHardwareScan, kernelModules}:
{modprobe, doHardwareScan, kernelModules}:
{
name = "hardware-scan";
@ -8,11 +7,9 @@
start on udev
script
export MODULE_DIR=${kernel}/lib/modules/
for i in ${toString kernelModules}; do
echo \"Loading kernel module $i...\"
${module_init_tools}/sbin/modprobe $i || true
${modprobe}/sbin/modprobe $i || true
done
if test -n \"${toString doHardwareScan}\" -a ! -e /var/run/safemode; then
@ -20,7 +17,7 @@ script
# 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
${modprobe}/sbin/modprobe $(cat $i) || true
echo \"\"
done

View File

@ -1,4 +1,4 @@
{kernel, module_init_tools, lvm2}:
{modprobe, lvm2}:
{
name = "lvm";
@ -10,8 +10,7 @@ start on udev
script
# Load the device mapper.
export MODULE_DIR=${kernel}/lib/modules/
${module_init_tools}/sbin/modprobe dm_mod || true
${modprobe}/sbin/modprobe dm_mod || true
# Scan for block devices that might contain LVM physical volumes
# and volume groups.

View File

@ -1,5 +1,4 @@
# !!! Don't like it that I have to pass the kernel here.
{ nettools, kernel, module_init_tools, wirelesstools
{ nettools, modprobe, wirelesstools
, nameservers, defaultGateway, interfaces
}:
@ -22,9 +21,7 @@ start on hardware-scan
stop on shutdown
start script
export MODULE_DIR=${kernel}/lib/modules/
${module_init_tools}/sbin/modprobe af_packet
${modprobe}/sbin/modprobe af_packet
for i in $(cd /sys/class/net && ls -d *); do
echo \"Bringing up network device $i...\"

View File

@ -1,4 +1,4 @@
{ntp, kernel, module_init_tools, glibc, pwdutils, writeText, servers}:
{ntp, modprobe, glibc, pwdutils, writeText, servers}:
let
@ -37,8 +37,7 @@ start script
chown ${ntpUser} ${stateDir}
# Needed to run ntpd as an unprivileged user.
export MODULE_DIR=${kernel}/lib/modules/
${module_init_tools}/sbin/modprobe capability
${modprobe}/sbin/modprobe capability
${ntp}/bin/ntpd -q -g ${ntpFlags}

View File

@ -1,4 +1,4 @@
{kernel, module_init_tools, mdadm}:
{modprobe, mdadm}:
let
@ -16,9 +16,9 @@ start on udev
script
# Load the necessary RAID personalities.
export MODULE_DIR=${kernel}/lib/modules/
# !!! hm, doesn't the kernel load these automatically?
for mod in raid0 raid1 raid5; do
${module_init_tools}/sbin/modprobe $mod || true
${modprobe}/sbin/modprobe $mod || true
done
# Scan /proc/partitions for RAID devices.