* 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:
parent
b760a4b8d9
commit
a83becdee8
@ -158,63 +158,25 @@ mkdir /mnt-root
|
|||||||
echo "mounting the root device.... (fix: sleeping 5 seconds to wait for upcoming usb drivers)"
|
echo "mounting the root device.... (fix: sleeping 5 seconds to wait for upcoming usb drivers)"
|
||||||
sleep 5
|
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.
|
for ((n = 0; n < ${#mountPoints[*]}; n++)); do
|
||||||
echo "probing for the NixOS installation CD..."
|
|
||||||
|
|
||||||
for i in /sys/block/*; do
|
|
||||||
if test "$(cat $i/removable)" = "1"; then
|
|
||||||
|
|
||||||
echo " in $i..."
|
|
||||||
|
|
||||||
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]}
|
mountPoint=${mountPoints[$n]}
|
||||||
device=${devices[$n]}
|
device=${devices[$n]}
|
||||||
fsType=${fsTypes[$n]}
|
fsType=${fsTypes[$n]}
|
||||||
options=${optionss[$n]}
|
options=${optionss[$n]}
|
||||||
|
|
||||||
# !!! Really quick hack to support bind mounts, i.e., where
|
# !!! Really quick hack to support bind mounts, i.e., where the
|
||||||
# the "device" should be taken relative to /mnt-root, not /.
|
# "device" should be taken relative to /mnt-root, not /. Assume
|
||||||
# Assume that every device that start with / but doesn't
|
# that every device that start with / but doesn't start with /dev
|
||||||
# start with /dev or LABEL= is a bind mount.
|
# or LABEL= is a bind mount.
|
||||||
case $device in
|
case $device in
|
||||||
/dev/*)
|
/dev/*)
|
||||||
;;
|
;;
|
||||||
LABEL=*)
|
|
||||||
;;
|
|
||||||
/*)
|
/*)
|
||||||
device=/mnt-root$device
|
device=/mnt-root$device
|
||||||
;;
|
;;
|
||||||
@ -223,9 +185,7 @@ else
|
|||||||
echo "mounting $device on $mountPoint..."
|
echo "mounting $device on $mountPoint..."
|
||||||
|
|
||||||
mountFS "$device" "$mountPoint" "$options" "$fsType"
|
mountFS "$device" "$mountPoint" "$options" "$fsType"
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# If this is a live-CD/DVD, then union-mount a tmpfs on top of the
|
# If this is a live-CD/DVD, then union-mount a tmpfs on top of the
|
||||||
|
@ -109,19 +109,17 @@ rec {
|
|||||||
|
|
||||||
inherit modulesClosure udevConf;
|
inherit modulesClosure udevConf;
|
||||||
|
|
||||||
inherit (config.boot) autoDetectRootDevice isLiveCD resumeDevice;
|
inherit (config.boot) isLiveCD resumeDevice;
|
||||||
|
|
||||||
# !!! copy&pasted from upstart-jobs/filesystems.nix.
|
# !!! copy&pasted from upstart-jobs/filesystems.nix.
|
||||||
mountPoints =
|
mountPoints =
|
||||||
if !config.boot.autoDetectRootDevice && fileSystems == []
|
if fileSystems == []
|
||||||
then abort "You must specify the fileSystems option!"
|
then abort "You must specify the fileSystems option!"
|
||||||
else map (fs: fs.mountPoint) fileSystems;
|
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;
|
fsTypes = map (fs: if fs ? fsType then fs.fsType else "auto") fileSystems;
|
||||||
optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems;
|
optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems;
|
||||||
|
|
||||||
rootLabel = if config.boot.autoDetectRootDevice then config.boot.rootLabel else "";
|
|
||||||
|
|
||||||
path = [
|
path = [
|
||||||
# `extraUtils' comes first because it overrides the `mount'
|
# `extraUtils' comes first because it overrides the `mount'
|
||||||
# command provided by klibc (which isn't capable of
|
# command provided by klibc (which isn't capable of
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
|
||||||
|
cdLabel = "NIXOS_INSTALLATION_CD";
|
||||||
|
|
||||||
|
|
||||||
configuration = {
|
configuration = {
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
autoDetectRootDevice = true;
|
|
||||||
isLiveCD = true;
|
isLiveCD = true;
|
||||||
# The label used to identify the installation CD.
|
|
||||||
rootLabel = "NIXOS";
|
|
||||||
extraTTYs = [7 8]; # manual, rogue
|
extraTTYs = [7 8]; # manual, rogue
|
||||||
extraModulePackages = [system.kernelPackages.aufs];
|
extraModulePackages = [system.kernelPackages.aufs];
|
||||||
|
|
||||||
@ -69,6 +69,12 @@ rec {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fileSystems = [
|
||||||
|
{ mountPoint = "/";
|
||||||
|
label = cdLabel;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
enableIntel3945ABGFirmware = true;
|
enableIntel3945ABGFirmware = true;
|
||||||
};
|
};
|
||||||
@ -277,9 +283,6 @@ rec {
|
|||||||
{ source = nixpkgsTarball + "/nixpkgs.tar.bz2";
|
{ source = nixpkgsTarball + "/nixpkgs.tar.bz2";
|
||||||
target = "/install/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.
|
# Closures to be copied to the Nix store on the CD.
|
||||||
@ -301,7 +304,7 @@ rec {
|
|||||||
|
|
||||||
inherit compressImage;
|
inherit compressImage;
|
||||||
|
|
||||||
volumeID = "NIXOS_INSTALLATION_CD";
|
volumeID = cdLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,15 +46,6 @@ in
|
|||||||
|
|
||||||
boot = {
|
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 {
|
isLiveCD = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
description = "
|
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 {
|
grubDevice = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "/dev/hda";
|
example = "/dev/hda";
|
||||||
@ -588,8 +569,7 @@ in
|
|||||||
];
|
];
|
||||||
description = "
|
description = "
|
||||||
The file systems to be mounted. It must include an entry for
|
The file systems to be mounted. It must include an entry for
|
||||||
the root directory (<literal>mountPoint = \"/\"</literal>) if
|
the root directory (<literal>mountPoint = \"/\"</literal>). Each
|
||||||
<literal>boot.autoDetectRootDevice</literal> is not set. Each
|
|
||||||
entry in the list is an attribute set with the following fields:
|
entry in the list is an attribute set with the following fields:
|
||||||
<literal>mountPoint</literal>, <literal>device</literal>,
|
<literal>mountPoint</literal>, <literal>device</literal>,
|
||||||
<literal>fsType</literal> (a file system type recognised by
|
<literal>fsType</literal> (a file system type recognised by
|
||||||
|
Loading…
Reference in New Issue
Block a user