Guide to creating a self replicating PXE system


The goal of this guide to help you boot a clone
of your linux system on a other system via PXE/NFS using
open source tools.

This guide assumes you know how to compile a kernel and make
an initrd image.


It is far easier to maintain one version of an operating system
and have it boot and run over the network then optionally load into the memory
when you have hundreds of nodes.
It can also be used to pxe boot a computer without cdrom/usbboot
and then qemu a windows install, the possibilities are really endless.
I made this to be useful for clusters, diskless workstations, and system repairs.


While this guide covers only the basics I hope it soon supports a
a bunch of cool features like loading most functions into ram
and grabbing applications/ect over the network if not included in
ram copy of OS.


All this stuff can probably be done with a million different
programs, or just one like dnsmasq, however I am using:

   ISC DHCPD v3.0.6 (isc.org)
   tftpserversp 1.6rc (tftp-server.sourceforge.net)
   syslinux (more specifically pxelinux)
   latest linux kernel (kernel.org)
   nfs-utils-1.1.4 (nfs.sourceforge.net)
   qemu/kqemu (recommended to boot OSs than Linux. qemu.org)


I have had a LOT of trouble getting any realtek 8139 network cards to allow
DHCP clients to connect or let alone register the cable. The network card
in a compaq presario v6000 doesn't work either, the only card I've had
any luck with is the Broadcom BCM4401-B0 100Base-TX ethernet controller.
Please note this is server side only and shouldn't affect the 'cloned' system.

Any rackmount setup should have better NICs, so you shouldn't worry, but a DHCP test
is advised before you go too far....

*WARNING: Following these steps will give
you a very insecure system, please know exactly what you are
doing and perform all of this behind a firewall (or better yet, disconnected from the internet).
THE 'client'/'cloned' systems will mount the 'master' node's root filesystem
there is always the possibility for catastrophic failure, simple conflicts like /var/lock, and such good stuff.
I'm working on scripts to take care of most stuff... Contact me for more information!


( 1) Get /etc/dhcpd.conf example and run ifconfig eth0 up ; dhcpd eth0
( 2) Run tftpserver (its defaults are fine)
( 3) Run mkdir /home/PXEClient
( 4) Run mkdir /home/PXEClient/pxelinux.cfg
( 5) Get /home/PXEClient/pxelinux.cgi/default example
( 6) Copy pxelinux to /home/PXEClient/pxelinux
( 7) Edit /etc/exports to include: /,no_squash_root)
( 8) Start NFS server using rc.nfs (or maybe exportfs -r, rpc.rquota, rpc.mountd, rpc.nfs 8, exportfs)
( 9) Compile kernel with initrd & nfs support (make menuconfig ; make bzimage ; make modules ; make modules_install ; echo if you forgot....)
(10) Copy kernelsource/arch/x86/boot/bzImage to /home/PXEClient/bzimage
(11) Make initrd to include all basics and dhcpcd
( I) Slackware/others try mkinitrd -c -k kernelversion -m ext3:nfs:networkcard -f nfs -r
( II) cp /sbin/dhcpcd to /boot/initrd-tree also /lib/libc.* and /lib/ld-linux.* if ldd says so (most likely)
(III) modify init/linuxrc to include 'dhcpcd eth0' BEFORE mount, also comment out any CRYPT/LVM/RESTORE stuff
you might need to hard code "mount -o rw,nolock -t nfs /mnt" instead of
mount command already in there, especially if receiving "RPC" errors at boot time.
( IV) run mkinitrd again
(12) Copy initrd to /home/PXEClient/initrd.gz
*You may find your self needing to reset the NFS server if you let the
client system gracefully shutdown, also you might wanna
 run touch /etc/fastboot

Thats it, you should now be able to boot clone
systems via PXE/NFS!

Chrooted NFS exports are a good start to securing
the system, however brutal my approach, it will save you
hundreds of megabytes of storage space.

I made this document because someone wanted me to reinstall
windows to a laptop with a broken CD drive, and PXE as the only
other boot option. Using my USB slackware disbtro
I booted off a USB stick on my brothers computer,
PXE cloned it to the broken computer, ran qemu with USB Windows Install CD, and viola!
As it happened around the same time someone wanted me to get their 12 node, 26 processor,
machine running as a cluster, so I said why not!

Some pictures to go with the project:

I am for hire, just in case your were wondering....

Created: May 23, 2009

Copyleft Karlan Thomas Mitchell 2009

Site: Karlan Mitchell (C) 2010

Valid XHTML 1.0 Transitional Valid CSS!