* When booting from the installation CD, just mount

/dev/disk/by-label/<label>.  This makes the whole
  autoDetectRootDevice/rootLabel machinery unnecessary.

svn path=/nixos/trunk/; revision=12561
This commit is contained in:
Eelco Dolstra 2008-08-08 23:01:30 +00:00
parent b760a4b8d9
commit a83becdee8
4 changed files with 38 additions and 97 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
};

View File

@ -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 <option>fileSystems</option>.
";
};
isLiveCD = mkOption {
default = false;
description = "
@ -65,16 +56,6 @@ in
";
};
rootLabel = mkOption {
description = "
When auto-detecting the root device (see
<option>boot.autoDetectRootDevice</option>), 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 (<literal>mountPoint = \"/\"</literal>) if
<literal>boot.autoDetectRootDevice</literal> is not set. Each
the root directory (<literal>mountPoint = \"/\"</literal>). Each
entry in the list is an attribute set with the following fields:
<literal>mountPoint</literal>, <literal>device</literal>,
<literal>fsType</literal> (a file system type recognised by