* Probe for the NixOS installation CD.

svn path=/nixu/trunk/; revision=6985
This commit is contained in:
Eelco Dolstra 2006-11-10 14:38:15 +00:00
parent 4b333e0f67
commit 67f3ee3b64
4 changed files with 52 additions and 7 deletions

View file

@ -1,5 +1,11 @@
#! @shell@
fail() {
# If starting stage 2 failed, start an interactive shell.
echo "Stage 2 failed, starting emergency shell..."
exec @shell@
}
# Print a greeting.
echo
echo "<<< NixOS Stage 1 >>>"
@ -31,10 +37,37 @@ modprobe ide-generic
modprobe ide-disk
modprobe ide-cd
# Try to find and mount the installation CD.
# Mount the installation CD.
mkdir /mnt
mkdir /mnt/cdrom
mount -o ro /dev/hdc /mnt/cdrom
echo "probing for the NixOS installation CD..."
for i in /sys/devices/*/*/media; do
if test "$(cat $i)" = "cdrom"; then
# Hopefully `drivename' matches the device created in /dev.
devName=/dev/$(cat $(dirname $i)/drivename)
echo " in $devName..."
if mount -o ro -t iso9660 $devName /mnt/cdrom; then
if test -e "/mnt/cdrom/@cdromLabel@"; then
found=1
break
fi
umount /mnt/cdrom
fi
fi
done
if test -z "$found"; then
echo "CD not found!"
fail
fi
# Start stage 2.
# !!! Note: we can't use pivot_root here (the kernel gods have
@ -46,6 +79,4 @@ umount /proc # cleanup
umount /sys
exec chroot . /init
# If starting stage 2 failed, start an interactive shell.
echo "Stage 2 failed, starting emergency shell..."
exec @shell@
fail

View file

@ -6,12 +6,13 @@
{ genericSubstituter, shell, staticTools
, module_init_tools, extraUtils, modules
, cdromLabel ? ""
}:
genericSubstituter {
src = ./boot-stage-1-init.sh;
isExecutable = true;
inherit shell modules;
inherit shell modules cdromLabel;
path = [
staticTools
module_init_tools

View file

@ -106,6 +106,9 @@ export PATH=$PATH
export MODULE_DIR=$MODULE_DIR
EOF
# Set the host name.
hostname nixos
# Start an interactive shell.
#exec @shell@

View file

@ -20,6 +20,10 @@ rec {
};
# The label used to identify the installation CD.
cdromLabel = "NIXOS";
# Determine the set of modules that we need to mount the root FS.
modulesClosure = import ./modules-closure.nix {
inherit (pkgs) stdenv kernel module_init_tools;
@ -45,6 +49,7 @@ rec {
inherit (pkgs) genericSubstituter;
inherit (pkgsDiet) module_init_tools;
inherit extraUtils;
inherit cdromLabel;
modules = modulesClosure;
shell = stdenvLinuxStuff.bootstrapTools.bash;
staticTools = stdenvLinuxStuff.staticTools;
@ -110,8 +115,13 @@ rec {
# Since the CD is read-only, the mount points must be on disk.
cdMountPoints = pkgs.stdenv.mkDerivation {
name = "mount-points";
builder = builtins.toFile "builder.sh"
"source $stdenv/setup; mkdir $out; cd $out; mkdir proc sys tmp etc dev var mnt nix nix/var";
builder = builtins.toFile "builder.sh" "
source $stdenv/setup
mkdir $out
cd $out
mkdir proc sys tmp etc dev var mnt nix nix/var
touch $out/${cdromLabel}
";
};