Configuring a standalone FOG VM under Ubuntu 20.04
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: [188.8.131.52] 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, 184.108.40.206 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: - 220.127.116.11 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.
@danboid Thanks for you detailed write up on setting up FOG!
I just tried to edit the first post but I was denied. Could we ditch this rule please, at least for this post?
I didn’t know the forum has such a rule. @Tom-Elliott Do you know if it’s possible to allow editing own posts for users as well?
Here is another comment: We don’t suggest running the installer via
sudodirectly because the environment variables is different on some Linux systems (and can cause issues!) compared to switching over to the root user via
sudo su -.
@danboid I don’t have rights to allow users to edit there own original posts. We may need to get one of the @Developers involved for that request. Since I’m a mod I can edit all posts using the vertical 3 dots next to the vote up button. Also understand I’m just giving you an unsolicited opinion, so take it as that (value it as nothing). I’m only suggesting that beginners might have a problem following since most have zero experience with linux also there are many that english is not their first language.
As I said before you have a well organized and clear tutorial. Don’t let that get lost in my comments.
Thanks for your feedback!
- I think I made this pretty clear in the first couple of paragraphs but I could add a bit more to say “note this is not the easiest way to install FOG”. I explain the reason for doing it in a VM in the second paragraph:
“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.”
The guide is titled “Configuring a standalone FOG VM” the VM bit being key here.
Yes, I should definitely change it to use the git repo instead. Good suggestion.
Thanks - useful advice
Yes - that would be another good thing to highlight but I do mention the role of /images already
I’m happy to make these changes but unfortunately the current forum settings don’t allow you to edit posts an hour after you’ve posted them. I just tried to edit the first post but I was denied. Could we ditch this rule please, at least for this post?
@danboid First of all let me say great job documenting the installation process on a current (at the time of writing) OS.
I do have a few comments
For new FOG Admins it may be a bit confusing why you are doing the virt-manager stuff. I fully understand why but its not clear in your documentation. And if the read doesn’t want to setup a containerized VM that they can just skip to the part of installing FOG. That part is great for both virtualized and physical fog server (minus a few of the VM container bits). Or you need to make it clear in the beginning that you are setting up a containerized VM using ubuntu and on that host (hypervisor so to speak) you will be installing FOG on a VM using that host. I guess my point is if the FOG admin that is following your guide is only copy and pasting they won’t know why and if it breaks they won’t know how to fix it.
While the tar method to install FOG is OK, I would recommend using the git method because updates can be quickly downloaded and installed with just a few commands. Its really a toss up to which method to use tarball vs git pull but there are options here.
On the fog vCPUs, that number is really dependent on the number of computers that have the fog client installed. 2 vCPUs should be sufficient for most SMB installations with 300 or less fog clients in play. The FOG Server for itself for imaging doesn’t need a lot of vCPUs. I even have FOG server running and deploying on a Raspberry Pi3 server. For the server’s standpoint the critical path is between disk and network. The fog server really doesn’t do number crunching during imaging.
When setting up the fog server its best to move the /images onto its own partition. That way when the /images partition fills up it doesn’t bring down the FOG Server. On centos (I realize you are talking ubuntu here) it will allocate 50GB for the root directory and then give /home the rest of the disk on its own partition. Again for centos I will rename /home to /images when installing centos so that all of the free disk space beyond 50GB is allocated to /images. Even better for a VM is to place /images on its own disk using a standard partition (not LVM) then you can extend the vm disk and then the partitions to make more room for images.
Overall your write up is very nicely organized and pretty clear for the beginner fog admin. Well done!