=Install Dependencies= apt-get install dnsmasq nfs-kernel-server pxelinux syslinux =Host configuration= Use eth1 to boot diskless client as example. Setup eth1 address to 192.168.101.1/24, and gateway to 192.168.101.1 Create directories: mkdir -p /srv/tftp mkdir -p /srv/ubunturootfs Edit /etc/dnsmasq.conf:
interface=eth1 bind-interfaces dhcp-boot=pxelinux.0 tftp-root=/srv/tftp/Restart dnsmasq: systemctl restart dnsmasq Edit /etc/exports, add lines below: /srv/ubunturootfs 192.168.101.0/24(rw,sync,no_root_squash) Make NFS changes effect: exportfs -a =Prepare client rootfs= Create rootfs: debootstrap --arch=amd64 xenial /srv/ubunturootfs http://cn.archive.ubuntu.com Setup rootfs: mount --bind /dev /srv/ubunturootfs/dev mount --bind /proc /srv/ubunturootfs/proc mount --bind /sys /srv/ubunturootfs/sys chroot /srv/ubunturootfs passwd root #Setup your root password apt-get install linux-image-generic Edit /etc/initramfs-tools/initramfs.conf in chroot: MODULES=netboot BOOT=nfs Update initramfs: update-initramfs -u Exit from chroot environment of rootfs: exit umount /srv/ubunturootfs/dev umount /srv/ubunturootfs/proc umount /srv/ubunturootfs/sys Copy kernel & initramfs to TFTP directory: cp /srv/ubunturootfs/boot/vmlinuz* /srv/tftp/ cp /srv/ubunturootfs/boot/initram* /srv/tftp/ cp /usr/lib/PXELINUX/pxelinux.0 /srv/tftp mkdir -p /srv/tftp/pxelinux.cfg Edit /srv/tftp/pxelinux.cfg/default
DEFAULT linux LABEL linux LINUX /vmlinuz-4.4.0-21-generic #Replace kernel image with real vmlinuz file name APPEND root=/dev/nfs initrd=initrd.img-4.4.0-21-generic nfsroot=192.168.101.1:/srv/ubunturootfs ip=dhcp rw #Replace initramfs file with real initrd.img file name