Booting Debian Bookworm PXE using NFS root filesystem
This article covers the process of setting up a network-based installation of Debian Bookworm using Preboot Execution Environment (PXE) and Network File System (NFS) for the root filesystem. By the end of this article, you will have a solid understanding of the key concepts and subtopics related to booting Debian Bookworm with a PXE-NFS root filesystem configuration.
Prerequisites
Ensure that you have access to a Debian Bookworm installation media or an existing Debian system. You'll need a DHCP (Dynamic Host Configuration Protocol) and TFTP (Trivial File Transfer Protocol) server to provide the necessary boot files and network configuration.
Setting up the DHCP Server
Configure the DHCP server to provide the IP address of the PXE server and the location of the boot file. Add the following lines to the DHCP server's configuration (e.g., /etc/dhcp/dhcpd.conf):
subnet 192.168.70.0 netmask 255.255.255.0 {
option broadcast-address 192.168.70.255;
option routers 192.168.70.1;
option domain-name-servers 192.168.70.1;
next-server 192.168.70.1;
filename "pxelinux.0";
}
Configuring the TFTP Server
Install the tftpd-hpa package on the Debian system that will act as the PXE server:
apt-get install tftpd-hpa
Then, create the directory for the TFTP files:
mkdir -p /srv/tftp/boot/
Creating the PXE Boot File
Download the SYSLINUX package, extract it, and copy the pxelinux.0 file to the TFTP directory:
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz
tar xf syslinux-6.03.tar.xz
cp syslinux-6.03/core/pxelinux.0 /srv/tftp/boot/
Configuring the NFS Server
Install the nfs-kernel-server package:
apt-get install nfs-kernel-server
Create the NFS Export directory:
mkdir -p /srv/nfs/clients
Update the /etc/exports file:
/srv/nfs/clients 192.168.70.0/24(rw,sync,no_subtree_check,no_root_squash)
Building the Debian Bookworm RAM Disk
Download and extract the Debian Bookworm netinst installation media. Then, create a new directory to mount the squashfs filesystem. Mount the filesystem and copy the necessary files:
mkdir -p /mnt/squashfs
mount -t squashfs debian-bookworm-netinst-amd64.iso /mnt/squashfs
cp -a /mnt/squashfs/install.amd/initrd.gz /
umount /mnt/squashfs
Preparing the Initramfs
Create the initramfs.cpio.gz file:
cd /
mkdir -p initramfs
cp -a /initrd.gz initramfs/
cd initramfs
gunzip -c ../initrd.gz | cpio -H newc -id
Modify the /init file by adding the following lines:
#!/bin/sh
# Add the following lines after #!/bin/sh
mount -t nfs 192.168.70.1:/clients /root
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
chroot /root /init
Ker
Booting Debian Bookworm PXE using NFS root filesystem
Booting Debian Bookworm PXE using NFS root filesystem
This article covers the process of setting up a network-based installation of Debian Bookworm using Preboot Execution Environment (PXE) and Network File System (NFS) for the root filesystem. By the end of this article, you will have a solid understanding of the key concepts and subtopics related to booting Debian Bookworm with a PXE-NFS root filesystem configuration.
Prerequisites
Ensure that you have access to a Debian Bookworm installation media or an existing Debian system. You'll need a DHCP (Dynamic Host Configuration Protocol) and TFTP (Trivial File Transfer Protocol) server to provide the necessary boot files and network configuration.
Setting up the DHCP Server
Configure the DHCP server to provide the IP address of the PXE server and the location of the boot file. Add the following lines to the DHCP server's configuration (e.g., /etc/dhcp/dhcpd.conf):
subnet 192.168.70.0 netmask 255.255.255.0 {
option broadcast-address 192.168.70.255;
option routers 192.168.70.1;
option domain-name-servers 192.168.70.1;
next-server 192.168.70.1;
filename "pxelinux.0";
}
Configuring the TFTP Server
Install the tftpd-hpa package on the Debian system that will act as the PXE server:
apt-get install tftpd-hpa
Then, create the directory for the TFTP files:
mkdir -p /srv/tftp/boot/
Creating the PXE Boot File
Download the SYSLINUX package, extract it, and copy the pxelinux.0 file to the TFTP directory:
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz
tar xf syslinux-6.03.tar.xz
cp syslinux-6.03/core/pxelinux.0 /srv/tftp/boot/
Configuring the NFS Server
Install the nfs-kernel-server package:
apt-get install nfs-kernel-server
Create the NFS Export directory:
mkdir -p /srv/nfs/clients
Update the /etc/exports file:
/srv/nfs/clients 192.168.70.0/24(rw,sync,no_subtree_check,no_root_squash)
Building the Debian Bookworm RAM Disk
Download and extract the Debian Bookworm netinst installation media. Then, create a new directory to mount the squashfs filesystem. Mount the filesystem and copy the necessary files:
mkdir -p /mnt/squashfs
mount -t squashfs debian-bookworm-netinst-amd64.iso /mnt/squashfs
cp -a /mnt/squashfs/install.amd/initrd.gz /
umount /mnt/squashfs
Preparing the Initramfs
Create the initramfs.cpio.gz file:
cd /
mkdir -p initramfs
cp -a /initrd.gz initramfs/
cd initramfs
gunzip -c ../initrd.gz | cpio -H newc -id
Modify the /init file by adding the following lines:
#!/bin/sh
# Add the following lines after #!/bin/sh
mount -t nfs 192.168.70.1:/clients /root
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
chroot /root /init
Kernel Command Line
To boot the system using PXE-NFS, use the following kernel command line options:
root=/dev/nfs nfsroot=192.168.70.1:/clients,ro ip=dhcp
This article has demonstrated how to set up a Debian Bookworm PXE-NFS root filesystem for network-based installations. By following the steps described, you will be able to provide a streamlined and automated installation experience for Debian Bookworm.