LXD is a next generation system container manager built around a very powerful REST and offers a user experience similar to virtual machines but using Linux containers instead. LXD uses pre-made Linux images which are available for a wide number of Linux distributions.
In this guide, I’ll show you simple steps to install and use LXD on Rocky / AlmaLinux server/Desktop. The installation will make use of Snap, which was covered on Installing Snapd and Snap applications on Rocky / AlmaLinux guide.
Features of LXD
From the official LXD website, these are the biggest features of LXD are mentioned:
- Secure by design (unprivileged containers, resource restrictions and much more)
- Scalable (from containers on your thousands thousand of compute nodes)
- Intuitive (simple, clear API and crisp command line experience)
- Image-based (with a wide variety of Linux distributions published daily)
- Support for Cross-host container and image transfer (including live migration with CRIU)
- Advanced resource control (cpu, memory, network I/O, block I/O, disk usage and kernel resources)
- Device passthrough (USB, GPU, Unix character and block devices, NICs, disks, and paths)
- Network management (bridge creation and configuration, cross-host tunnels, …)
- Storage management (support for multiple storage backends, storage pools, and storage volumes)
Running LXD Containers on on Rocky / AlmaLinux
Now let’s start the installation of LXD on Rocky / AlmaLinux by following the steps below
Step 1: Install snapd
You need to install snapd which will provide snap command line tool used to install LXD package. Install snapd by following the guide:
Once you have snapd installed, go to step 2
Step 2: Configure Kernel Parameters
Some Kernel options are required by LXD to be enabled on the system. Configure them by running the following commands on your terminal. Run these commands as root user.
grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
grubby --args="namespace.unpriv_enable=1" --update-kernel="$(grubby --default-kernel)"
echo "user.max_user_namespaces=3883" > /etc/sysctl.d/99-userns.conf
You’ll need to reboot the system after making the changes.
sudo reboot
Step 3: Install lxd snap on Rocky / AlmaLinux
Finally, install LXD snap from snap store
$ sudo snap install lxd
lxd (5.21/stable) 5.21.1-d46c406 from Canonical✓ installed
The installation should take short time if you have a good internet connection. You can confirm package installation using:
$ sudo snap list
Name Version Rev Tracking Publisher Notes
core20 20240416 2318 latest/stable canonical✓ base
core22 20240408 1380 latest/stable canonical✓ base
lxd 5.21.1-d46c406 28460 5.21/stable canonical✓ -
powershell 7.4.3 269 latest/stable microsoft-powershell✓ classic
snapd 2.63 21759 latest/stable canonical✓ snapd
$ sudo snap services
Service Startup Current Notes
lxd.activate enabled inactive -
lxd.daemon enabled inactive socket-activated
lxd.user-daemon enabled inactive socket-activated
Step 4: Launching test LXD container
Ensure
echo 'export PATH="$PATH:/snap/bin/"'|tee -a ~/.bashrc
source ~/.bashrc
Let’s add our user account to the grouplxd for it to manage LXD containers without permission errors.
sudo usermod -aG lxd $USER
newgrp lxd
Load kernel modules.
sudo modprobe overlay
sudo modprobe br_netfilter
Ensure modules are configured to load at boot:
echo -e "noverlay\nbr_netfilter" | sudo tee /etc/modules-load.d/lxd.conf
Restart LXD service.
sudo systemctl restart snap.lxd.daemon
Configure LXD environment using
$ lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: no
Do you want to configure a new storage pool? (yes/no) [default=yes]: no
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, ceph, dir, lvm) [default=btrfs]: dir
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
A listing of containers should return an empty list
$ lxc list
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+
To list available VM images run:
lxc image list images:
Example of image names available:
- fedora/40
- kali
- rockylinux/9
- rockylinux/8
- oracle/9
- almalinux/8
- almalinux/9
# Rocky linux 8|9
lxc image list images:centos/9-Stream
debian/12
Create a test Rocky Linux 8 container by running:
# lxc launch images:rockylinux/8 rocky-8-container
Creating rocky-8-container
Starting rocky-8-container
Launch Ubuntu container by running:
# lxc launch images:ubuntu/22.04 ubuntu-container
Creating ubuntu-container
Starting ubuntu-container
List your containers:
# lxc list
+-------------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| rocky-8-container | RUNNING | 10.249.233.129 (eth0) | fd42:380b:91a6:efc0:216:3eff:fece:1ee3 (eth0) | CONTAINER | 0 |
+-------------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| ubuntu22 | RUNNING | 10.249.233.40 (eth0) | fd42:380b:91a6:efc0:216:3eff:feb1:7d6f (eth0) | CONTAINER | 0 |
+-------------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| ubuntu-container | RUNNING | 10.249.233.189 (eth0) | fd42:380b:91a6:efc0:216:3eff:fe6f:7d3e (eth0) | CONTAINER | 0 |
+-------------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
Stop, start, restart, delete, check info a container
lxc start container
lxc stop container
lxc restart container
Get info about a container using info command option
lxc info container
Sample output:

For more command line options, run
lxc --help
lxc command --help e.g lxc start --help
Recommended Linux Books to read:
- Best Linux Books for Beginners & Experts
- Best Linux Kernel Programming Books
- Best Linux Bash Scripting Books
You have successfully installed LXD on Rock / AlmaLinux from snap and created an lxc container. Thanks for using our guide. If you have any issue, don’t hesitate to drop a comment.




























































