How to install and configure LXD on POP_OS
What’s LXD?|
LXD is a next-generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead.
It’s image-based with pre-made images available for a wide number of Linux distributions and is built around a very powerful, yet pretty simple, REST API.
To get a better idea of what LXD is and what it does, you can try it online! Then if you want to run it locally, take a look at our getting started guide.
The LXD project was founded and is currently led by Canonical Ltd with contributions from a range of other companies and individual contributors.
Step 1 — Install LXD on POP_OS
First, as always, check if there are any pending updates to install on POP_OS
sudo apt update && sudo apt upgrade
To start the installation of LXC
sudo apt install lxd
Usually, for testing, the purpose selects the latest version else picks 4.0 for stable servers on the next screen
Step 2 — Add user to the LXD group for management purpose
No need to be the root user to manage LXD daemon. To manage LXD server add your username to lxd group using the adduser command:
sudo adduser $USER lxd.
The group membership is only applied at the next login, or a new ssh session started. Hence, either you need to close and re-open your user/ssh session or use the following newgrp command:
newgrp lxd
Verify membership details with the id command:
id | grep lxd
Test it with the lxc command:
lxc list
Step 3 — Set up and configure LXD networking and storage options
Now that we installed LXD, it is time to set up the LXD server. You must configure networking and storage option such as directory, DIR, ZFS, Btrfs, and more, enter:
sudo lxd init
Next, you must answer a series of questions on how to configure the LXD server, including the storage and networking option. Here is a sample as you can starting your settings.
We can verify the information by typing the following commands:
lxc profile list
lxc network list
lxc storage list
Step 4 — Listing built-in LXD image for various Linux distros
lxc image list images: | grep -i ubuntu
lxc image list images: | grep -i ubuntu/21
Step 5 — Creating your first Linux container
Creating your first container is straightforward. The syntax is:lxc launch images:{distro}/{version}/{arch} {container-name-here}