Install LXD to Ubuntu 20.04 LTS using apt

How to install a pure LXD Container Hypervisor on Ubuntu 20.04 LTS Linux for the incredible speed of unmodified Debian/Ubuntu/CentOS/Fedora/Arch Linux operating systems? How can I configure and use LXD on a Ubuntu Linux server? How to install LXD on an Ubuntu cloud server?

Introduction : The LXD container system is supported and created by the Ubuntu command. It offers 25-30% better performance than Vmware ESX. 10 times the density with zero delay. You can place Linux VMs with LXD directly into containers without having to change applications or administrative processes. You can run CentOS, Arch Linux, Fedora Linux, OpenSUSE, Gentoo, Ubuntu, Debian and many other Linux distributions in containers. This page shows how to install and configure LXD on Ubuntu 20.04 LTS.

Adblock detected ?

My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via PayPal/Bitcoin, or become a supporter using Patreon.


Why use LXD on Ubuntu 20.04?

LXD is a container experiment that provides a ReST API for managing LXC containers. With LXD you can do the following:

  1. Preferred containers (protected by construction)
  2. Scalable
  3. Living Migration
  4. Advanced resource management for CPU, memory, disk/network I/O, kernel modules, etc.).
  5. Hardware support for GPU, USB, NIC, hard drives, etc.
  6. Containers to be loaded
  7. Refresh the container
  8. Cluster support
  9. Ease of use
  10. Installing various Linux distributions in containers
  11. Management of container resources such as storage volumes, card folders, storage/input/output limits, networks, etc.

Installation and configuration of LXD on Ubuntu 20.04 LTS

Let’s take a look at all the step-by-step instructions for setting up LXD :

Step 1 – Installing LXD on Ubuntu Linux Server 20.04 LTS

Make sure all security updates are installed on Ubuntu with the command apt or apt-get, type:
sudo apt update
sudo apt upgrade
To install a stable LXD branch, run the following command apt or snap:
sudo apt install lxd
Install LXD to Ubuntu 20.04 LTS using apt For the test, the target selects the latest version 4.0 for stable servers on the next screen
Install LXD to Ubuntu 20.04 LTS using apt I select version 4.0 of the snap track
You can also use the snap command directly as follows :
sudo snap install lxd –channel=4.0/stable
Install LXD to Ubuntu 20.04 LTS using apt

Step 2 – Adding a user to the LXD group for control purposes

You don’t need to be a root user to control the LXD daemon. To manage the LXD server, add a username to the lxd group using the adduser command under Ubuntu Linux:
sudo adduser {USERNameHere} lxd
sudo adduser vivek lxd
sudo adduser $USER lxd
Group membership is only valid on the next connection or when starting a new ssh session. Therefore you must either close and reopen your user/session, or use the following newgrp command to immediately request membership:
newgrp lxd
Check your membership details with the id command:
Test it with the lxc command:
list lxc
Install LXD to Ubuntu 20.04 LTS using apt See my more permission errors and more unprivileged user managing LXD

Step 3 – Configuring and setting up the functions of the LXD network and storage device

Now that we have installed LXD, it is time to configure the LXD server. You must configure network and storage options, such as B. Directory, ZFS, Btrfs, and others, type:
sudo lxd init
Next, you must answer a series of questions about configuring the LXD server, including storage and network options. Here is an example of the session I configured for ZFS and NATed subnets. Feel free to choose the options according to your needs:
Install LXD to Ubuntu 20.04 LTS using apt
We can check the information by entering the following commands:
List of profiles lxcList of standard lxc networksList of networks lxc lxdbr0List of memories lxc nixcraftzfs List of memories and network profilesGif.01 : Discover our LXD storage server and our network profile

Step 4 – List of an embedded LXD image for different distributions of Linux

To get a list of all the current LXD list images listlxx: | grep -i centos List images listlxx: | grep -i ubuntulxc List images LXD: | grep -i ubuntulxc List images LXD: | grep -i ubuntulxc List images LXD : | List of images of grep -i debian LXD

Step 5 – Create the first Linux container

It’s easy to make your first container. Syntax:
lxc start images:{distro}/{version}/{arc}. {pos(192,210)}(name of the container somewhere)

Alpine Container Linux 3.11

Your container here is called alpine-c1:
lxc launc images:alpine/3.11/amd64 alpine-c1
Install LXD to Ubuntu 20.04 LTS using apt .

CentOS Linux 8 Container

start images lxc: centos/8/amd64 centos-8-с2

Ubuntu Linux container 16.04 or 18.04 or 20.04 LTS

Start-up screens lxc:ubuntu/xenial/amd64 ubuntu-xenial-c3
Start-up screens lxc:ubuntu/bionic/amd64 ubuntu-bionic-c4
Start-up screens lxc:ubuntu/focal/amd64 ubuntu-focal-c5

Debian Linux 9.x stretch or 10.x container

lxc start images: debian/stretch/amd64 debian-9-c6
lxc start images: debian/10/amd64 debian-10-www

Architecture container for Linux

Boot images lxc:archlinux/amd64 arch-c7

Linux GentooContainer

start images lxc:gentoo/amd64 gentoo-c8

Fedora Linux 31 container

start images lxc: fedora/31/amd64 fedora-31-c9

OpenSUSE Linux container 15.0

Start-up screens lxc: opensuse/15.1/amd64 opensuse15-1-c10

Oracle Linux 8.x VM

Boot images lxc:oracle/8/amd64 oracle-8-c11

Step 6 – Container management based on LXD with the CLIexcavator

Let’s dive into the basic container management teams.

List of Linux containers

We can display the existing containers as a tube using the following syntax and the command grep/egrep:
lxc list –fast
lxc list | grep RUNNING
lxc list | grep STOPPED
lxc list | grep -i opensuse
lxc list *c1*
lxc list *c2*
lxc list
Install LXD to Ubuntu 20.04 LTS using apt

Run/start command specified in container

With the execution command, we execute or execute the commands in the containers as follows:
lxc exec containerName — command
lxc exec containerName — /path/to/script
lxc exec containerName –env EDITOR=/usr/bin/vim — command
##### Execution date, ip a, ip rm and other commands on different containers ##
lxc exec cenots-8-c2 — date
lxc exec cenots-8-c2 — ip a
lxc exec ubuntu-focal-c5 — ip r
lxc exec fedora-31-c9 — dnf -y update
lxc exec debian-10-www — cat /etc/debian_version
Install LXD to Ubuntu 20.04 LTS using apt

Access to the baseball pit in container

If you want to connect/access a container named debian-10-www, type
lxc exec {container name} {shell name}
lxc exec debian-10-www bash
lxc exec alpine-c1 sh
You can now execute commands or install packages. For example, use the apt/apt-get command in the container:
# cat /etc/*issue*
# apt update
# apt upgrade
Just type exit to return to the host:
# exit

Operation of my container

lxc start {container name}
lxc start oracle-8-c11

Stop my containers command

lxc stop {container name}
lsc stop alpine c1

Charging my containers

lxc restart {container name}
lxc restart gentoo-c8

Remove packaging LXD

The team’s next. Be careful as LXD containers are immediately removed without any indication of confirmation. In other words: Always make backups:lxc delete {container-Name}lxc delete ubuntu-xenial-c3 The following error can occur when deleting a container:lxc delete {container-name}lxc delete ubuntu-xenial-c3 The following error can occur when deleting a container

Container is moving, stop it first or force it through.

To repair it:
lxc stop ubuntu-xenial-c3 & lxc remove ubuntu-xenial-c3

How do I view information about LXD Servers and Containers?

Enter the following command:
lxc information
lxc information {ship name}
lxc information opensuse15-1-c10

Drag the file from Container

lxc file {continer-nane}/{path/to/file} {/path/k/local/dest}
lxc file ubuntu-xenial-c3/var/www/nginx/app/config.php .

Place the file in the container

Click lxc-file {/path/k/file} {continer-nane}/path/to/dest/dir/
lxc-file push config.php ubuntu-xenial-c3/var/www/nginx/app/

Step 7 – Obtaining the lxcOrder Certificate

Easy to get help:
lxc –help
lxc {mission} –help
lxc list –help


In this detailed tutorial you have learned how to install and configure LXD on an LTS Ubuntu 20.04 server using the apt command to run different Linux distributions. For more information, see the lxc orders and documents here.


Published: Vivek gears

The author is the creator of nixCraft and an experienced system administrator, DevOps engineer and Linux/Unix shell script trainer. Receive the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly by email.