Diskless Machine(PxE boot)

What is PxE ?

PxE is a way of booting OS kernel over the network rather than from disk. It consist of one or more PxE servers which holds all kernel and initial ramdisk image. And PxE clients which are actual host where user application and services start. It is depicted in the Figure-1. PxE server running tftp and dhcp services. It is only necessary to PxE supported NIC on the client side. I will use Arch Linux as a PxE server. It is the one of the most lightweight and flexible  Linux distribution. I will use CentOS6 kernel image for the PxE client.

First think we need to install necessary packages on the PxE server.

[root@archbox netctl]# pacman -S tftp-hpa
[root@archbox netctl]# systemctl enable tftpd.service
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/tftpd.service.
[root@archbox netctl]# systemctl start tftpd.service

Installing dhcp:

You may get an error on the starting dhcpd4 service due to the fact that we have not configured yet the service.

[root@archbox netctl]# pacman -S dhcpd
[root@archbox netctl]# systemctl enable dhcpd4.service
[root@archbox netctl]# systemctl start dhcpd4.service

Installing NFS:

There are many options to boot the kernel over network such as NFS, HTTP, iSCSI etc. We will boot the host via NFS.

[root@arch2 etc]# pacman -S nfs-utils
[root@arch2 etc]# systemctl enable nfs-server.service 
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/nfs-server.service.
[root@arch2 etc]# systemctl start nfs-server.service 

Installing Syslinux Syslinux is a packages that contains plenty of boot-loaders such as SYSLINUX (FAT filesystem bootloader), EXTLINUX (ext2/3/4 , btrfs and xfs filesystem bootloader), PXELINUX (Network PXE bootloader) and ISOLINUX (ISO-9660) for CD/DVD bootloading.

Configuration on the PxE Server:


[root@arch2 ~]# cat /etc/dhcpd.conf
allow booting;
allow bootp;
option domain-name-servers,;
option subnet-mask;
option routers;
subnet netmask {
filename "pxelinux.0";


As indicated before /srv/tftp the root directory of the tftp server. So all necessary configurations such as OS kernel images, initial ram disk images to boot over network will be stored in this (sub)directories.

[root@arch2 syslinux]# pwd
[root@arch2 syslinux]# ls -ltr
total 16
drwxr-xr-x 2 root root 4096 Jan 14 20:47 efi32
drwxr-xr-x 2 root root 4096 Jan 14 20:47 efi64
drwxr-xr-x 2 root root 4096 Jan 14 20:47 diag
drwxr-xr-x 2 root root 4096 Jan 14 20:47 bios

In order for properly booting the kernel over network we need to copy some syslinux binaries to the /srv/tftpboot.

[root@arch2 syslinux]# cp /usr/lib/syslinux/bios/pxelinux.0 /srv/tftp
[root@arch2 syslinux]# cp /usr/lib/syslinux/bios/menu.c32 /srv/tftp
[root@arch2 syslinux]# cp /usr/lib/syslinux/bios/libutil.c32 /srv/tftp
[root@arch2 syslinux]# cp /usr/lib/syslinux/bios/ldlinux.c32 /srv/tftp

we also need to create a special folder named pxelinux.cfg under /srv/tftp which holds configuration for the grub-like menu. There is a directory named rhce6 under the /srv/tftp which holds our PxE client kernel and initrd image.

#For more information see /usr/share/doc/syslinux/pxelinux.txt

[root@arch2 syslinux]# mkdir -p /srv/tftp/pxelinux.cfg
[root@arch2 syslinux]# cat << EOF > /srv/tftp/pxelinux.cfg/default
default menu.c32
 timeout 30
 prompt 1

 label diskless6
 kernel /rhce6/vmlinuz-2.6.32-696.10.3.el6.x86_64
 append initrd=/rhce6/netboot6.img rw root=nfs: selinux=0 enforcing=0


NFS server will be used to mounting root (/) file by the kernel. All our applications and OS configurations live here. So I created a folder named diskless/rhce6 under the /srv.

[root@arch2 rhce6]# cat /etc/exports
/srv/diskless/rhce6 *(rw,no_root_squash,no_subtree_check)

Creating a special initrd for the PxE client.

Here is the magic comes in. It is very important that we need to create initrd image that is able to mount the root (/) by using NFS protocol. By the way we do not do it on the PxE server. I have a running CentOS6 machine which has the same kernel version as the host that will be used as PxE client.

We need to install dracut-network package.

[root@node01 ~]# yum install dracut-network

Creating a initrd image:

[root@node01 ~]# dracut -f /boot/netboot6.img `uname -r` root=dhcp root-path=nfs:

Only thing that we need to do is, copying the kernel image(vmlinuz) and initrd(in this case netboot6.img) to /srv/tftp/rhce6

[root@arch2 rhce6]# pwd
[root@arch2 rhce6]# ls
netboot6.img  vmlinuz-2.6.32-696.10.3.el6.x86_64

Copying images to the PxE Server:

We need to copy CentOS root(/) folder to the PxE server. And PxE server serve this place as nfs export.

[root@node01 ~]# rsync -vaHAXSz --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / [email protected]:/srv/diskless/rhce6

Changing Hostname:

[root@arch2 ~]# cat /srv/diskless/rhce6/etc/sysconfig/network

fstab We need to modify fstab suitable for the PxE boot.

[root@arch2 ~]# cat /srv/diskless/rhce6/etc/fstab  /            nfs     defaults       1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0


I configured PxE client IP as dhcp which automatically given an IP by the dhcp server.

[root@arch2 ~]# cat /srv/diskless/rhce6/etc/sysconfig/network-scripts/ifcfg-eth0 

PxE client Options:

Create a New Virtual Machine on the KVM and choose “Network Boot(PXE)”

Chose interface device model virtio in the NIC section.


Finally I am ready to fire my virtual guest without adding a disk.

Disk Status


That’s all for now. Happy booting 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.