Author: viric
Date: Mon Aug 15 14:37:00 2011
New Revision: 28585
URL: https://svn.nixos.org/websvn/nix/?rev=28585&sc=1
Log:
Making the system-tarball-pc boot fine with PXE, and include help files and a
readme file as examples for an easy PXE setup.
This allows booting the NixOS in the system tarball, and thus allows installing
nixos.
Modified:
nixos/trunk/modules/installer/cd-dvd/system-tarball-pc.nix
nixos/trunk/modules/installer/cd-dvd/system-tarball.nix
Modified: nixos/trunk/modules/installer/cd-dvd/system-tarball-pc.nix
==============================================================================
--- nixos/trunk/modules/installer/cd-dvd/system-tarball-pc.nix Mon Aug 15
11:27:07 2011 (r28584)
+++ nixos/trunk/modules/installer/cd-dvd/system-tarball-pc.nix Mon Aug 15
14:37:00 2011 (r28585)
@@ -21,13 +21,92 @@
TOTALTIMEOUT 9000
label nixos
- MENU LABEL ^NixOS base through NFS
+ MENU LABEL ^NixOS using nfsroot
KERNEL bzImage
- append initrd=initrd ip=dhcp tnfsroot=IPADDR:/home/pcroot
systemConfig=${config.system.build.toplevel}
init=${config.system.build.toplevel}/initrd
+ append ip=dhcp nfsroot=/home/pcroot
systemConfig=${config.system.build.toplevel}
init=${config.system.build.toplevel}/init
+
+ # I don't know how to make this boot with nfsroot (using the initrd)
+ label nixos_initrd
+ MENU LABEL NixOS booting the poor ^initrd.
+ KERNEL bzImage
+ append initrd=initrd ip=dhcp nfsroot=/home/pcroot
systemConfig=${config.system.build.toplevel}
init=${config.system.build.toplevel}/init
label memtest
MENU LABEL ^Memtest86+
- KERNEL memtest.bin
+ KERNEL memtest
+ '';
+
+ dhcpdExampleConfig = pkgs.writeText "dhcpd.conf-example" ''
+ # Example configuration for booting PXE.
+ allow booting;
+ allow bootp;
+
+ # Adapt this to your network configuration.
+ option domain-name "local";
+ option subnet-mask 255.255.255.0;
+ option broadcast-address 192.168.1.255;
+ option domain-name-servers 192.168.1.1;
+ option routers 192.168.1.1;
+
+ # PXE-specific configuration directives...
+ # Some BIOS don't accept slashes for paths inside the tftp servers,
+ # and will report Access Violation if they see slashes.
+ filename "pxelinux.0";
+ # For the TFTP and NFS root server. Set the IP of your server.
+ next-server 192.168.1.34;
+
+ subnet 192.168.1.0 netmask 255.255.255.0 {
+ range 192.168.1.50 192.168.1.55;
+ }
+ '';
+
+ readme = pkgs.writeText "readme.txt" ''
+ Let all the files in the system tarball sit in a directory served by NFS
(the NFS root)
+ like this in exportfs:
+ /home/pcroot 192.168.1.0/24(rw,no_root_squash,no_all_squash)
+
+ Run "exportfs -a" after editing /etc/exportfs, for the nfs server to be
aware of the
+ changes.
+
+ Use a tftp server serving the root of boot/ (from the system tarball).
+
+ In order to have PXE boot, use the boot/dhcpd.conf-example file for your
dhcpd server,
+ as it will point your PXE clients to pxelinux.0 from the tftp server.
Adapt the
+ configuration to your network.
+
+ Adapt the pxelinux configuration (boot/pxelinux.cfg/default) to set the
path to your
+ nfrroot. If you use ip=dhcp in the kernel, the nfs server ip will be taken
from
+ dhcp and so you don't have to specify it.
+
+ The linux in bzImage includes network drivers for some usual cards.
+
+
+ QEMU Testing
+ ---------------
+
+ You can test qemu pxe boot without having a DHCP server adapted, but
having nfsroot,
+ like this:
+ qemu-system-x86_64 -tftp /home/pcroot/boot -net nic -net
user,bootfile=pxelinux.0 -boot n
+
+ I don't know how to use NFS through the qemu '-net user' though.
+
+
+ QEMU Testing with NFS root and bridged network
+ -------------------------------------------------
+
+ This allows testing with qemu as any other host in your LAN.
+
+ Testing with the real dhcpd server requires setting up a bridge and having
a tap device.
+ tunctl -t tap0
+ brctl addbr br0
+ brctl addif br0 eth0
+ brctl addif tap0 eth0
+ ifconfig eth0 0.0.0.0 up
+ ifconfig tap0 0.0.0.0 up
+ ifconfig br0 up # With your ip configuration
+
+ Then you can run qemu:
+ qemu-system-x86_64 -boot n -net tap,ifname=tap0,script=no -net
nic,model=e1000
'';
in
@@ -58,8 +137,17 @@
{ source = pxeconfig;
target = "/boot/pxelinux.cfg/default";
}
+ { source = readme;
+ target = "/readme.txt";
+ }
+ { source = dhcpdExampleConfig;
+ target = "/boot/dhcpd.conf-example";
+ }
{ source = "${pkgs.memtest86}/memtest.bin";
- target = "/boot/memtest.bin";
+ # We can't leave '.bin', because pxelinux interprets this specially,
+ # and it would not load the image fine.
+ # http://forum.canardpc.com/threads/46464-0104-when-launched-via-pxe
+ target = "/boot/memtest";
}
];
@@ -69,19 +157,6 @@
services.openssh.enable = true;
jobs.openssh.startOn = pkgs.lib.mkOverrideTemplate 50 {} "";
- boot.initrd.postMountCommands = ''
- for o in $(cat /proc/cmdline); do
- case $o in
- tnfsroot=*)
- set -- $(IFS==; echo $o)
- # TODO: It cannot mount nfs, as maybe it cannot find 'mount.nfs'
- mount $2 /mnt-root
- ;;
- *) ;;
- esac
- done
- '';
-
boot.kernelPackages = pkgs.linuxPackages_2_6_39;
nixpkgs.config = {
packageOverrides = p: rec {
Modified: nixos/trunk/modules/installer/cd-dvd/system-tarball.nix
==============================================================================
--- nixos/trunk/modules/installer/cd-dvd/system-tarball.nix Mon Aug 15
11:27:07 2011 (r28584)
+++ nixos/trunk/modules/installer/cd-dvd/system-tarball.nix Mon Aug 15
14:37:00 2011 (r28585)
@@ -72,13 +72,16 @@
inherit (config.tarball) contents storeContents;
};
+ # Otherwise it will collide with the 'ip=dhcp' kernel autoconfig.
+ networking.useDHCP = false;
+
boot.postBootCommands =
''
# After booting, register the contents of the Nix store on the
# CD in the Nix database in the tmpfs.
if [ -f /nix-path-registration ]; then
${config.environment.nix}/bin/nix-store --load-db <
/nix-path-registration &&
- rm /nix-path/registration
+ rm /nix-path-registration
fi
# nixos-rebuild also requires a "system" profile and an
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits