Difference between revisions of "Use nfsroot for diskless clients"

From FAIWiki
Jump to: navigation, search
 
(18 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
system via NFS (NFS v3, v4 is not working with overlayfs) from the install server.
 
system via NFS (NFS v3, v4 is not working with overlayfs) from the install server.
  
It's pretty easy. Tested with FAI 5.3.6 and dracut from Debian 9 (stretch).
+
It's pretty easy. Tested with FAI 5.10.1 and Debian 11 (bullseye).
  
 
First add all packages you like to have for your
 
First add all packages you like to have for your
Line 12: Line 12:
 
Create the FAI nfsroot
 
Create the FAI nfsroot
  
<code>fai-make-nfsroot -v</code>
+
<code>fai-make-nfsroot -Nv</code>
  
 +
The option -N will add nonfree firmware software (for e.g. for Wifi interfaces).
 
Then disable some FAI specific things inside the nfsroot:
 
Then disable some FAI specific things inside the nfsroot:
  
 
<pre>
 
<pre>
 
chroot /srv/fai/nfsroot bash
 
chroot /srv/fai/nfsroot bash
rm -f /etc/init.d/rcS
+
apt purge fai-nfsroot
dpkg-divert --package fai-nfsroot --remove --rename /etc/init.d/rcS
 
insserv -r fai-abort
 
 
exit
 
exit
 
</pre>
 
</pre>
 
This also works with XFCE and xorg running a graphical desktop.
 
  
  
Line 32: Line 29:
  
  
== How to create a Live CD with Xfce desktop ==
+
= How to create a Live CD with Xfce desktop =
  
This is tested with FAI 5.0.3, Debian 8.0 (Jessie) and dracut
+
You will have an account called demo, the pw is fai.
044+3-3. You will have an account called demo, the pw is fai.
 
Just confirmed that this is also working using FAI 5.3.6 with Debian 9 (stretch) and dracut 044+241-3
 
  
  
 
<pre>
 
<pre>
fai-make-nfsroot -v
+
fai-make-nfsroot -Nv
  
 
chroot /srv/fai/nfsroot bash
 
chroot /srv/fai/nfsroot bash
rm -f /etc/init.d/rcS
+
apt purge fai-nfsroot
dpkg-divert --package fai-nfsroot --remove --rename /etc/init.d/rcS
 
insserv -r fai-abort
 
 
export LC_ALL=C
 
export LC_ALL=C
 
adduser --disabled-login --gecos "fai demo user" demo
 
adduser --disabled-login --gecos "fai demo user" demo
 
ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
 
ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
 
usermod -p "$ROOTPW" demo
 
usermod -p "$ROOTPW" demo
 +
usermod -p "$ROOTPW" root
 +
  
apt-cache dumpavail > /var/lib/dpkg/available
 
 
apt-get update
 
apt-get update
aptitude -y install at-spi2-core locales task-xfce-desktop network-manager systemd-sysv sysvinit-core-
+
apt-get -y install at-spi2-core locales task-xfce-desktop network-manager systemd-sysv sysvinit-core-
 
apt-get clean
 
apt-get clean
  
rm lib/systemd/system/wpa_supplicant@.service
+
# rm lib/systemd/system/wpa_supplicant@.service
 
# optional
 
# optional
# rm -f /etc/hosts /etc/resolv.conf* /etc/fai/fai.conf /var/lib/apt/lists/*_* /var/tmp/base.tar.xz
+
# rm -f /etc/hosts /etc/resolv.conf* /var/lib/apt/lists/*_* /var/tmp/base.tar.xz
 
exit
 
exit
 
</pre>
 
</pre>
Line 65: Line 59:
  
 
<pre>
 
<pre>
fai-cd -MJd '' -g ~/grub.cfg-diskless ~/fai-diskless.iso
+
fai-cd -HMJd '' -s3000 -g ~/grub.cfg-live ~/fai-live.iso
 
</pre>
 
</pre>
  
Adding -H to fai-cd will add some directories onto the CD, that are normally
+
See man page https://fai-project.org/doc/man/fai-cd.html
excluded. Using FAI 5.3.6, this can only be used if you reduce this
+
for more info.
value in fai-cd, which leads to a bigger disk image. Otherwise there
 
will be a no space on device error.
 
  
<pre>
+
Here's the grub.cfg.live:
<    count=$(($size/900))
 
---
 
>    count=$(($size/800))
 
</pre>
 
 
 
 
 
 
 
Here's the grub.cfg.diskless:
 
 
<pre>
 
<pre>
 
## grub2 configuration
 
## grub2 configuration
set default="FAI diskless client"
+
set default="FAI live system"
 
set timeout=3
 
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
 
fi
 
  
 
# make sure we can access partitions
 
# make sure we can access partitions
 
insmod part_msdos
 
insmod part_msdos
 
insmod part_gpt
 
insmod part_gpt
 +
insmod all_video
 +
insmod gfxterm
  
if [ ${iso_path} ] ; then
+
set gfxmode=auto
    set loopback="findiso=${iso_path}"
+
set color_normal=white/black
fi
+
set color_highlight=red/black
 +
set menu_color_normal=white/black
 +
set menu_color_highlight=black/yellow
  
menuentry "FAI diskless client" --unrestricted {
+
menuentry "FAI live system" --unrestricted {
     set gfxpayload=$resolution
+
     search --set=root --file /FAI-CD
 
     linux  /boot/vmlinuz rd.live.image root=live:CDLABEL=FAI_CD
 
     linux  /boot/vmlinuz rd.live.image root=live:CDLABEL=FAI_CD
 
     initrd  /boot/initrd.img
 
     initrd  /boot/initrd.img
Line 113: Line 92:
  
 
This disk space for creating new files is limited by the amount of
 
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
+
free space in the disk image (added by -s). You will have about 2.5GB of free disk
calculate_required_size). You will have about 200MB of free disk
 
 
space. This is NO persistent storage.
 
space. This is NO persistent storage.
  
 
After booting the machine, you must restart the network interface, for
 
e.g.
 
<pre>
 
dhclient -r ens3
 
dhclient -v ens3
 
</pre>
 
  
 
You can download an ISO image, for and example of this Live CD
 
You can download an ISO image, for and example of this Live CD
http://fai-project.org/fai-cd/debian9-live-xfce.iso
+
https://fai-project.org/fai-cd/debian11-live-xfce.iso

Latest revision as of 22:59, 6 April 2021

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 mount it's whole file system via NFS (NFS v3, v4 is not working with overlayfs) from the install server.

It's pretty easy. Tested with FAI 5.10.1 and Debian 11 (bullseye).

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

Create the FAI nfsroot

fai-make-nfsroot -Nv

The option -N will add nonfree firmware software (for e.g. for Wifi interfaces). Then disable some FAI specific things inside the nfsroot:

chroot /srv/fai/nfsroot bash
apt purge fai-nfsroot
exit


That's it. Now, boot your client. Since FAI is using overlayfs, the whole filesystem is writeable for the client, even it's mounted read-only.


How to create a Live CD with Xfce desktop

You will have an account called demo, the pw is fai.


fai-make-nfsroot -Nv

chroot /srv/fai/nfsroot bash
apt purge fai-nfsroot
export LC_ALL=C
adduser --disabled-login --gecos "fai demo user" demo
ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
usermod -p "$ROOTPW" demo
usermod -p "$ROOTPW" root


apt-get update
apt-get -y install at-spi2-core locales task-xfce-desktop network-manager systemd-sysv sysvinit-core-
apt-get clean

# rm lib/systemd/system/wpa_supplicant@.service
# optional
# rm -f /etc/hosts /etc/resolv.conf* /var/lib/apt/lists/*_* /var/tmp/base.tar.xz
exit

Then create the CD/USB ISO image using this command

fai-cd -HMJd '' -s3000 -g ~/grub.cfg-live ~/fai-live.iso

See man page https://fai-project.org/doc/man/fai-cd.html for more info.

Here's the grub.cfg.live:

## grub2 configuration
set default="FAI live system"
set timeout=3

# make sure we can access partitions
insmod part_msdos
insmod part_gpt
insmod all_video
insmod gfxterm

set gfxmode=auto
set color_normal=white/black
set color_highlight=red/black
set menu_color_normal=white/black
set menu_color_highlight=black/yellow

menuentry "FAI live system" --unrestricted {
    search --set=root --file /FAI-CD
    linux   /boot/vmlinuz rd.live.image root=live:CDLABEL=FAI_CD
    initrd  /boot/initrd.img
}


This disk space for creating new files is limited by the amount of free space in the disk image (added by -s). You will have about 2.5GB of free disk space. This is NO persistent storage.


You can download an ISO image, for and example of this Live CD https://fai-project.org/fai-cd/debian11-live-xfce.iso