Running virtual machines with LXD 4.0

You can always check https://images.linuxcontainers.org, only cloud variants have cloud-init, if there is no such variant (only default), then no cloud-init.

We usually try to have cloud-init images whenever official up to date packages for it are available in the distro, maybe things changed with Arch but the current state of things suggest it wasn’t last we checked.

Ah that does make sense. It seems cloud-init for arch is actually on 20.2-1 and has been out of date since it was flagged on 2020-09-24. It would also appear Gentoo has the same problem cloud-init-21.1.

  • Does cloud-init have to be the latest version? I’ll try to find out upstream why Arch Linux is lagging behind, then.

On a side note it’s nice to see cloud-init in Alpine Linux. Currently edge repo, so maybe next stable release 3.13 it will be in main repo.

* Is there any way to add a root account etc without cloud-init? I read somewhere default accounts are not shipped with any images. I suppose the only way is to boot an archiso media, chroot to the environment and add a user.

* I also thought about creating my own image with cloud-init. If the package is slightly out of date is this likely to cause issues? I’ll try to work with upstream to get this up to date. It’s nice to have a rolling release distribution with cloud-init.

I assume something like this can be used to boot an environment from a live-cd in order to add some users. For example the archlinux instance doesn’t have cloud-init, so I expect manually adding users is a way?

Add boot ISO to boot device

sudo echo -n '-drive file=/os/archlinux/2020.11.01/archlinux-2020.11.01-x86_64.iso,index=0,media=cdrom,if=ide' | sudo lxc config set archvm raw.qemu -

I’ve already created a VM with:

lxc init images:archlinux/current/amd64 archvm --vm -c security.secureboot=false

The environment will automatically boot from the primary disk. It seems hitting ESC isn’t enough to bring up the boot menu. Did I need to change some of the boot options?

I did try hitting escape but that wasn’t helping.

For ArchLinux since it has a running agent, just use:
echo user:passwd | lxc exec NAME -- chpasswd

Or something similar. You have a root shell easily accessible with lxc exec NAME bash so just use that :slight_smile:

ESC works but the time window is very very narrow unless your distribution has a build of EDK2 with an increased timeout (as we do in the LXD snap).

Ah yes, that probably wasn’t working because of the issue you answered in Lxd-agent: No such file or directory - #4 by stgraber

ESC works but the time window is very very narrow unless your distribution has a build of EDK2 with an increased timeout (as we do in the LXD snap).

Right. I don’t think they have a patch for that. Are you able to point me to the commit/patch that increases it?

First patch is to make DHCPv6 netboot work properly, second is for the fancy LXD bootscreen, third is the boot delay increase.

Hi,

I posted the following regarding an error I am getting when trying to boot into Windows… can anyone help?

Appreciate any help!

Thanks,
Tony

Hi,
I’m trying to run lxd vm’s on my Arch Linux machine, but I get the same error (image doesn’t mater):

[mz@V7590 ~]$ lxc launch ubuntu:20.04 vm1 --vm --profile myprofile --profile vm
Creating vm1
Starting vm1
Error: Failed to run: forklimits limit=memlock:unlimited:unlimited – /usr/bin/qemu-system-x86_64 -S -name vm1 -uuid 8ccbcfe8-1392-4848-a5fe-75382a0e2fdb -daemonize -cpu host -nographic -serial chardev:console -nodefaults -no-reboot -no-user-config -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -readconfig /var/log/lxd/vm1/qemu.conf -pidfile /var/log/lxd/vm1/qemu.pid -D /var/log/lxd/vm1/qemu.log -chroot /var/lib/lxd/virtual-machines/vm1 -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas nobody: qemu-system-x86_64:/var/log/lxd/vm1/qemu.conf:27: There is no option group ‘spice’
qemu-system-x86_64: -readconfig /var/log/lxd/vm1/qemu.conf: read config /var/log/lxd/vm1/qemu.conf: Invalid argument
: Process exited with a non-zero value
Try lxc info --show-log local:vm1 for more info

[mz@V7590 ~]$ sudo cat /var/log/lxd/vm1/qemu.conf
[sudo] password for mz:

Machine

[machine]
graphics = “off”
type = “q35”
accel = “kvm”
usb = “off”
graphics = “off”

[global]
driver = “ICH9-LPC”
property = “disable_s3”
value = “1”

[global]
driver = “ICH9-LPC”
property = “disable_s4”
value = “1”
[boot-opts]
strict = “on”

Console

[chardev “console”]
backend = “pty”

Graphical console

[spice] // Line number 27 //
unix = “on”
addr = “/var/log/lxd/vm1/qemu.spice”
disable-ticketing = “on”

[mz@V7590 ~]$ lxc info --show-log local:vm1
Name: vm1
Location: none
Remote: unix://
Architecture: x86_64
Created: 2021/01/04 20:22 UTC
Status: Stopped
Type: virtual-machine
Profiles: myprofile, vm
Error: open /var/log/lxd/vm1/qemu.log: no such file or directory

[mz@V7590 ~]$ lxd --version
4.9
[mz@V7590 ~]$ lxc --version
4.9
[mz@V7590 ~]$ pacman -Ss spice-gtk
community/spice-gtk 0.38-1 [installed]
GTK+ client library for SPICE
[mz@V7590 ~]$ which virt-viewer
/usr/bin/virt-viewer
[mz@V7590 ~]$ uname -r
5.4.86-1-lts

Launching vm’s with options --console=vga or --console=console, the result is exactly the same…

At this setup lxd containers are working fine…

Could you help me ?
Thx in advance…

That’s an issue with your Linux distribution, your build of qemu wasn’t built with spice support.
I believe I had the LXD maintainer on Arch mention that to us earlier so there may be an open bug report against qemu in Arch to have this fixed.

Hello. I am trying build windows image, but stuck with this error.

[Error: Failed to run: forklimits limit=memlock:unlimited:unlimited fd=3 – /usr/bin/qemu-system-x86_64 -S -name win10 -uuid d648ea55-a11d-4bed-b07a-7e4721319ae4 -daemonize -cpu host -nographic -serial chardev:console -nodefaults -no-reboot -no-user-config -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=deny,resourcecontrol=deny -readconfig /var/log/lxd/win10/qemu.conf -pidfile /var/log/lxd/win10/qemu.pid -D /var/log/lxd/win10/qemu.log -chroot /var/lib/lxd/virtual-machines/win10 -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas nobody -drive file=/run/media/BIG/DWN/Win10_20H2_v2_Russian_x64.iso,index=0,media=cdrom,if=ide -drive file=/run/media/BIG/DWN/virtio-win-0.1.173.iso,index=1,media=cdrom,if=ide: [242623] aa-exec: ERROR: AppArmor interface not available
: Process exited with a non-zero value
Try lxc info --show-log win10 for more info

lxc --version 4.9
Any advice?

Looks like AppArmor isn’t available on your host system. What OS are you running and are you using LXD from the snap package?

ManjaroLinux 20.2.1. LXD from official Repositories.

That’s an issue with your Linux distribution, your build of qemu wasn’t built with spice support.
I believe I had the LXD maintainer on Arch mention that to us earlier so there may be an open bug report against qemu in Arch to have this fixed.

This is upstream qemu 5.2.0 bug. I spent a few hours to isolate the first bad comit.

Does your kernel have appamor support? As we check for the existence of /sys/kernel/security/apparmor and the aa-exec command as indicating that AppArmor is supported.

What’s the content of /sys/module/apparmor/parameters/enabled?

What kernel version are you using and can you supply the output of sudo aa-enabled?

[d@tired ~]$ cat /sys/module/apparmor/parameters/enabled
Y
[d@tired ~]$ sudo aa-enabled
[sudo] password for d:
Yes

What version of AppAmor do you have?

apparmor 3.0.1-1