diff --git a/boot/boot-stage-1-init.sh b/boot/boot-stage-1-init.sh index 126761f2192..83a06c7d7dd 100644 --- a/boot/boot-stage-1-init.sh +++ b/boot/boot-stage-1-init.sh @@ -158,74 +158,34 @@ mkdir /mnt-root echo "mounting the root device.... (fix: sleeping 5 seconds to wait for upcoming usb drivers)" sleep 5 -if test -n "@autoDetectRootDevice@"; then +# Hard-coded root device(s). +mountPoints=(@mountPoints@) +devices=(@devices@) +fsTypes=(@fsTypes@) +optionss=(@optionss@) - # Look for the root device by label. - echo "probing for the NixOS installation CD..." +for ((n = 0; n < ${#mountPoints[*]}; n++)); do + mountPoint=${mountPoints[$n]} + device=${devices[$n]} + fsType=${fsTypes[$n]} + options=${optionss[$n]} - for i in /sys/block/*; do - if test "$(cat $i/removable)" = "1"; then + # !!! Really quick hack to support bind mounts, i.e., where the + # "device" should be taken relative to /mnt-root, not /. Assume + # that every device that start with / but doesn't start with /dev + # or LABEL= is a bind mount. + case $device in + /dev/*) + ;; + /*) + device=/mnt-root$device + ;; + esac - echo " in $i..." + echo "mounting $device on $mountPoint..." - set -- $(IFS=: ; echo $(cat $i/dev)) - major="$1" - minor="$2" - - # Create a device node for this device. - nuke /dev/tmpdev # don't have `rm' in klibc - mknod /dev/tmpdev b "$major" "$minor" - - if mount -o ro -t iso9660 /dev/tmpdev /mnt-root; then - if test -e "/mnt-root/@rootLabel@"; then - found=1 - break - fi - umount /mnt-root - fi - - fi - done - - if test -z "$found"; then - echo "CD not found!" - fail - fi - -else - - # Hard-coded root device(s). - mountPoints=(@mountPoints@) - devices=(@devices@) - fsTypes=(@fsTypes@) - optionss=(@optionss@) - - for ((n = 0; n < ${#mountPoints[*]}; n++)); do - mountPoint=${mountPoints[$n]} - device=${devices[$n]} - fsType=${fsTypes[$n]} - options=${optionss[$n]} - - # !!! Really quick hack to support bind mounts, i.e., where - # the "device" should be taken relative to /mnt-root, not /. - # Assume that every device that start with / but doesn't - # start with /dev or LABEL= is a bind mount. - case $device in - /dev/*) - ;; - LABEL=*) - ;; - /*) - device=/mnt-root$device - ;; - esac - - echo "mounting $device on $mountPoint..." - - mountFS "$device" "$mountPoint" "$options" "$fsType" - done - -fi + mountFS "$device" "$mountPoint" "$options" "$fsType" +done # If this is a live-CD/DVD, then union-mount a tmpfs on top of the diff --git a/boot/boot-stage-1.nix b/boot/boot-stage-1.nix index 3195ca81a0a..3e707f9e141 100644 --- a/boot/boot-stage-1.nix +++ b/boot/boot-stage-1.nix @@ -109,19 +109,17 @@ rec { inherit modulesClosure udevConf; - inherit (config.boot) autoDetectRootDevice isLiveCD resumeDevice; + inherit (config.boot) isLiveCD resumeDevice; # !!! copy&pasted from upstart-jobs/filesystems.nix. mountPoints = - if !config.boot.autoDetectRootDevice && fileSystems == [] + if fileSystems == [] then abort "You must specify the fileSystems option!" else map (fs: fs.mountPoint) fileSystems; - devices = map (fs: if fs ? device then fs.device else "LABEL=" + fs.label) fileSystems; + devices = map (fs: if fs ? device then fs.device else "/dev/disk/by-label/${fs.label}") fileSystems; fsTypes = map (fs: if fs ? fsType then fs.fsType else "auto") fileSystems; optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems; - rootLabel = if config.boot.autoDetectRootDevice then config.boot.rootLabel else ""; - path = [ # `extraUtils' comes first because it overrides the `mount' # command provided by klibc (which isn't capable of diff --git a/configuration/rescue-cd.nix b/configuration/rescue-cd.nix index 9a28e671989..f3d9822ad83 100644 --- a/configuration/rescue-cd.nix +++ b/configuration/rescue-cd.nix @@ -9,14 +9,14 @@ rec { + + cdLabel = "NIXOS_INSTALLATION_CD"; + configuration = { boot = { - autoDetectRootDevice = true; isLiveCD = true; - # The label used to identify the installation CD. - rootLabel = "NIXOS"; extraTTYs = [7 8]; # manual, rogue extraModulePackages = [system.kernelPackages.aufs]; @@ -69,6 +69,12 @@ rec { }; }; + fileSystems = [ + { mountPoint = "/"; + label = cdLabel; + } + ]; + networking = { enableIntel3945ABGFirmware = true; }; @@ -277,9 +283,6 @@ rec { { source = nixpkgsTarball + "/nixpkgs.tar.bz2"; target = "/install/nixpkgs.tar.bz2"; } - { source = pkgs.writeText "label" ""; - target = "/${configuration.boot.rootLabel}"; - } ]; # Closures to be copied to the Nix store on the CD. @@ -301,7 +304,7 @@ rec { inherit compressImage; - volumeID = "NIXOS_INSTALLATION_CD"; + volumeID = cdLabel; }; diff --git a/system/options.nix b/system/options.nix index 4df60a5150c..70f7bcb5faf 100644 --- a/system/options.nix +++ b/system/options.nix @@ -46,15 +46,6 @@ in boot = { - autoDetectRootDevice = mkOption { - default = false; - description = " - Whether to find the root device automatically by searching for a - device with the right label. If this option is off, then a root - file system must be specified using . - "; - }; - isLiveCD = mkOption { default = false; description = " @@ -65,16 +56,6 @@ in "; }; - rootLabel = mkOption { - description = " - When auto-detecting the root device (see - ), this option - specifies the label of the root device. Right now, this is - merely a file name that should exist in the root directory of - the file system. It is used to find the boot CD-ROM. - "; - }; - grubDevice = mkOption { default = ""; example = "/dev/hda"; @@ -588,8 +569,7 @@ in ]; description = " The file systems to be mounted. It must include an entry for - the root directory (mountPoint = \"/\") if - boot.autoDetectRootDevice is not set. Each + the root directory (mountPoint = \"/\"). Each entry in the list is an attribute set with the following fields: mountPoint, device, fsType (a file system type recognised by