Configuring a standalone FOG VM under Ubuntu 20.04
by Dan MacDonald
FOG (Free Open Ghost) makes it quick and easy to deploy Windows, Linux or macOS images over a wired network using iPXE, partclone, apache and other open source software under the hood. The aim of this guide is to set up a FOG server running in a Ubuntu Server 20.04 VM hosted by qemu running on Ubuntu 20.04. I use virt-manager to simplify the process of creating and managing the VM.
This server will be running its own DHCP and DNS servers so that all you will need is your FOG VM, a switch and some ethernet cables to image machines. FOG and its required services (like DHCP and DNS servers) are things I don’t usually want to be running on my laptop or workstation which is why it’s useful to have FOG running inside of a VM so you can quickly fire it up as and when it’s needed.
User groups for virt-manager
If you want to run virt-manager as a normal user, make sure your user is in both the kvm and libvirt groups. Remember you need to log out and back in after adding your user to a group before it takes effect.
Create bridge interface on host machine
When you install virt-manager a virbr0 network bridge is created but this doesn’t work to host a FOG server. Instead we need to create a bridge interface, br0, by editing /etc/netplan/01-network-manager-all.yaml to look like this:
network: version: 2 renderer: networkd ethernets: enp0s31f6: dhcp4: false dhcp6: false bridges: br0: interfaces: [enp0s31f6] addresses: [192.168.0.33/24] gateway4: 192.168.0.1 mtu: 1500 nameservers: addresses: [220.127.116.11] parameters: stp: true forward-delay: 4 dhcp4: no dhcp6: no
Make sure you at least modify enp0s31f6 above to match the wired interface name on your host machine - run ip l to list your network interfaces. You will need to reboot for the new network config to take effect.
Note that using this netplan config will switch your Ubuntu box from using NetworkManager to using networkd, which is part of systemd. Whilst this will get FOG working, it also has the effect of breaking the network applets used by most Linux desktops because they nearly all use NM behind the scenes.
It is possible to configure netplan to connect to wifi when using systemd but its not as simple as when using the NM applet. It is also possible to connect to wifi using wpasupplicant and wpa_gui whilst using networkd but I have not tested those with networkd yet. I’ll only be using the above networkd bridge config on my laptop when using FOG and use default Ubuntu NM config the rest of the time for easier wifi access.
Create a FOG VM
Download the Ubuntu Server 20.04 install image. Ubuntu 20.04 has the advantage over Debian 10 or RHEL 8 in that its kernel and qemu packages are recent enough to enable you to use Virtio-FS to share the hosts disk with the VM if your host supports NUMA. It is still possible to use Virtio-FS without NUMA but that requires qemu 5.x and Ubuntu 20.04 ships qemu 4.2.
When creating the FOG VM in virt-manager, I assigned it 4 GB RAM and 4 VCPUs. You could get away with as little as 512 MB RAM, 1 VCPU and a 4 GB disk for your FOG VM and it should still run, if you don’t install any other software and you have the /images directory hosted elsewhere but generally you will want to make the VM disk as large as possible. You can easily use 200 GB imaging a modern Windows 10 box with a few big apps installed. On the last step of creating a new VM in virt-manager, for the Network selection I chose the option “Bridge br0: Host device enp0s31f6”.
I find it easier to configure a static IP using the Ubuntu server installer so choose the Manual network configuration. For your FOG servers subnet you will likely want to use something like 192.168.0.0/24. I used 192.168.0.44 for the address, 18.104.22.168 for the nameserver and my gateway is 192.168.0.1. If you skipped the manual network config screen of the Ubuntu Server installer, you can alternately edit /etc/netplan/00-installer-config.yaml to look like this:
network: ethernets: enp1s0: addresses: - 192.168.0.44/24 gateway4: 192.168.0.1 nameservers: addresses: - 22.214.171.124 version: 2
I used the Ubuntu server guided disk defaults, using the whole disk. It’s debatable how much use LVM is when used in VMs, its much easier to resize disks without it but its the default in Ubuntu server.
On the Ubuntu server Profile Setup page, enter fog-server for the server name. Install the SSH server but don’t install any of the server snaps and cancel the updates at the end, we’ll update after booting into our newly installed VM.
FOG VM configuration
Reboot and login to your FOG server VM. Ubuntu server installs extra packages we don’t need so lets update then get rid of them:
$ sudo apt update && sudo apt upgrade $ sudo apt remove bcache-tools btrfs-progs cloud-guest-utils cloud-initramfs-copymods cloud-initramfs-dyn-netconf xfsprogs lxd-agent-loader open-iscsi open-vm-tools $ sudo apt autoremove
Then we’ll download and extract the latest FOG release:
$ wget https://github.com/FOGProject/fogproject/archive/1.5.9.tar.gz $ tar xvf 1.5.9.tar.gz
This is a good point to create a snapshot of your VM should you mess any of the following steps up and need to start over.
$ sudo ~/fogproject-1.5.9/bin/installfog.sh
Option 2 for Ubuntu packages
N for Normal installation
Don’t change the default network interface
Say Yes to setting up a router address for the DHCP server then enter your gateway (‘router’ - in my case its 192.168.0.1)
Say Yes to DHCP to handle DNS
For What DNS address should DHCP allow? Accept the default
Say Yes to Would you like to use the FOG server for DHCP service?
Say no to the language packs unless you want them
Say no to enabling HTTPS unless you want to configure that. I’m not covering that here.
Don’t change the hostname if already set to fog-server
The script will then download, install and configure the required packages. You will be required to click on a link or two to finish setting up the FOG database midway through the install script. Once the FOG install script has finished you can detach the host from the internet but still use FOG when its VM is running.