[Nix-dev] Re: [Nix-commits] SVN commit: nix - 18975 - eelco - in nixos/trunk/modules: installer/cd-dvd system/boot virtualisation

Lluís Batlle viriketo at gmail.com
Sat Dec 19 23:57:12 CET 2009


FYI:
If I don't load "sd_mod" explicitly, tuxonice (in the zen kernels)
does not know to resume from my swap at  /dev/sda2.
And, we already commented this on irc, but I had to load the i8042
module to get my keyboard working.

Additionally, I don't think the ide modules are needed, if we use the
pata modules - these provide access to ide discs through the scsi
kernel interace.

Regards,
Lluís.

2009/12/15 Eelco Dolstra <e.dolstra at tudelft.nl>:
> Author: eelco
> Date: 2009-12-15 16:38:20 +0000 (Tue, 15 Dec 2009)
> New Revision: 18975
>
> You can view the changes in this commit at:
>   https://svn.nixos.org/viewvc/nix?rev=18975&view=rev
>
> Modified:
>   nixos/trunk/modules/installer/cd-dvd/installation-cd-base.nix
>   nixos/trunk/modules/installer/cd-dvd/iso-image.nix
>   nixos/trunk/modules/system/boot/kernel.nix
>   nixos/trunk/modules/system/boot/stage-1-init.sh
>   nixos/trunk/modules/system/boot/stage-1.nix
>   nixos/trunk/modules/virtualisation/qemu-vm.nix
>
> Log:
> * 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.
>
>
> Changes:
>
> Modified: nixos/trunk/modules/installer/cd-dvd/installation-cd-base.nix
> ===================================================================
> --- nixos/trunk/modules/installer/cd-dvd/installation-cd-base.nix       2009-12-15 15:48:29 UTC (rev 18974)
> +++ nixos/trunk/modules/installer/cd-dvd/installation-cd-base.nix       2009-12-15 16:38:20 UTC (rev 18975)
> @@ -114,7 +114,7 @@
>
>   # 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 @@
>       "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;
>
> Modified: nixos/trunk/modules/installer/cd-dvd/iso-image.nix
> ===================================================================
> --- nixos/trunk/modules/installer/cd-dvd/iso-image.nix  2009-12-15 15:48:29 UTC (rev 18974)
> +++ nixos/trunk/modules/installer/cd-dvd/iso-image.nix  2009-12-15 16:38:20 UTC (rev 18975)
> @@ -128,7 +128,7 @@
>       (! 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
>
> Modified: nixos/trunk/modules/system/boot/kernel.nix
> ===================================================================
> --- nixos/trunk/modules/system/boot/kernel.nix  2009-12-15 15:48:29 UTC (rev 18974)
> +++ nixos/trunk/modules/system/boot/kernel.nix  2009-12-15 16:38:20 UTC (rev 18975)
> @@ -61,13 +61,65 @@
>         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,51 +152,18 @@
>         "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.
> -      '';
> -    };
> +
> +    boot.initrd.kernelModules =
> +      [ # For LVM.
> +        "dm_mod"
> +      ];
>
> -    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" ];
> -
>     # The Linux kernel >= 2.6.27 provides firmware.
>     hardware.firmware = [ "${kernel}/lib/firmware" ];
>
>
> Modified: nixos/trunk/modules/system/boot/stage-1-init.sh
> ===================================================================
> --- nixos/trunk/modules/system/boot/stage-1-init.sh     2009-12-15 15:48:29 UTC (rev 18974)
> +++ nixos/trunk/modules/system/boot/stage-1-init.sh     2009-12-15 16:38:20 UTC (rev 18975)
> @@ -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
>
>
> -# 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 @@
>  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
>
>
> @@ -107,12 +99,13 @@
>  fi
>
>  if test -e /sys/power/resume -a -e /sys/power/disk; then
> -  echo "@resumeDevice@" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
> -  echo shutdown > /sys/power/disk
> +    echo "@resumeDevice@" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
> +    echo shutdown > /sys/power/disk
>  fi
>
>
>  # Create device nodes in /dev.
> +echo "running udev..."
>  export UDEV_CONFIG_FILE=@udevConf@
>  mkdir -p /dev/.udev # !!! bug in udev?
>  udevd --daemon
> @@ -120,10 +113,10 @@
>  udevadm settle
>
>  if type -p dmsetup > /dev/null; then
> -  echo "starting device mapper and LVM..."
> -  dmsetup mknodes
> -  lvm vgscan --ignorelockingfailure
> -  lvm vgchange -ay --ignorelockingfailure
> +    echo "starting device mapper and LVM..."
> +    dmsetup mknodes
> +    lvm vgscan --ignorelockingfailure
> +    lvm vgchange -ay --ignorelockingfailure
>  fi
>
>  if test -n "$debug1devices"; then fail; fi
>
> Modified: nixos/trunk/modules/system/boot/stage-1.nix
> ===================================================================
> --- nixos/trunk/modules/system/boot/stage-1.nix 2009-12-15 15:48:29 UTC (rev 18974)
> +++ nixos/trunk/modules/system/boot/stage-1.nix 2009-12-15 16:38:20 UTC (rev 18975)
> @@ -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 @@
>       ";
>     };
>
> -    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 @@
>     };
>
>     boot.initrd.extraUtilsCommands = mkOption {
> +      internal = true;
>       default = "";
>       merge = pkgs.lib.mergeStringOption;
>       description = ''
> @@ -110,9 +102,9 @@
>
>   # 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 @@
>     { 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,9 +171,9 @@
>       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}
>
>       # Run patchelf to make the programs refer to the copied libraries.
> @@ -191,12 +183,20 @@
>           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 @@
>       $out/bin/reiserfsck -V
>       $out/bin/mdadm --version
>       $out/bin/basename --version
> -      $out/bin/insmod --version
> +      $out/bin/modprobe --version
>     ''; # */
>
>
> @@ -234,6 +234,7 @@
>
>       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 @@
>             --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 @@
>
>     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 @@
>     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
> -    ];
>   };
>
>
>
> Modified: nixos/trunk/modules/virtualisation/qemu-vm.nix
> ===================================================================
> --- nixos/trunk/modules/virtualisation/qemu-vm.nix      2009-12-15 15:48:29 UTC (rev 18974)
> +++ nixos/trunk/modules/virtualisation/qemu-vm.nix      2009-12-15 16:38:20 UTC (rev 18975)
> @@ -71,8 +71,8 @@
>   # 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 =
> -    ["cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8"];
> +  boot.initrd.availableKernelModules =
> +    [ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8" ];
>
>   boot.initrd.extraUtilsCommands =
>     ''
>
> _______________________________________________
> nix-commits mailing list
> nix-commits at cs.uu.nl
> http://mail.cs.uu.nl/mailman/listinfo/nix-commits
>



More information about the nix-dev mailing list