Difference between revisions of "Diskless system"
m (→GRUB: "and" is a verb apparently) |
m (→NBD: ic++) |
||
Line 120: | Line 120: | ||
copyonwrite = false}} | copyonwrite = false}} | ||
− | {{note|Set {{ic|copyonwrite}} to true if you want to have multiple clients using the same NBD share simultaneously; refer to man 5 nbd-server for more details.}} | + | {{note|Set {{ic|copyonwrite}} to true if you want to have multiple clients using the same NBD share simultaneously; refer to {{ic|man 5 nbd-server}} for more details.}} |
Start nbd. | Start nbd. |
Revision as of 23:27, 10 December 2012
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
Contrast to the official installation guide, which concentrates on an arch installation on local storage, here the installation is to be placed on network storage.
Contents
Server configuration
You will need a DHCP server to setup networking, as well as a TFTP server to transfer the boot image (a requirement of all PXE option roms). Unlike PXE which is designed for quick-and-dirty/temporary setups to boot installation media, here you're actually doing a network installation, which is more-permanent, and thus calls for doing things properly.
DHCP
Install ISC dhcp.
# pacman -Syu dhcp
Configure ISC DHCP.
# vim /etc/dhcpd.conf
allow booting; allow bootp; authoritative; option domain-name-servers 10.0.0.1; group { next-server 10.0.0.1; filename "pxelinux.0"; subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.1; range 10.0.0.128 10.0.0.254; } }
next-server
should be the address of the TFTP server; everything else should be changed to match your networkStart ISC DHCP.
# systemctl start dhcpd4
TFTP
The TFTP server will be used to transfer the kernel, initramfs, and pxelinux to the client.
Install tftp-hpa.
# pacman -Syu tftp-hpa
/srv/arch/boot
to /srv/boot
if you're going to use NBD, because you'll be unable to mount your root filesystem while in useConfiguration
Copy the tftp unit files in /usr/lib/systemd/system
to /etc/systemd/system
; the former gets overwritten when systemd is updated. The systemd article talks in more detail about customizing unit files.
# cp /usr/lib/systemd/system/tftpd.s* /etc/systemd/system/
Next we tell tftpd where the tftp root is: /srv/arch/boot
.
# vim /etc/systemd/system/tftpd.service
[Unit] Description=hpa's original TFTP daemon [Service] ExecStart=/usr/sbin/in.tftpd -s /srv/arch/boot/ StandardInput=socket StandardOutput=inherit StandardError=journal
Start tftpd :
# systemctl start tftpd.socket
Network storage
The primary difference between using NFS and NBD is while with both you can in fact have multiple clients using the same installation, with NBD (by the nature of manipulating a filesystem directly) you'll need to use the copyonwrite
mode to do so, which ends up discarding all writes on client disconnect. In some situations however, this might be highly desirable.
NFS
Install nfs-utils on the server.
# pacman -Syu nfs-utils
You'll need to add the root of your arch installation to your NFS exports:
# vim /etc/exports
/srv/arch *(rw,fsid=0,no_root_squash,no_subtree_check,async)
async
with sync
--additional options can be found in the NFS article.Next start NFS.
# systemctl start rpc-idmapd.service rpc-mountd.service
NBD
Install nbd.
# pacman -Syu nbd
Configure nbd.
# vim /etc/nbd-server/config
[generic] [arch] exportname = /srv/arch.img copyonwrite = false
copyonwrite
to true if you want to have multiple clients using the same NBD share simultaneously; refer to man 5 nbd-server
for more details.Start nbd.
# systemctl start nbd
Client installation
Directory setup
Create a sparse file of at least 1 gigabyte, and create an ext4 filesystem on it (you can of course also use a real block device or LVM if you so desire).
# truncate -s 1G /srv/arch.img # mkfs.ext4 /srv/arch.img # export root=/srv/arch # mkdir -p "$root" # mount /srv/arch.img "$root"
Bootstrapping installation
Install devtools and arch-install-scripts, and run mkarchoot
.
# pacman -Syu devtools arch-install-scripts # mkarchroot -f --arch x86_64 "$root" base mkinitcpio-nfs-utils nfs-utils
Replace x86_64
with i686
as appropriate for your target hardware.
ipconfig
used in early-boot is provided only by the latter.Trivial modifications to the net
hook are required in order for NFSv4 mounting to work (not supported by nfsmount
--the default for the net
hook).
# sed s/nfsmount/mount.nfs4/ "$root/usr/lib/initcpio/hooks/net" | tee "$root/usr/lib/initcpio/hooks/net_nfs4" # cp "$root/usr/lib/initcpio/install/{net,net_nfs4}"
The copy of net
is unfortunately needed so it does not get overwritten when mkinitcpio-nfs-utils is updated on the client installation.
The newly-created net_nfs4
hook needs to be added to the HOOKS
array in mkinitcpio.conf
, and mount.nfs4
to BINARIES
.
# vim "$root/etc/mkinitcpio.conf"
MODULES="nfsv4" HOOKS="base udev autodetect net_nfs4 filesystems" BINARIES="/sbin/mount.nfs4"
net
hook is sufficient for NBD installations; you will also need to append nbd
to your HOOKS
array; mount.nfs4
is also not neededThe initramfs now needs to be rebuilt; the easiest way to do this is via arch-chroot
.
# arch-chroot "$root" /bin/bash (chroot) # mkinitcpio -p linux (chroot) # exit
Client configuration
In addition to the setup mentioned here, you should also set up your hostname, timezone, locale, and keymap, and follow any other relevant parts of the Installation Guide.
Bootloader
Pxelinux
Install syslinux.
# pacman -Syu syslinux
Copy the pxelinux bootloader (provided by the syslinux package) to the boot directory of the client.
# cp /usr/lib/syslinux/pxelinux.0 "$root/boot" # mkdir "$root/boot/pxelinux.cfg"
We also created the pxelinux.cfg
directory, which is where pxelinux searches for configuration files by default. Because we don't want to discriminate between different host MACs, we then create the default
configuration.
# vim "$root/boot/pxelinux.cfg/default"
default linux label linux kernel vmlinuz-linux append initrd=initramfs-linux.img ip=:::::eth0:dhcp nfsroot=10.0.0.1:/
Or if you are using NBD, use the following append line:
append initrd=initramfs-linux.img ip=:::::eth0:dhcp nbd_host=10.0.0.1 nbd_name=arch
nbd_host
and/or nfsroot
, respectively, to match your network configuration (the address of the NFS/NBD server)The pxelinux configuration syntax identical to syslinux; refer to the upstream documentation for more information.
The kernel and initramfs will be transferred via TFTP, so the paths to those are going to be relative to the TFTP root. Otherwise, the root filesystem is going to be the NFS mount itself, so those are relative to the root of the NFS server.
GRUB
Though poorly documented, grub also supports being loaded via PXE. Because of an endainness bug in grub-core/net/tftp.c
not fixed until bzr revision 4548 (grub-bios 2.00 is revision 4542), you will need to install grub-bios-bzrAUR; it makes the most sense to do this on the client installation. The Arch User Repository article describes in more detail on how to build AUR packages.
# pacman --root "$root" --dbpath "$root/var/lib/pacman" -U grub-bios-bzr-4599-1-x86_64.pkg.tar.xz
Only because we want to use the grub-bios-bzrAUR installation on the target, we arch-chroot
the target installation so we can use its grub-mknetdir
instead.
# arch-chroot /srv/arch (chroot) # grub-mknetdir --net-directory=/boot/ --subdir=/grub (chroot) # exit
filename
directive in /etc/dhcpd.conf
to /grub/i386-pc/core.0
as grub-mknetdir
will tell youNow we create a trivial QnD grub configuration
# vim "$root/boot/grub/grub.cfg"
menuentry "Arch Linux" { linux /vmlinuz-linux ip=:::::eth0:dhcp nfsroot=10.0.0.1:/ initrd /initramfs-linux.img }
GRUB dark-magic will set root=(pxe:10.0.0.1)
automatically, so that the kernel and initramfs are transferred via TFTP without any additional configuration.
VFS mountpoints
Add hacks to your fstab for the root filesystem and devpts.
# vim "$root/etc/fstab"
none / none defaults 0 0 none /dev/pts devpts mode=0620,gid=5,nosuid,noexec 0 0
Consider /var
For a simple setup, it may not be an issue that /var
is shared between all of the clients. A booted system does not expect /var
to be shared. If you intend to run BOINC or SLURMAUR, you will definitely need to have separate /var
directories for each of your clients.
You could mount /var/log
, for example, as tmpfs so that logs from multiple hosts don't mix unpredictably.
/etc/fstab
tmpfs /var/log tmpfs nodev,nosuid 0 0
Client boot
NBD
If you're using NBD, you'll need to umount the arch.img
before/while you boot your client.
This makes things particularly interesting when it comes to kernel updates. You can't have your client filesystem mounted while you're booting a client, but that also means you need to use a kernel separate from your client filesystem in order to build it.
You'll need to first copy $root/boot from the client installation to your tftp root (i.e. /srv/boot).
# cp -r "$root/boot" /srv/boot
You'll then need to umount $root before you start the client.
# umount "$root"
/srv/boot
using NFS in fstab on the client (prior to doing the kernel update) or mount your client filesystem after the client has disconnected from NBD