├── README.md └── TFTP ├── chain.c32 ├── installers └── ubuntu │ ├── trusty │ └── amd64 │ │ ├── initrd.gz │ │ └── linux │ ├── wily │ └── amd64 │ │ ├── initrd.gz │ │ └── linux │ └── xenial │ └── amd64 │ ├── initrd.gz │ └── linux ├── kickstart └── basic.cfg ├── ldlinux.c32 ├── libcom32.c32 ├── libutil.c32 ├── menu.c32 ├── pxelinux.0 └── pxelinux.cfg └── default /README.md: -------------------------------------------------------------------------------- 1 | # VirtualBox + PXE Boot + Kickstart example 2 | 3 | [VirtualBox](https://www.virtualbox.org/wiki/Downloads) support PXE (network booting) out of the box with minimal configuration and no extra software or servers. 4 | 5 | This repo contains some basic starter files you can use to bootstrap your VirtualBox PXE boot setup faster. 6 | 7 | ## Requirements 8 | 9 | * VirtualBox is installed and works 10 | * Create a VM you will use to test the PXE boot setup 11 | 12 | ## VM Settings 13 | 14 | In order for PXE booting to work with the builtin server in Virtualbox you need to configure your VM's network settings and boot order properly. 15 | 16 | * Set the VM to use the NAT networking (Network -> Adapter 1 -> Attached to: NAT). 17 | 18 | * Set the VM to boot from network (System -> Motherboard -> Boot Order). Alternatively, you can use F12 in the booting VM to load the boot menu. For testing PXE and kickstart configs, I found that changing the boot order was easier. 19 | 20 | ## Setup PXE boot files 21 | 22 | Unfortunately VirtualBox does not provide any PXE boot configuration files and only provides a way to serve those files. 23 | 24 | To make it easier, I have provided all of the files needed in this repo in the TFTP folder. Copy everything in TFTP folder of this repo to the VirtualBox storage directory. Depending on your system it will be in a different location. 25 | 26 | On OSX it is `~/Library/Virtualbox/TFTP` 27 | On Linux it is `~/.config/VirtualBox/TFTP/` 28 | 29 | Note: You may have to create this directory if it doesn't exist. 30 | 31 | One liner to download and extract the TFTP folder 32 | ```shell 33 | curl https://codeload.github.com/defunctzombie/virtualbox-pxe-boot/tar.gz/master | tar zx --strip-components 1 34 | ``` 35 | 36 | ## Symlink pxelinux.0 to vmname.pxe 37 | 38 | From the Virtualbox Docs 39 | 40 | > 6.3.2. PXE booting with NAT 41 | > PXE booting is now supported in NAT mode. The NAT DHCP server provides a boot file name of the form vmname.pxe if the directory TFTP exists in the directory where the user's VirtualBox.xml file is kept. It is the responsibility of the user to provide vmname.pxe. 42 | 43 | What this means is that in order for VirtualBox to actually PXE boot your machine, it will look for a file called vmname.pxe (where vmname is the name of your virtual machine). Avoid spaces or other special characters in vm names. 44 | 45 | On my system, I created a vm called `test` so I would then make a symlink called `test.pxe` to `pxelinux.0` 46 | 47 | ```shell 48 | ln -s ./pxelinux.0 test.pxe 49 | ``` 50 | 51 | ## Boot the VM 52 | 53 | Click boot and if all went well, you will see a menu with two entries: 54 | 55 | * Install 56 | * Kickstart Install 57 | 58 | Select either one to try it out! 59 | 60 | ## Further config 61 | 62 | At this point the PXE booting works and you see a menu with two example items I have provided. That is the main extent of this guide however here are some more details about the menu items and configuration. 63 | 64 | The menu entries are configured in `TFTP/pxelinux.cfg/default`. This is just a text file. Open it and you will find that the menu entry items look similar to grub boot item lines. 65 | 66 | The `Install` menu entry simply boots the Ubuntu wily amd64 installer. The kernel and initrd files were both downloaded from the [ubuntu ftp archive][1] and placed in the `installers/ubuntu/wily/amd64/` directory. In this way you could support many different OS versions and vendors. 67 | 68 | The `Kickstart Install` is identical to the `Install` entry except that it provides a [kickstart](https://en.wikipedia.org/wiki/Kickstart_(Linux)) config file to automate the install process. Kickstart stuff is outside of the scope of this guide, but suffice to say you can automate basically any part of the install. 69 | 70 | NOTE: The kickstart file is retrieved via HTTP. For the examples here I simply put the kickstart file from `kickstart/basic.cfg` on pastebin so that no extra HTTP server is needed. For testing this is usually sufficient but for production setups you will need to serve your kickstart files via some http server. 71 | 72 | ## References 73 | * https://gist.github.com/jtyr/816e46c2c5d9345bd6c9 74 | 75 | [1]: http://ftp.ubuntu.com/ubuntu/dists/wily/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/ 76 | -------------------------------------------------------------------------------- /TFTP/chain.c32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/chain.c32 -------------------------------------------------------------------------------- /TFTP/installers/ubuntu/trusty/amd64/initrd.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/installers/ubuntu/trusty/amd64/initrd.gz -------------------------------------------------------------------------------- /TFTP/installers/ubuntu/trusty/amd64/linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/installers/ubuntu/trusty/amd64/linux -------------------------------------------------------------------------------- /TFTP/installers/ubuntu/wily/amd64/initrd.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/installers/ubuntu/wily/amd64/initrd.gz -------------------------------------------------------------------------------- /TFTP/installers/ubuntu/wily/amd64/linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/installers/ubuntu/wily/amd64/linux -------------------------------------------------------------------------------- /TFTP/installers/ubuntu/xenial/amd64/initrd.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/installers/ubuntu/xenial/amd64/initrd.gz -------------------------------------------------------------------------------- /TFTP/installers/ubuntu/xenial/amd64/linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/installers/ubuntu/xenial/amd64/linux -------------------------------------------------------------------------------- /TFTP/kickstart/basic.cfg: -------------------------------------------------------------------------------- 1 | lang en_US 2 | langsupport en_US 3 | keyboard us 4 | timezone America/Los_Angeles 5 | rootpw --disabled 6 | reboot # reboot after install 7 | text # text mode install 8 | install 9 | url --url http://us.archive.ubuntu.com/ubuntu 10 | 11 | bootloader --location=mbr 12 | zerombr yes 13 | clearpart --all --initlabel 14 | part /boot --fstype ext2 --size 250 15 | part /boot/efi --fstype vfat --size 512 16 | part swap --recommended 17 | part / --fstype ext4 --size 1 --grow 18 | 19 | auth --useshadow --enablemd5 20 | firewall --disabled 21 | 22 | # no automatic updates 23 | preseed pkgsel/update-policy select none 24 | 25 | # don't install recommended packages automatically 26 | preseed base-installer/install-recommends boolean false 27 | 28 | #Do not configure the X Window System 29 | skipx 30 | #Install packages we need for post install script 31 | %packages 32 | wget 33 | openssh-server 34 | vim 35 | 36 | %post --interpreter=/bin/bash 37 | %end 38 | -------------------------------------------------------------------------------- /TFTP/ldlinux.c32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/ldlinux.c32 -------------------------------------------------------------------------------- /TFTP/libcom32.c32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/libcom32.c32 -------------------------------------------------------------------------------- /TFTP/libutil.c32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/libutil.c32 -------------------------------------------------------------------------------- /TFTP/menu.c32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/menu.c32 -------------------------------------------------------------------------------- /TFTP/pxelinux.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/defunctzombie/virtualbox-pxe-boot/f76c0b13090759ea84f524b28340be4a6ef1c1ab/TFTP/pxelinux.0 -------------------------------------------------------------------------------- /TFTP/pxelinux.cfg/default: -------------------------------------------------------------------------------- 1 | PROMPT 0 2 | NOESCAPE 0 3 | ALLOWOPTIONS 0 4 | TIMEOUT 100 5 | 6 | DEFAULT menu.c32 7 | 8 | MENU TITLE [ Boot Menu ] 9 | 10 | LABEL install 11 | menu default 12 | menu label ^Install 13 | kernel installers/ubuntu/wily/amd64/linux 14 | append vga=normal initrd=installers/ubuntu/wily/amd64/initrd.gz 15 | 16 | # example here uses raw file from github 17 | LABEL install 18 | menu label ^Kickstart Install 19 | kernel installers/ubuntu/wily/amd64/linux 20 | append vga=normal initrd=installers/ubuntu/wily/amd64/initrd.gz ks=http://pastebin.com/raw/7BPDWJuX 21 | --------------------------------------------------------------------------------