From b760a4b8d97af5d408399b892bddb7f52870e075 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 8 Aug 2008 22:44:45 +0000 Subject: [PATCH] * Use the persistent storage udev rules in the initrd so that we can use /dev/disk/by-{label,id,...} names for the root FS. * Kill udevd at the end of stage 1. Don't know how it got killed previously... svn path=/nixos/trunk/; revision=12560 --- boot/boot-stage-1-init.sh | 8 +++++--- boot/boot-stage-1.nix | 32 +++++++++++++++++++++++++++++--- upstart-jobs/udev.nix | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/boot/boot-stage-1-init.sh b/boot/boot-stage-1-init.sh index a3f8f8ef7e3..126761f2192 100644 --- a/boot/boot-stage-1-init.sh +++ b/boot/boot-stage-1-init.sh @@ -92,9 +92,7 @@ echo shutdown > /sys/power/disk # Create device nodes in /dev. -export UDEV_CONFIG_FILE=/udev.conf -echo 'udev_rules="/rules"' > $UDEV_CONFIG_FILE -mkdir /rules +export UDEV_CONFIG_FILE=@udevConf@ udevd --daemon udevadm trigger udevadm settle @@ -242,6 +240,10 @@ if test -n "@isLiveCD@"; then fi +# Stop udevd. +kill $(minips -C udevd -o pid=) + + if test -n "$debug1mounts"; then fail; fi diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index b97de3c4e95..3195ca81a0a 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -39,13 +39,16 @@ rec { }; + udev = pkgsKlibc.udev; + + # Some additional utilities needed in stage 1, notably mount. We # don't want to bring in all of util-linux, so we just copy what we # need. extraUtils = pkgs.runCommand "extra-utils" { buildInputs = [pkgs.nukeReferences]; inherit (pkgsStatic) utillinux; - inherit (pkgsKlibc) udev; + inherit udev; e2fsprogs = pkgsDiet.e2fsprogs; devicemapper = if config.boot.initrd.lvm then pkgsStatic.devicemapper else null; lvm2 = if config.boot.initrd.lvm then pkgsStatic.lvm2 else null; @@ -60,6 +63,7 @@ rec { cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $out/bin cp $udev/sbin/udevd $udev/sbin/udevadm $out/bin + cp $udev/lib/udev/*_id $out/bin nuke-refs $out/bin/* ''; # */ @@ -71,7 +75,29 @@ rec { (fs: fs.mountPoint == "/" || (fs ? neededForBoot && fs.neededForBoot)) config.fileSystems; - + + udevRules = pkgs.stdenv.mkDerivation { + name = "udev-rules"; + buildCommand = '' + ensureDir $out + cp ${udev}/*/udev/rules.d/60-persistent-storage.rules $out/ + substituteInPlace $out/60-persistent-storage.rules \ + --replace ata_id ${extraUtils}/bin/ata_id \ + --replace usb_id ${extraUtils}/bin/usb_id \ + --replace scsi_id ${extraUtils}/bin/scsi_id \ + --replace path_id ${extraUtils}/bin/path_id \ + --replace vol_id ${extraUtils}/bin/vol_id + ''; # */ + }; + + + # The udev configuration file for in the initrd. + udevConf = pkgs.writeText "udev-initrd.conf" '' + udev_rules="${udevRules}" + #udev_log="debug" + ''; + + # The init script of boot stage 1 (loading kernel modules for # mounting the root FS). bootStage1 = pkgs.substituteAll { @@ -81,7 +107,7 @@ rec { staticShell = stdenvLinuxStuff.bootstrapTools.bash; - inherit modulesClosure; + inherit modulesClosure udevConf; inherit (config.boot) autoDetectRootDevice isLiveCD resumeDevice; diff --git a/upstart-jobs/udev.nix b/upstart-jobs/udev.nix index 43cad5bc4db..4662adde222 100644 --- a/upstart-jobs/udev.nix +++ b/upstart-jobs/udev.nix @@ -68,7 +68,7 @@ let ''; # */ }; - # The udev configuration file + # The udev configuration file. conf = writeText "udev.conf" '' udev_rules="${udevRules}" #udev_log="debug"