Skip to content

Instantly share code, notes, and snippets.

@eirikb eirikb/0-PXE-VDI-LTSP.md
Last active May 18, 2018

Embed
What would you like to do?
Host VDI / VMDK (VirtualBox images) directly over PXE (Network boot).

PXE Boot VDI/VMDK over network

This is an example script of how to host VDI / VMDK (VirtualBox images) directly over PXE (Network boot).  
Example relies on LTSP.  

Client

Can be any distro, but requires ltsp-client-core, example with Debian:

sudo apt-get -y install ltsp-client-core
sudo /usr/share/ltsp/update-kernel

If testing/building with VirtualBox remember to properly shutdown the machine (shutdown -h now).

If you want DHCP from a second interface, this should do the trick upon boot inside the PXE client:

 sudo ip route del default
 sudo ip link set up dev enp0s3
 sudo dhclient enp0s3

install.sh

Run the install.sh-file on a Debian (tested on 9) box, VirtualBox should work fine. enp0s8 is the second interface on my vbox test, you probably have to change this. Both server and client supports multiple interfaces.

#!/usr/bin/env bash
sudo apt-get -y install ltsp-server-standalone qemu-utils
sudo modprobe nbd
sudo qemu-nbd -c /dev/nbd0 -P 1 ~/client.vdi
sudo mkdir -p /opt/ltsp/images
sudo ln -s /dev/nbd0 /opt/ltsp/images/amd64.img
sudo chown nbd /opt/ltsp/images/amd64.img
# Force ltsp-update-kernels to recognize symbolic links
sudo sed -i 's/ -f / -e /g' /usr/sbin/ltsp-update-kernels
# Mount and un-mount for unknown reason (or else ltsp-update-kernel will throw "cannot mount: /dev/loop0 read-only)
sudo mount /dev/nbd0 /mnt
sudo umount /mnt
sudo ltsp-update-kernels amd64
sudo ltsp-config dnsmasq --no-proxy-dhcp
sudo tee -a /etc/nbd-server/config <<EOF
[/opt/ltsp/amd64]
exportname = /opt/ltsp/images/amd64.img
EOF
sudo ip link set up dev enp0s8
sudo ip addr add 192.168.67.1/24 dev enp0s8
sudo systemctl restart dnsmasq
sudo systemctl restart nbd-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.