Diskless System

Dec 16, 2013
2 min read
May 27, 2023 09:13 EEST

We want to boot via PXE and mount everything via NFS. At first we create a basic directory structure:

export DISKLESS=vdrhd1
export DISKLESS=diskless
mkdir /usr/local/$DISKLESS/
cd !$
mkdir boot
mkdir dev
mkdir bin
mkdir sbin
mkdir lib
mkdir etc
mkdir usr
mkdir root
mkdir home
mkdir proc
mkdir tmp
chmod a+w tmp
mkdir sys
mkdir var
mkdir var/empty
mkdir var/lock
mkdir var/log
mkdir var/run
mkdir var/spool
mkdir var/lib
mkdir var/lib/dbus
mkdir var/tmp
mkdir var/cache
mkdir var/cache/hald
mknod dev/console c 5 1
mknod -m 666 dev/null c 3 1

Be sure you have the following settings in the kernel config:

#
# Networking options
#
CONFIG_PACKET=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
#
# Network File Systems
#
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
CONFIG_NFS_V4=y
CONFIG_ROOT_NFS=y

Compile and install the kernel with:

make
make INSTALL_PATH=/usr/local/$DISKLESS/boot install
make INSTALL_MOD_PATH=/usr/local/$DISKLESS modules_install

You must copy or symlink your kernel to the tftp directory so the client can download the kernel via tftp.

Install NVIDIA Driver

Execute on the headless system:

sh NVIDIA-Linux-x86-275.09.07.run  -a

Prepare DHCPD

Put the following lines to your dhcpd.conf:

next-server 192.168.0.251;
filename "pxelinux.0";
option tftp-server-name "server.idefix.lan";

Boot the Kernel with PXE

Create a directory on your TFTP directory called pxelinux.cfg now place their the config files. I have one file called default:

DEFAULT memtest
PROMPT 1
TIMEOUT 10

LABEL memtest
  MENU HIDE
  MENU LABEL memtest
  KERNEL memtest86+.bin

LABEL local
  LOCALBOOT 0

And one file with the MAC address 00-de and so on:

PROMPT 1
DEFAULT vdr
TIMEOUT 10

LABEL vdr
  MENU HIDE
  MENU LABEL ^VDR
  KERNEL vmlinuz-2.6.22-gentoo-r5-diskless
  APPEND ip=dhcp root=/dev/nfs nfsroot=192.168.0.149:/usr/local/diskless

LABEL memtest
  MENU HIDE
  MENU LABEL ^memtest86+
  KERNEL memtest.bin

Synchronize folders

rsync -az --delete --ignore-errors --numeric-ids --stats --progress /bin /usr/local/$DISKLESS/
rsync -az --exclude "*$DISKLESS*" --delete --ignore-errors --numeric-ids --stats --progress /lib /usr/local/$DISKLESS/
rsync -az --delete --ignore-errors --numeric-ids --stats --progress /sbin /usr/local/$DISKLESS/
rsync -az --exclude "/var/lib*" --exclude "/var/cache*" --exclude "/var/log*" --exclude "/var/tmp" --exclude "/var/db*" \
--exclude "/var/www" --delete --ignore-errors --numeric-ids --stats --progress /var /usr/local/$DISKLESS/
rsync -az --delete --ignore-errors --numeric-ids --stats --progress /etc /usr/local/$DISKLESS/

Related Posts