Ubuntu LXD Virtual Machine

I have covered LXD containers in many other tutorials and they are lean and resource efficient. LXD VMs use many of the facilities of the LXD frontend and also the QEMU VM components on the backend. This makes for an easier to use and leaner VM.

In my two previous Windows 11 LXD VM tutorials, we learned how to use distrobuilder to repackage the Windows 11 distribution ISO and perform a Windows 11 installation in a LXD VM.

Typically LXD VM’s are created from an image just like a LXD container and so they do not have to go through an installation process as we did with the Windows 11 LXD VM.

LXD VM images are kept fairly lean on purpose to optimize size with the idea that you can add whatever apps you need once the container is deployed. An Ubuntu LXD VM has the advantage of quick deployment because there is no installation process like there is with a typical VM.

Be sure you are running LXD v4.0 or later:

lxc version

In this video, I deploy an Ubuntu 22.04 Desktop in a LXD VM. First we want to examine your network interfaces on your LXD host:

ip route show

Note which interface on your system is the one getting an address on your LAN. Now we create a LXD profile for the untagged VLAN which is your main LAN so that our container will get an address on your LAN and not an internal LXD NAT address space which is the default. Note: Your parent will not be “bridge0”:

lxc profile create untagged
lxc profile device add untagged eth0 nic nictype=macvlan parent=bridge0
lxc profile show untagged

Deploy the Ubuntu 22.04 Jammy Jellyfish desktop in a LXD VM:

lxc launch images:ubuntu/22.04/desktop ubuntu-vm --vm --profile default --profile untagged -c limits.memory=4096MB -c limits.cpu=2 -c boot.autostart=true --console=vga

To regain access to the console after logging out:

lxc console ubuntu-vm --type=vga

You can change the size of your root file system:

lxc config device override ubuntu-vm root size=50GiB

I showed how to download a script to enable an RDP server on your Ubuntu LXD VM:

wget https://c-nergy.be/downloads/xRDP/xrdp-installer-1.4.8.zip
unzip xrdp-installer-1.4.8.zip 
chmod +x xrdp-installer-1.4.8.sh
./xrdp-installer-1.4.8.sh

You can connect to your LXD VM with the console or with a program like Remmina remote desktop client. I used Apache Guacamole and I have a separate video on Guacamole if you are interested.