* Pass the path of the stage 2 init script to stage 1 init through the

kernel command line, instead of having a /init symlink.  This allows
  us to switch between configurations.
* Some debug support: adding `debug' to the kernel command line gives
  a stage 1 shell.

svn path=/nixu/trunk/; revision=7107
This commit is contained in:
Eelco Dolstra 2006-11-24 00:04:29 +00:00
parent 1fb01e46c5
commit 2cccff268d
4 changed files with 33 additions and 6 deletions

View File

@ -1,3 +1,8 @@
To get a Stage 1 shell:
Add "debug1" to the kernel command line.
Switching to maintenance mode:
$ shutdown now

View File

@ -32,6 +32,25 @@ mkdir /sys
mount -t sysfs none /sys
# Process the kernel command line.
stage2Init=@stage2Init@
for o in $(cat /proc/cmdline); do
case $o in
init=*)
set -- $(IFS==; echo $o)
stage2Init=$2
;;
debugtrace)
# Show each command.
set -x
;;
debug1)
fail
;;
esac
done
# Create device nodes in /dev.
source @makeDevices@
@ -85,6 +104,7 @@ else
fi
# Start stage 2.
# !!! Note: we can't use pivot_root here (the kernel gods have
# decreed), but we could use run-init from klibc, which deletes all
@ -94,6 +114,10 @@ mount --move . /
umount /proc # cleanup
umount /sys
exec chroot . @stage2Init@
echo "INIT = $stage2Init"
if test -z "$stage2Init"; then fail; fi
exec chroot . $stage2Init
fail

View File

@ -11,7 +11,7 @@ let
bootEnv = import ./boot-environment.nix {
autoDetectRootDevice = false;
inherit rootDevice;
stage2Init = "/init"; # !!! should be bootEnv.bootStage2;
stage2Init = ""; # Passed on the command line via Grub.
readOnlyRoot = false;
};

View File

@ -6,9 +6,8 @@ ln -s $kernel $out/kernel
ln -s $grub $out/grub
cat > $out/menu.lst << GRUBEND
title NixOS
kernel $kernel selinux=0 apm=on acpi=on
initrd $initrd
kernel $kernel selinux=0 apm=on acpi=on init=$bootStage2
initrd $initrd
GRUBEND
ensureDir $out/bin
@ -20,7 +19,6 @@ export PATH=$coreutils/bin:$gnused/bin:$gnugrep/bin:$diffutils/bin
if test -n "$grubDevice"; then
$grubMenuBuilder $out
$grub/sbin/grub-install "$grubDevice" --no-floppy --recheck
ln -sf $bootStage2 /init # !!! fix?
fi
EOF