Cannot create VMs using LVM storage backend on Funtoo linux

Hi there,

I’ve been trying to create empty VM’s for booting with an iso on my distro but there’s something wrong with the way storage is being created that’s different for VMs (it works for regular containers).

Say I do:

# lxc init slackware --empty --vm

I get this message:

    Creating slackware
Error: Failed creating instance: Failed to activate LVM logical volume "/dev/default/virtual-machines_slackware": Failed to run: lvchange --activate y --ignoreactivationskip /dev/default/virtual-machines_slackware: device-mapper: reload ioctl on  (254:9) failed: Invalid argument

Logical volumes:

funtoo ~ # lvs
      LV                                                                      VG      Attr       LSize   Pool        Origin Data%  Meta%  Move Log Cpy%Sync Convert
      LXDThinPool                                                             default twi-aotz-- <12.90g                    65.30  1.97                            
      containers_endless--mosquito                                            default Vwi---tz-k  <9.32g LXDThinPool                                               
      containers_precious--ghoul                                              default Vwi---tz-k  <9.32g LXDThinPool                                               
      images_00c85e7b30d70a3436005ae3302254d27167c3260accf2e2b12c660c8648c342 default Vwi---tz-k  <9.32g LXDThinPool                                               
      images_cea91a28441af36f088f3ae8b637499061518ea2d83c7560a2f7f33d74298968 default Vwi---tz-k  <9.32g LXDThinPool                                               
      images_d342e2d3510458e8157baefe736ccd8a226f3b806b1ebff8288bd0b785a926d9 default Vwi---tz-k  <9.32g LXDThinPool                                               
      home                                                                    funtoo  -wi-ao----  64.00g                                                           
      root                                                                    funtoo  -wi-ao----  48.00g                                                           
      swap                                                                    funtoo  -wi-ao----   4.00g                                                           
      virt                                                                    funtoo  -wi-ao----  10.00g

Can you launch a VM from an image, such as images:ubuntu/focal?

# lxc launch images:ubuntu/focal --vm
Creating the instance
Error: Failed instance creation: Failed creating instance from image: Failed to activate LVM logical volume "/dev/default/images_40620641f2ed8d8afcbe414e2f72c1efe7b46957ee28cd18a123a0346165c617": Failed to run: lvchange --activate y --ignoreactivationskip /dev/default/images_40620641f2ed8d8afcbe414e2f72c1efe7b46957ee28cd18a123a0346165c617: device-mapper: reload ioctl on  (254:9) failed: Invalid argument

OK so its just a general issue with LVM VMs.

Are you running with the snap package?

No, my distro doesn’t use snaps. I tried building LXD with apparmor support earlier. I wish I hadn’t done that because I was told it’s not to do with that.
Now I’ve removed it but I can’t start my containers because of network problems!

funtoo ~ # lxc start endless-mosquito 
Error: Failed preparing container for start: Failed to start device "eth0": Parent device "lxdbr0" doesn't exist
Try `lxc info --show-log endless-mosquito` for more info

funtoo ~ # ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.36  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::e584:c563:5215:618f  prefixlen 64  scopeid 0x20<link>
        ether 28:d2:44:25:f0:68  txqueuelen 1000  (Ethernet)
        RX packets 7385  bytes 6679444 (6.3 MiB)
        RX errors 0  dropped 1057  overruns 0  frame 0
        TX packets 3963  bytes 913492 (892.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf2500000-f2520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:6c:be:7e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::f5d6:d4ce:3511:b4ef  prefixlen 64  scopeid 0x20<link>
        ether a4:4e:31:63:b3:c8  txqueuelen 1000  (Ethernet)
        RX packets 756  bytes 77812 (75.9 KiB)
        RX errors 0  dropped 310  overruns 0  frame 0
        TX packets 55  bytes 8202 (8.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

funtoo ~ # lxc network list
+--------+----------+---------+----------------+------+-------------+---------+
|  NAME  |   TYPE   | MANAGED |      IPV4      | IPV6 | DESCRIPTION | USED BY |
+--------+----------+---------+----------------+------+-------------+---------+
| eth0   | physical | NO      |                |      |             | 0       |
+--------+----------+---------+----------------+------+-------------+---------+
| lxdbr0 | bridge   | YES     | 10.162.45.1/24 | none |             | 3       |
+--------+----------+---------+----------------+------+-------------+---------+
| virbr0 | bridge   | NO      |                |      |             | 0       |
+--------+----------+---------+----------------+------+-------------+---------+
| wlan0  | physical | NO      |                |      |             | 0       |
+--------+----------+---------+----------------+------+-------------+---------+

funtoo ~ # lxc network detach-profile lxdbr0 default
Error: More than one device matches, specify the device name
funtoo ~ # lxc network detach-profile lxdbr0 endless-mosquito 
Error: Fetch profile: No such object

Try restarting LXD as it will recreate any missing bridges. It looks like something/someone has removed the bridge interface.

Regarding the LVM issue, please can you rule out corruption on your existing LVM pool by creating a fresh temporary one using a loop file with:

lxc storage create lvmtemp lvm
lxc init slackware --empty --vm -s lvmtemp

See if that works.

funtoo ~ # rc-service lxd restart
 * Stopping lxd service (but not containers) ...                          [ ok ]
 * Starting lxd service ...                                               [ ok ]
funtoo ~ # ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.36  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::e584:c563:5215:618f  prefixlen 64  scopeid 0x20<link>
        ether 28:d2:44:25:f0:68  txqueuelen 1000  (Ethernet)
        RX packets 10909  bytes 7536280 (7.1 MiB)
        RX errors 0  dropped 2302  overruns 0  frame 0
        TX packets 6132  bytes 1444864 (1.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf2500000-f2520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:6c:be:7e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::f5d6:d4ce:3511:b4ef  prefixlen 64  scopeid 0x20<link>
        ether a4:4e:31:63:b3:c8  txqueuelen 1000  (Ethernet)
        RX packets 2242  bytes 216846 (211.7 KiB)
        RX errors 0  dropped 550  overruns 0  frame 0
        TX packets 118  bytes 18872 (18.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
funtoo ~ # lxc storage create lvmtemp lvm
Storage pool lvmtemp created
funtoo ~ # lxc init slackware --empty --vm -s lvmtemp
Creating slackware
Error: Failed creating instance: Failed to activate LVM logical volume "/dev/lvmtemp/virtual-machines_slackware": Failed to run: lvchange --activate y --ignoreactivationskip /dev/lvmtemp/virtual-machines_slackware: device-mapper: reload ioctl on  (254:13) failed: Invalid argument

Check your logs for something preventing LXD from bringing up lxdbr0.

And it works if you do a container on LVM?

E.g.

lxc init images:ubuntu/focal c1 -s lvmtemp

Yes! (weird right):

funtoo ~ # lxc init images:ubuntu/focal c1 -s lvmtemp
Creating c1
funtoo ~ #

What version of LXD is this and have you built it manually if not using a package?

And have you done a fresh reboot since this started to ensure LVM state is fresh?

It’s 4.14.

[I] app-emulation/lxd
     Available versions:  3.21^s **4.0.5^s **4.12^s 4.14^s {apparmor +dnsmasq (+)ipv6 nls KERNEL="linux"}
     Installed versions:  4.14^s(04:17:12 PM 08/05/2021)(ipv6 nls -apparmor KERNEL="linux")
     Homepage:            https://linuxcontainers.org/lxd/introduction/ https://github.com/lxc/lxd
     Description:         Fast, dense and secure container management

I tried one before we started chatting, when I realized the network wasn’t working.
I had trouble getting it to start yesterday, as well, but I thought that had been fixed by starting the libvirtd service. Now I’m really confused.

That output above is from portage.

Is networking working now?

No. I still can’t get that interface to come back. Even though LXD thinks it’s there.

LXD doesn’t think its there, its just that it has a DB record indicating that it used to be there as an managed network interface. If LXD cannot bring up the interface for some reason (or something else is subsequently removing it), then this will be the issue. Please check your LXD logs for the former and look at any other network management systems you have on your machine for the latter.

Can you show output of vgs too, I wonder if you’re running out of space.

Otherwise I’m fresh out of ideas as never seen anything like that and have never used Funtoo, and it seems like there is some other strange stuff going on on your system causing the network issues too :slight_smile: