summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2010-08-07 14:16:18 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2010-08-07 14:16:18 +0000
commite8e7ee356c7356345be059bb1f412162a2462f76 (patch)
tree215b362eb355cc88ff1605963e2ea54792784ed9 /modules
parent3cab6d3e1cbbf7aa5156c7760a994af890845970 (diff)
downloadnixlib-e8e7ee356c7356345be059bb1f412162a2462f76.tar
nixlib-e8e7ee356c7356345be059bb1f412162a2462f76.tar.gz
nixlib-e8e7ee356c7356345be059bb1f412162a2462f76.tar.bz2
nixlib-e8e7ee356c7356345be059bb1f412162a2462f76.tar.lz
nixlib-e8e7ee356c7356345be059bb1f412162a2462f76.tar.xz
nixlib-e8e7ee356c7356345be059bb1f412162a2462f76.tar.zst
nixlib-e8e7ee356c7356345be059bb1f412162a2462f76.zip
* In the installation CD, pass the label of the CD through the
  root=... kernel command line parameter, instead of hard-coding it in
  `fileSystems'.  This is to allow CD-to-USB converters such as
  UNetbootin to rewrite the kernel command line to the label or UUID
  of the USB stick.

svn path=/nixos/trunk/; revision=23024
Diffstat (limited to 'modules')
-rw-r--r--modules/installer/cd-dvd/iso-image.nix17
-rw-r--r--modules/system/boot/stage-1-init.sh14
-rw-r--r--modules/system/boot/stage-1.nix1
3 files changed, 29 insertions, 3 deletions
diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix
index 71b797b0d950..9ce05522f484 100644
--- a/modules/installer/cd-dvd/iso-image.nix
+++ b/modules/installer/cd-dvd/iso-image.nix
@@ -107,11 +107,22 @@ in
   system.boot.loader.kernelFile = "bzImage";
   environment.systemPackages = [ pkgs.grub2 ];
 
-  # In stage 1 of the boot, mount the CD/DVD as the root FS by label
-  # so that we don't need to know its device.
+  # In stage 1 of the boot, mount the CD as the root FS by label so
+  # that we don't need to know its device.  We pass the label of the
+  # root filesystem on the kernel command line, rather than in
+  # `fileSystems' below.  This allows CD-to-USB converters such as
+  # UNetbootin to rewrite the kernel command line to pass the label or
+  # UUID of the USB stick.  It would be nicer to write
+  # `root=/dev/disk/by-label/...' here, but UNetbootin doesn't
+  # recognise that.
+  boot.kernelParams = [ "root=LABEL=${config.isoImage.volumeID}" ];
+
+  # Note that /dev/root is a symlink to the actual root device
+  # specified on the kernel command line, created in the stage 1 init
+  # script.
   fileSystems =
     [ { mountPoint = "/";
-        label = config.isoImage.volumeID;
+        device = "/dev/root";
       }
       { mountPoint = "/nix/store";
         fsType = "squashfs";
diff --git a/modules/system/boot/stage-1-init.sh b/modules/system/boot/stage-1-init.sh
index 11a10629d7cf..080016dc32c6 100644
--- a/modules/system/boot/stage-1-init.sh
+++ b/modules/system/boot/stage-1-init.sh
@@ -80,6 +80,20 @@ for o in $(cat /proc/cmdline); do
         stage1panic)
             panicOnFail=1
             ;;
+        root=*)
+            # If a root device is specified on the kernel command
+            # line, make it available through the symlink /dev/root.
+            # Recognise LABEL= and UUID= to support UNetbootin.
+            set -- $(IFS==; echo $o)
+            if [ $2 = "LABEL" ]; then
+                root="/dev/disk/by-label/$3"
+            elif [ $2 = "UUID" ]; then
+                root="/dev/disk/by-uuid/$3"
+            else
+                root=$2
+            fi
+            ln -s "$root" /dev/root
+            ;;
     esac
 done
 
diff --git a/modules/system/boot/stage-1.nix b/modules/system/boot/stage-1.nix
index 0a5cec8b1d23..4eb0eedf0b40 100644
--- a/modules/system/boot/stage-1.nix
+++ b/modules/system/boot/stage-1.nix
@@ -130,6 +130,7 @@ let
       cp -v ${pkgs.coreutils}/bin/cat $out/bin
       cp -v ${pkgs.coreutils}/bin/chroot $out/bin
       cp -v ${pkgs.coreutils}/bin/sleep $out/bin
+      cp -v ${pkgs.coreutils}/bin/ln $out/bin
 
       # Copy e2fsck and friends.      
       cp -v ${pkgs.e2fsprogs}/sbin/e2fsck $out/bin