Prep
Head on over to ubuntu and grab an iso. I chose ubuntu-18.04.1-live-server-amd64.iso, but by the time you’re reading this there is probably something newer.
Burn the ISO to a USB disk or a DVD if you’re feeling particularly patient.
To LVM or not to LVM
At this point many guides will recommend you partition your disk with LVM and install your host OS on top of that. That is entirely unnecessary. I recommend you not do that right now unless you’re a super LVM fanboy. It’s just an extra thing to learn and manage and you have more important things to get to. That said, if you only have one disk, then you’ll certainly want to partition your disk with enough space left over for your guest OSes.
Install Xen
When you have completed the wizard and are left staring into the eyes of that dapper bionic beaver, install the universe repository and Xen.
sudo apt-add-repository universe sudo apt-get install xen-hypervisor-amd64
Reboot!
Congratulations, you’re running Xen. Don’t believe me? Run this command to check.
# This command should show Domain-0 with a state ofr------
# which I can only assume means... running like afeistybionic beaver. sudo xl list
What’s going on here?
Here are some terms you might be interested in:
Domain-0 or Dom0 is your Xen host.
Domain-U or DomU is a Xen guest.
Network the network
Before we can get all intrepid with our beaver we need to tweak the network. Xen supports a quantal quetzal of different networking approaches, but bridging is the most popular. In this approach Xen’s internal network will be bridged to the host’s network. Guest OSes will show up as unique hosts (read: unique mac addresses) on your Xen host’s network.
Did you know your maverick bionic beaver replaced ifupdown with netplan? Technically it was her artful friend, but who’s keeping score?
# Note: this file doesn't exist yet sudo nano /etc/netplan/01-netcfg.yaml
You hipsters can use vi
if you prefer.
network: version: 2 renderer: networkd ethernets: enp3s0: dhcp4: no dhcp6: no bridges: xenbr0: interfaces: [ enp3s0 ] dhcp4: no dhcp6: no addresses: [ 192.168.1.10/24 ] gateway4: 192.168.1.1 nameservers: addresses: [ 192.168.1.1 ]
The above snippet will create a new bridge named xenbr0 (preferably pronounced: /zenbrō/) with a static IP address, netmask, gateway and nameserver. All of those fields are important. Apply the changes and validate.
sudo netplan apply ping commitstrip.com
Is your beaver feeling breezy bionic? If not, you may have some other files in /etc/netplan that are conflicting with your setup. Excellent. Proceed.
Remembering the Memory
One of the great features about Xen is that you can over-provision your guests. In other words, if you have 32GB of physical RAM installed in your server, you can assign 32GB of virtual RAM to each of 10 guest OSes. If the guests don’t require the full 32GB they might all live in harmony, but more realistically they will eventually need to fight to the karmic death. So over-provision with care.
That said, the host machine is a parsimonious fellow and defaults to using ALL THE THINGS of memory and doesn’t like it when you start stealing from it to give to your guests. Let’s fix this by limiting his take at boot time.
sudo nano /etc/default/grub
Add the following line to the grub config file
GRUB_CMDLINE_XEN_DEFAULT=”dom0_mem=512M,max:512M”
You can give your host OS more memory, but it doesn’t require much to manage the guests. Save the file, and apply the changes and reboot.
sudo update-grub
You made it!
Your Xenbox is primed for launch. Next time we will install a guest VM.