forked from mirrors/nixpkgs
* Stage 1: clean up better (unmount /proc and /sys, remount new root
to /). * Stage 2: use sysvinit to create a bunch of mingetty's on virtual consoles 1-6. Show a nice welcoming message. Start syslogd and log everything to tty10. svn path=/nixu/trunk/; revision=6963
This commit is contained in:
parent
1cec62ba5d
commit
8a43fcd57c
|
@ -36,9 +36,15 @@ mkdir /mnt
|
|||
mkdir /mnt/cdrom
|
||||
mount -o ro /dev/hdc /mnt/cdrom
|
||||
|
||||
# Start stage 2. !!! We use chroot for now, but I guess that should
|
||||
# be pivot_root or so.
|
||||
chroot /mnt/cdrom /init
|
||||
# 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
|
||||
# files in the initramfs, remounts the target root on /, and chroots.
|
||||
cd /mnt/cdrom
|
||||
mount --move . /
|
||||
umount /proc # cleanup
|
||||
umount /sys
|
||||
exec chroot . /init
|
||||
|
||||
# If starting stage 2 failed, start an interactive shell.
|
||||
echo "Stage 2 failed, starting emergency shell..."
|
||||
|
|
|
@ -23,6 +23,12 @@ mount -t proc none /proc
|
|||
mount -t sysfs none /sys
|
||||
mount -t tmpfs none /dev
|
||||
mount -t tmpfs none /tmp
|
||||
mount -t tmpfs none /var
|
||||
mount -t tmpfs none /nix/var
|
||||
|
||||
mkdir -p /nix/var/nix/db
|
||||
mkdir -p /nix/var/nix/gcroots
|
||||
mkdir -p /nix/var/nix/temproots
|
||||
|
||||
# Create device nodes in /dev.
|
||||
source @makeDevices@
|
||||
|
@ -38,5 +44,43 @@ for i in @extraPath@; do
|
|||
fi
|
||||
done
|
||||
|
||||
# Start syslogd.
|
||||
mkdir -p /var/run
|
||||
#mkdir -p /var/log
|
||||
#touch /var/log/messages
|
||||
echo "*.* /dev/tty10" > /etc/syslog.conf
|
||||
echo "syslog 514/udp" > /etc/services # required, even if we don't use it
|
||||
@sysklogd@/sbin/syslogd &
|
||||
|
||||
# login/su absolutely need this.
|
||||
touch /etc/login.defs
|
||||
|
||||
# Enable a password-less root login.
|
||||
echo "root::0:0:root:/:@shell@" > /etc/passwd
|
||||
echo "root:*:0" > /etc/group
|
||||
|
||||
cat > /etc/profile <<EOF
|
||||
export PATH=$PATH
|
||||
export MODULE_DIR=$MODULE_DIR
|
||||
EOF
|
||||
|
||||
# Set up inittab.
|
||||
for i in $(seq 1 6); do
|
||||
echo "$i:2345:respawn:@mingetty@/sbin/mingetty --noclear tty$i" >> /etc/inittab
|
||||
done
|
||||
|
||||
# Show a nice greeting on each terminal.
|
||||
cat > /etc/issue <<EOF
|
||||
|
||||
<<< Welcome to NixOS (\m) - Kernel \r (\l) >>>
|
||||
|
||||
You can log in as \`root'.
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
# Start an interactive shell.
|
||||
exec @shell@
|
||||
#exec @shell@
|
||||
|
||||
# Start init.
|
||||
exec init 2
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{ genericSubstituter, shell, coreutils
|
||||
, utillinux, kernel, path ? []
|
||||
, utillinux, kernel, sysklogd, mingetty
|
||||
, path ? []
|
||||
}:
|
||||
|
||||
genericSubstituter {
|
||||
src = ./boot-stage-2-init.sh;
|
||||
isExecutable = true;
|
||||
inherit shell kernel;
|
||||
inherit shell kernel sysklogd mingetty;
|
||||
path = [
|
||||
coreutils
|
||||
utillinux
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#mknod -m 0600 /dev/console c 5 1
|
||||
mknod -m 0600 /dev/ttyS0 c 4 64
|
||||
mknod -m 0600 /dev/ttyS1 c 4 65
|
||||
mknod -m 0600 /dev/ttyS2 c 4 66
|
||||
|
@ -11,16 +10,12 @@ mknod -m 0666 /dev/zero c 1 5
|
|||
|
||||
# tty
|
||||
mknod -m 0600 /dev/tty c 5 0
|
||||
mknod -m 0600 /dev/tty0 c 4 0
|
||||
mknod -m 0600 /dev/tty1 c 4 1
|
||||
mknod -m 0600 /dev/tty2 c 4 2
|
||||
mknod -m 0600 /dev/tty3 c 4 3
|
||||
mknod -m 0600 /dev/tty4 c 4 4
|
||||
mknod -m 0600 /dev/tty5 c 4 5
|
||||
mknod -m 0600 /dev/tty6 c 4 6
|
||||
mknod -m 0600 /dev/tty7 c 4 7
|
||||
mknod -m 0600 /dev/tty8 c 4 8
|
||||
mknod -m 0600 /dev/tty9 c 4 9
|
||||
if ! test -e /dev/console; then
|
||||
mknod -m 0600 /dev/console c 5 1
|
||||
fi
|
||||
for i in $(seq 0 10); do
|
||||
mknod -m 0600 /dev/tty$i c 4 $i
|
||||
done
|
||||
|
||||
mkdir -m 0755 /dev/pts
|
||||
mknod -m 0666 /dev/ptmx c 5 2
|
||||
|
|
|
@ -33,7 +33,7 @@ rec {
|
|||
extraUtils = pkgs.stdenv.mkDerivation {
|
||||
name = "extra-utils";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
"source $stdenv/setup; ensureDir $out/bin; cp $utillinux/bin/mount $out/bin; nuke-refs $out/bin/mount";
|
||||
"source $stdenv/setup; ensureDir $out/bin; cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin; nuke-refs $out/bin/*";
|
||||
buildInputs = [pkgs.nukeReferences];
|
||||
inherit (pkgsStatic) utillinux;
|
||||
};
|
||||
|
@ -63,7 +63,8 @@ rec {
|
|||
# The init script of boot stage 2, which is supposed to do
|
||||
# everything else to bring up the system.
|
||||
bootStage2 = import ./boot-stage-2.nix {
|
||||
inherit (pkgs) genericSubstituter coreutils utillinux kernel;
|
||||
inherit (pkgs) genericSubstituter coreutils utillinux kernel
|
||||
sysklogd;
|
||||
shell = pkgs.bash + "/bin/sh";
|
||||
|
||||
# Additional stuff; add whatever you want here.
|
||||
|
@ -86,7 +87,15 @@ rec {
|
|||
pkgs.netcat
|
||||
pkgs.nettools
|
||||
pkgs.vim
|
||||
pkgs.nix
|
||||
pkgs.strace
|
||||
pkgs.sysvinit
|
||||
pkgs.procps
|
||||
pkgs.shadowutils
|
||||
pkgs.sysklogd
|
||||
];
|
||||
|
||||
mingetty = pkgs.mingettyWrapper;
|
||||
};
|
||||
|
||||
|
||||
|
@ -94,12 +103,13 @@ rec {
|
|||
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";
|
||||
"source $stdenv/setup; mkdir $out; cd $out; mkdir proc sys tmp etc dev var mnt nix nix/var";
|
||||
};
|
||||
|
||||
|
||||
# Create an ISO image containing the isolinux boot loader, the
|
||||
# kernel, and initrd produced above.
|
||||
# kernel, the initrd produced above, and the closure of the stage 2
|
||||
# init.
|
||||
rescueCD = import ./make-iso9660-image.nix {
|
||||
inherit (pkgs) stdenv cdrtools;
|
||||
isoName = "nixos.iso";
|
||||
|
@ -128,5 +138,5 @@ rec {
|
|||
bootImage = "isolinux/isolinux.bin";
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue