Install LXD pure-container hypervisor on Ubuntu 18.04 LTS

How can I install LXD pure-container hypervisor on Ubuntu 18.04 LTS to runs unmodified Debian/Ubuntu/CentOS Linux operating systems VM at incredible speed? How do I setup and use LXD on Ubuntu Linux server?Introduction: The LXD container hypervisors are supported and created by Ubuntu team. It provides 25% faster performance than ESX. 10 times the density with zero latency. One can move Linux VMs straight to containers using LXD without modifying the apps or administration processes. Ubuntu’s LXD is a pure-container hypervisor that runs unmodified Linux guest operating systems with VM-style operations at incredible speed. You can run CentOS, Arch Linux, Fedora Linux, OpenSUSE, Gentoo, Ubuntu, Debian and other Linux distro in containers. This page shows how to install and configure LXD pure-container hypervisor on Ubuntu Linux 18.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?

LXD is a container hypervisor providing a ReST API to manage LXC containers. One can do the following things with LXD:

Run containers

Update containers

Clustering support

Install different Linux distro inside containers

Manage container resources, like storage volumes and networks

Setting up LXD on Ubuntu 18.04 LTS

The procedure to set up and use LXD on Ubuntu Linux 18.04 LTS is as follows:

Install lxd

Setup and configure LXD networking and storage

Create your first container

Launch a container

Let us see all steps in details.

Install LXD pure-container hypervisor on Ubuntu 18.04 LTS

How to 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 on Ubuntu Linux:$ sudo adduser {USERNameHere} lxd $ sudo adduser vivek lxd Please note that group membership is only applied at login or new ssh session, you then either need to close and re-open your user/ssh session or use the following command to avoid problems:$ newgrp lxd Verify it with the id command:$ id

Setup ZFS (optional)

I suggest you use ZFS and along with DHCP based IP networking for ease of setup for each VM. The ZFS offers quick option to make snapshots and other advanced features:$ sudo apt install zfsutils-linux See how to install ZFS on Ubuntu server for more information.

Configure LXD storage and networking option

It is time set up the LXD server. You must configure networking and storage option such as directory, zfs, btrf and more:$ sudo lxd init You must answer a series of questions on how to configure the LXD server. Here is a sample session: LXD is now set up and configured. You can verify it with the following command:$ lxc list $ lxc info | more

Creating your first Linux container

How create and use your first container on Ubuntu 18.04 LTS running LXD

To create and start containers from images use the launch command:lxc launch images:{distro}/{version}/{arch} {container-name-here} Let us see some examples to create and start containers from various Linux distro images as per your needs.

How do I restart my containers?

How do I delete my containers?

The command is (be careful as the LXD containers are deleted immediately without any confirmation prompt i.e. keep backups):$ lxc delete containerName $ lxc delete foo $ lsc delete cenots-c2 You may get the following error while deleting the container:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Your support makes a big difference:

I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft takes a lot of my time and hard work to produce. If everyone who reads nixCraft, who likes it, helps fund it, my future would be more secure. You can donate as little as $1 to support nixCraft:

Notable Replies

[quote]It would be nice if you also could add some information about how to move the default store … I’ve done it, but it was not a simple task… which is one of the reasons why I’m still using lxc … [/quote]

When you run sudo lxd init you can always change storage type. It is possible to move after installation as well but it needs more work.