* 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:
parent
1fb01e46c5
commit
2cccff268d
@ -1,3 +1,8 @@
|
|||||||
|
To get a Stage 1 shell:
|
||||||
|
|
||||||
|
Add "debug1" to the kernel command line.
|
||||||
|
|
||||||
|
|
||||||
Switching to maintenance mode:
|
Switching to maintenance mode:
|
||||||
|
|
||||||
$ shutdown now
|
$ shutdown now
|
||||||
|
@ -32,6 +32,25 @@ mkdir /sys
|
|||||||
mount -t sysfs none /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.
|
# Create device nodes in /dev.
|
||||||
source @makeDevices@
|
source @makeDevices@
|
||||||
|
|
||||||
@ -85,6 +104,7 @@ else
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Start stage 2.
|
# Start stage 2.
|
||||||
# !!! Note: we can't use pivot_root here (the kernel gods have
|
# !!! Note: we can't use pivot_root here (the kernel gods have
|
||||||
# decreed), but we could use run-init from klibc, which deletes all
|
# decreed), but we could use run-init from klibc, which deletes all
|
||||||
@ -94,6 +114,10 @@ mount --move . /
|
|||||||
umount /proc # cleanup
|
umount /proc # cleanup
|
||||||
umount /sys
|
umount /sys
|
||||||
|
|
||||||
exec chroot . @stage2Init@
|
echo "INIT = $stage2Init"
|
||||||
|
|
||||||
|
if test -z "$stage2Init"; then fail; fi
|
||||||
|
|
||||||
|
exec chroot . $stage2Init
|
||||||
|
|
||||||
fail
|
fail
|
||||||
|
@ -11,7 +11,7 @@ let
|
|||||||
bootEnv = import ./boot-environment.nix {
|
bootEnv = import ./boot-environment.nix {
|
||||||
autoDetectRootDevice = false;
|
autoDetectRootDevice = false;
|
||||||
inherit rootDevice;
|
inherit rootDevice;
|
||||||
stage2Init = "/init"; # !!! should be bootEnv.bootStage2;
|
stage2Init = ""; # Passed on the command line via Grub.
|
||||||
readOnlyRoot = false;
|
readOnlyRoot = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,9 +6,8 @@ ln -s $kernel $out/kernel
|
|||||||
ln -s $grub $out/grub
|
ln -s $grub $out/grub
|
||||||
|
|
||||||
cat > $out/menu.lst << GRUBEND
|
cat > $out/menu.lst << GRUBEND
|
||||||
title NixOS
|
kernel $kernel selinux=0 apm=on acpi=on init=$bootStage2
|
||||||
kernel $kernel selinux=0 apm=on acpi=on
|
initrd $initrd
|
||||||
initrd $initrd
|
|
||||||
GRUBEND
|
GRUBEND
|
||||||
|
|
||||||
ensureDir $out/bin
|
ensureDir $out/bin
|
||||||
@ -20,7 +19,6 @@ export PATH=$coreutils/bin:$gnused/bin:$gnugrep/bin:$diffutils/bin
|
|||||||
if test -n "$grubDevice"; then
|
if test -n "$grubDevice"; then
|
||||||
$grubMenuBuilder $out
|
$grubMenuBuilder $out
|
||||||
$grub/sbin/grub-install "$grubDevice" --no-floppy --recheck
|
$grub/sbin/grub-install "$grubDevice" --no-floppy --recheck
|
||||||
ln -sf $bootStage2 /init # !!! fix?
|
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user