Use nfsroot for diskless clients

From FAIWiki
Revision as of 16:24, 16 March 2016 by Mrfai (talk | contribs) (add how to create Xfce live ISO)
Jump to: navigation, search

How to turn the FAI nfsroot into a file system for diskless clients

Someone asked me about using the FAI nfsroot for a diskless client setup. The clients should PXE boot and have /tmp and /var as tmpfs (means writable).

It's pretty easy. (Tested with FAI 4.1 and dracut 034-2 (wheezy) and with FAI 4.4~beta and dracut 40-1 (jessie)).

First add all packages you like to have for your diskless clients to /etc/fai/NFSROOT.

Create the FAI nfsroot

fai-make-nfsroot -v

Then disable some FAI specific things inside the nfsroot:

chroot /srv/fai/nfsroot bash
rm -f /etc/init.d/rcS
dpkg-divert --package fai-nfsroot --remove --rename /etc/init.d/rcS
insserv -r fai-abort

This also works with XFCE and xorg running a graphical desktop.

That's it. Now, boot your client. Since FAI is using aufs (advanced multi layered unification filesystem version 3.x), the whole filesystem is writeable for the client, even it's mounted read-only.

How to create a Live CD with Xfce desktop

This is tested with FAI 5.0.3, Debian 8.0 (Jessie) and dracut 044+3-3. You will have an account called demo, the pw is fai.

fai-make-nfsroot -v

chroot /srv/fai/nfsroot bash
rm -f /etc/init.d/rcS
dpkg-divert --package fai-nfsroot --remove --rename /etc/init.d/rcS
insserv -r fai-abort
export LC_ALL=C
adduser --disabled-login --gecos "fai demo user" demo
usermod -p "$ROOTPW" demo

aptitude -y install at-spi2-core locales lightdm xfce4 xterm xorg xserver-xorg-video-all xserver-xorg-input-all systemd-sysv sysvinit-core-
apt-get clean

# optional
# rm -f /etc/hosts /etc/resolv.conf* /etc/fai/fai.conf /var/lib/apt/lists/*_* /var/tmp/base.tar.xz

Then create the CD/USB ISO image using this command

fai-cd -MJd '' -g ~/grub.cfg-diskless ~/fai-diskless.iso

Here's the grub.cfg.diskless:

## grub2 configuration
set default="FAI diskless client"
set timeout=3
set resolution=1024x768

if loadfont /boot/grub/ascii.pf2 ; then
   insmod png
   set gfxmode=640x480
   insmod gfxterm
   insmod vbe
   terminal_output gfxterm

# make sure we can access partitions
insmod part_msdos
insmod part_gpt

if [ ${iso_path} ] ; then
    set loopback="findiso=${iso_path}"

menuentry "FAI diskless client" --unrestricted {
    set gfxpayload=$resolution
    linux   /boot/vmlinuz root=live:CDLABEL=FAI_CD rd.neednet ip=dhcp
    initrd  /boot/initrd.img

This disk space for creating new files is limited by the amount of free space in the disk image (created inside fai-cd in subroutine calculate_required_size). You will have about 200MB of free disk space. This is NO persistens storage.