forked from mirrors/nixpkgs
A more friendly stage1, with interactive bash, busybox plenty of tools, etc.
I set it as default because users can benefit of this without having to prepare their nixos first, and I don't think it will break any nixos for the initrd size increase. It can be disabled with 'boot.initrd.withExtraTools = false'. svn path=/nixos/trunk/; revision=33000
This commit is contained in:
parent
6a0958cc06
commit
bbebba68f7
|
@ -190,6 +190,7 @@
|
||||||
./system/boot/luksroot.nix
|
./system/boot/luksroot.nix
|
||||||
./system/boot/modprobe.nix
|
./system/boot/modprobe.nix
|
||||||
./system/boot/stage-1.nix
|
./system/boot/stage-1.nix
|
||||||
|
./system/boot/stage-1-extratools.nix
|
||||||
./system/boot/stage-2.nix
|
./system/boot/stage-2.nix
|
||||||
./system/etc/etc.nix
|
./system/etc/etc.nix
|
||||||
./system/upstart-events/control-alt-delete.nix
|
./system/upstart-events/control-alt-delete.nix
|
||||||
|
|
56
modules/system/boot/stage-1-extratools.nix
Normal file
56
modules/system/boot/stage-1-extratools.nix
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{ config, pkgs, ...}:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
staticBusybox = pkgs.busybox.override {
|
||||||
|
enableStatic = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
options = {
|
||||||
|
boot.initrd.withExtraTools = mkOption {
|
||||||
|
default = true;
|
||||||
|
type = with types; bool;
|
||||||
|
description = ''
|
||||||
|
Have busybox utils in initrd, and an interactive bash.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.extraUtilsCommands = mkIf config.boot.initrd.withExtraTools ''
|
||||||
|
|
||||||
|
set -x
|
||||||
|
cp -pv ${pkgs.ncurses}/lib/libncurses*.so.* $out/lib
|
||||||
|
cp -pv ${pkgs.readline}/lib/libreadline.so.* $out/lib
|
||||||
|
cp -pv ${pkgs.readline}/lib/libhistory.so.* $out/lib
|
||||||
|
rm $out/bin/bash
|
||||||
|
cp -pv ${pkgs.bashInteractive}/bin/bash $out/bin
|
||||||
|
|
||||||
|
cp -pv ${staticBusybox}/bin/busybox $out/bin
|
||||||
|
shopt -s nullglob
|
||||||
|
for d in bin sbin; do
|
||||||
|
pushd ${staticBusybox}/$d
|
||||||
|
# busybox has these, but we'll put them later
|
||||||
|
GLOBIGNORE=.:..:mke2fs:ip:modprobe
|
||||||
|
for a in *; do
|
||||||
|
if [ ! -e $out/bin/$a ]; then
|
||||||
|
ln -sf busybox $out/bin/$a
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
unset GLOBIGNORE
|
||||||
|
'';
|
||||||
|
|
||||||
|
boot.initrd.extraUtilsCommandsTest = mkIf config.boot.initrd.withExtraTools ''
|
||||||
|
$out/bin/busybox
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -25,12 +25,23 @@ EOF
|
||||||
|
|
||||||
read reply
|
read reply
|
||||||
|
|
||||||
|
# Get the console from the kernel cmdline
|
||||||
|
console=tty1
|
||||||
|
for o in $(cat /proc/cmdline); do
|
||||||
|
case $o in
|
||||||
|
console=*)
|
||||||
|
set -- $(IFS==; echo $o)
|
||||||
|
console=$2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
case $reply in
|
case $reply in
|
||||||
f)
|
f)
|
||||||
exec @shell@;;
|
exec setsid @shell@ < /dev/$console >/dev/$console 2>/dev/$console ;;
|
||||||
i)
|
i)
|
||||||
echo "Starting interactive shell..."
|
echo "Starting interactive shell..."
|
||||||
@shell@ || fail
|
setsid @shell@ < /dev/$console >/dev/$console 2>/dev/$console || fail
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Continuing...";;
|
echo "Continuing...";;
|
||||||
|
@ -57,6 +68,11 @@ mount -t tmpfs -o "mode=0755,size=@devSize@" none /dev
|
||||||
mkdir -p /run
|
mkdir -p /run
|
||||||
mount -t tmpfs -o "mode=0755,size=@runSize@" none /run
|
mount -t tmpfs -o "mode=0755,size=@runSize@" none /run
|
||||||
|
|
||||||
|
# Some console devices, for the interactivity
|
||||||
|
mknod /dev/console c 5 1
|
||||||
|
mknod /dev/tty1 c 4 1
|
||||||
|
mknod /dev/ttyS0 c 4 64
|
||||||
|
mknod /dev/ttyS1 c 4 65
|
||||||
|
|
||||||
# Process the kernel command line.
|
# Process the kernel command line.
|
||||||
export stage2Init=/init
|
export stage2Init=/init
|
||||||
|
|
|
@ -139,7 +139,7 @@ let
|
||||||
# Copy some utillinux stuff.
|
# Copy some utillinux stuff.
|
||||||
cp -v ${pkgs.utillinux}/bin/mount ${pkgs.utillinux}/bin/umount \
|
cp -v ${pkgs.utillinux}/bin/mount ${pkgs.utillinux}/bin/umount \
|
||||||
${pkgs.utillinux}/sbin/fsck ${pkgs.utillinux}/sbin/switch_root \
|
${pkgs.utillinux}/sbin/fsck ${pkgs.utillinux}/sbin/switch_root \
|
||||||
${pkgs.utillinux}/sbin/blkid $out/bin
|
${pkgs.utillinux}/sbin/blkid ${pkgs.utillinux}/bin/setsid $out/bin
|
||||||
cp -pdv ${pkgs.utillinux}/lib/libblkid*.so.* $out/lib
|
cp -pdv ${pkgs.utillinux}/lib/libblkid*.so.* $out/lib
|
||||||
cp -pdv ${pkgs.utillinux}/lib/libuuid*.so.* $out/lib
|
cp -pdv ${pkgs.utillinux}/lib/libuuid*.so.* $out/lib
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ if [ ! -e /proc/1 ]; then
|
||||||
mknod -m 0666 /dev/null c 1 3
|
mknod -m 0666 /dev/null c 1 3
|
||||||
mknod -m 0644 /dev/urandom c 1 9 # needed for passwd
|
mknod -m 0644 /dev/urandom c 1 9 # needed for passwd
|
||||||
mknod -m 0644 /dev/console c 5 1
|
mknod -m 0644 /dev/console c 5 1
|
||||||
|
mknod -m 0644 /dev/tty1 c 4 1
|
||||||
|
mknod -m 0644 /dev/ttyS0 c 4 64
|
||||||
|
mknod -m 0644 /dev/ttyS1 c 4 65
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue