Trying to autostart lxd in the WSL 2 Ubuntu-22.04 instance but it's set for socket activation

Hi,

I’ve installed the lxd snap in the WSL 2 Ubuntu-22.04 instance and it works fine. Now I’m trying to
set lxd to autostart when the WSL 2 Ubuntu-22.04 instance starts but I’ve failed to accomplish this.

ogra at #ubuntu/libera suggested that I use

sudo snap start --enable lxd.daemon

to do it, but lxd doesn’t autostart on WSL 2 Ubuntu-22.04 instance startup.

$ sudo snap services
[sudo] password for aki:
Service          Startup  Current   Notes
lxd.activate     enabled  inactive  -
lxd.daemon       enabled  inactive  socket-activated
lxd.user-daemon  enabled  inactive  socket-activated

If I run “lxc list”, both lxd and the one lxc container I have, start up through socket activation (I guess).

I’ve used “lxc config set ubuntu-jammy boot.autostart true” to make the lxc container start automatically.

Best regards,

Aki

1 Like

I got this startup problem fixed like this:

WSL 2’s default systemd target is graphical.target.

I changed both:

# /etc/systemd/system/snap.lxd.activate.service.d/override.conf
[Install]
WantedBy=
WantedBy=graphical.target

and

# /etc/systemd/system/snap.lxd.daemon.service.d/override.conf
[Install]
WantedBy=graphical.target

then

systemctl daemon-reload
systemctl enable snap.lxd.activate.service
systemctl enable snap.lxd.daemon.service

and then restarted the WSL 2 VM.

Best regards,

Aki

Unfortunately, that same config didn’t work on my work laptop. So I’m still checking how to start the snap lxd on boot.

When I try to start lxd manually with “sudo /usr/bin/snap run lxd.daemon”, I get this error message:

=> Starting LXD
WARNING[2023-09-29T11:37:35+03:00] AppArmor support has been disabled because of lack of kernel support
WARNING[2023-09-29T11:37:35+03:00]  - AppArmor support has been disabled, Disabled because of lack of kernel support
WARNING[2023-09-29T11:37:35+03:00]  - Couldn't find the CGroup blkio.weight, disk priority will be ignored
WARNING[2023-09-29T11:37:35+03:00] Instance type not operational                 driver=qemu err="vhost_vsock kernel module not loaded" type=virtual-machine
Killed
=> LXD failed to start

lxd still starts with “sudo lxc list” so I’m a bit confused what’s going on.

Finally. I updated the WSL 2 kernel from https://aka.ms/wsl2kernel and now the snap lxd starts up automatically on boot.

1 Like