- Clone project and resources
git clone https://github.com/pypxe/PyPXE
git clone https://github.com/ipxe/ipxe.git
pip3 install pypxe
- Install requirements
apt install liblzma-dev
Create config file
cat << EOF > PyPXE/pxe.json
{
"DHCP_BROADCAST": "",
"DHCP_DNS": "8.8.8.8",
"DHCP_FILESERVER": "192.168.100.51",
"DHCP_MODE_PROXY": false,
"DHCP_OFFER_BEGIN": "192.168.100.100",
"DHCP_OFFER_END": "192.168.100.150",
"DHCP_ROUTER": "192.168.100.1",
"DHCP_SERVER_IP": "192.168.100.51",
"DHCP_SERVER_PORT": 67,
"DHCP_SUBNET": "255.255.255.0",
"DHCP_WHITELIST": false,
"HTTP_SERVER_IP": "192.168.100.51",
"HTTP_PORT": 80,
"LEASES_FILE": "",
"MODE_DEBUG": "",
"MODE_VERBOSE": "",
"NBD_BLOCK_DEVICE": "",
"NBD_COPY_TO_RAM": false,
"NBD_COW": true,
"NBD_COW_IN_MEM": false,
"NBD_PORT": 10809,
"NBD_SERVER_IP": "0.0.0.0",
"NBD_WRITE": false,
"NETBOOT_DIR": "./netboot",
"NETBOOT_FILE": "",
"STATIC_CONFIG": "",
"SYSLOG_PORT": 514,
"SYSLOG_SERVER": null,
"TFTP_PORT": 69,
"TFTP_SERVER_IP": "",
"USE_DHCP": true,
"USE_HTTP": true,
"USE_IPXE": true,
"USE_TFTP": true
}
EOF
- Create ipxe boot file and boot ipxe script
cat << EOF > ipxe/src/boot.ipxe
#!ipxe
dhcp
chain --replace http://192.168.100.51/scripts/script.ipxe
boot
EOF
mkdir PyPXE/netboot/scripts
mkdir PyPXE/netboot/images/clonezilla -p
cat << EOF > PyPXE/netboot/scripts/script.ipxe
#!ipxe
set boot-url http://192.168.100.51/images
kernel ${boot-url}/clonezilla/vmlinuz boot=live config noswap nolocales edd=on nomodeset vga=788 nosplash noprompt fetch=http://10.20.20.51/clonezilla/filesystem.squashfs
initrd ${boot-url}/clonezilla/initrd.img
boot
EOF
- Download and unzip clonezilla ISO
wget https://freefr.dl.sourceforge.net/project/clonezilla/clonezilla_live_stable/3.1.3-16/clonezilla-live-3.1.3-16-amd64.iso
mkdir /tmp/mount
mount -o loop clonezilla-live-3.1.3-16-amd64.iso /tmp/mount
rsync -avr /tmp/mount/live/ pyPXE/netboot/images/clonezilla
- Add PyPXE ipxe boot script to kpxe boot file
make bin/undionly.kpxe EMBED=boot.ipxe
cp bin/undionly.kpxe /home/debian/PyPXE/netboot/ipxe.kpxe
sed -i s#chainload.kpxe#ipxe.kpxe#g PyPXE/pypxe/dhcp.py
- Start server
cd PyPXE
sudo python3 -m pypxe.server --config pxe.json --debug all,-dhcp