Linux Desktop images in LXD

Use Linux Desktop virtual machine images in LXD

left.svg right.svg page.svg tags.svg

Linux Desktop Images

List all the desktop amd64 virtual machines in images remote server:

lxc image list images: type=virtual-machine architecture=x86_64 --columns=lLfFpdasut desktop

Here are some commands related to remote servers:

# configured remote servers
lxc remote list
# get the default remote server
lxc remote get-default
# set 'ubuntu' as the new default remote server
lxc remote switch ubuntu

# list images in the default remote server
lxc image list
# list images in the 'ubuntu' remote server
lxc image list ubuntu:
# list virtual machines with x86_64 architecture in the 'images' remote server
lxc image list images: type=virtual-machine architecture=x86_64 --columns=lLfFpdasut

Create a dedicated LXC profile

lxc profile create LinuxDesktop

lxc profile set LinuxDesktop limits.cpu=4
lxc profile set LinuxDesktop limits.memory=8GiB

lxc profile device add LinuxDesktop root disk \
    path=/ pool=default

lxc profile device add LinuxDesktop eth0 nic \
    name=eth0 network=lxdbr0

# if you want audio
lxc profile set LinuxDesktop raw.qemu='-device intel-hda -device hda-duplex'

Launch a new image

lxc launch images:ubuntu/jammy/desktop UbuntuDesktop --vm --profile=LinuxDesktop --console=vga

After startup you may want to:

# update the system
sudo apt update && sudo apt -y upgrade

# install the openssh server and add a public key for remote access
ssh_key='ssh-ed25519 AAAA...'
sudo apt install openssh-server
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$ssh_key" > ~/.ssh/authorized_keys

# for audio support
sudo apt install "linux-modules-extra-$(uname -r)"
reboot

To connect to vm’s console use:

lxc console UbuntuDesktop --type=vga

Templating

If you want to make a template out of the modified virtual machine you should generalize it, at least:

When is stopped publish an image to you local image repository:

lxc publish UbuntuDesktop --public --alias=UbuntuDesktop_Base

Note: An example script for simple generalization of a virtual machine or container is generalize_simple.sh

Tags:LXDLinux Desktop

Category:System Administration

Created 2023-12-14

In the same category:

Related posts: