Adding a new container gives this error:Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Invalid devices: Failed detecting root disk device: No root device could be found

This problem just started happening no more than 3 days ago. Probably some upgrade. I tried adding default profile but it says it already exists. see below. Any ideas. Thanks

# lxc launch ubuntu:18.04 QMAIL24 --target Q3
Creating QMAIL24
Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Invalid devices: Failed detecting root disk device: No root device could be found
# lxc image list
+-------+--------------+--------+---------------------------------------------+--------------+-----------+----------+-------------------------------+
| ALIAS | FINGERPRINT  | PUBLIC |                 DESCRIPTION                 | ARCHITECTURE |   TYPE    |   SIZE   |          UPLOAD DATE          |
+-------+--------------+--------+---------------------------------------------+--------------+-----------+----------+-------------------------------+
|       | 68fc6b23c41b | no     | ubuntu 18.04 LTS amd64 (release) (20210325) | x86_64       | CONTAINER | 190.74MB | Mar 26, 2021 at 4:06am (UTC)  |
+-------+--------------+--------+---------------------------------------------+--------------+-----------+----------+-------------------------------+
|       | 46701fa2d99c | no     | ubuntu 20.04 LTS amd64 (release) (20210325) | x86_64       | CONTAINER | 360.90MB | Mar 26, 2021 at 10:06pm (UTC) |
+-------+--------------+--------+---------------------------------------------+--------------+-----------+----------+-------------------------------+
# lxc storage show default
Error: not found
# lxc profile device add default root disk path=/ pool=default
Error: The device already exists
# lxc profile show default
config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdfan0
    type: nic
  root:
    path: /
    pool: local
    type: disk
name: default
used_by:
- /1.0/instances/WP-QUANTUMAI-2020-mar6-bk
- /1.0/instances/WP-HAPPYDOGS-2020-mar28
- /1.0/instances/EMPODERATE-2020-mar6 .......
# lxc project ls
+-------------------+--------+----------+-----------------+----------+---------------------+---------+
|       NAME        | IMAGES | PROFILES | STORAGE VOLUMES | NETWORKS |     DESCRIPTION     | USED BY |
+-------------------+--------+----------+-----------------+----------+---------------------+---------+
| default (current) | YES    | YES      | YES             | YES      | Default LXD project | 188     |
+-------------------+--------+----------+-----------------+----------+---------------------+---------+
# lxc profile device add default root disk path=/ pool=default
Error: The device already exists
# lxc version
Client version: 4.12
Server version: 4.12

Most likely the image got detached from its profiles.
A workaround for that is to manually pass -p default during launch.
Permanent fix is to look at lxc image list for the relevant cached entry, then use lxc image edit and add default back to the list of profiles.

If you have any clue on how to reproduce this kind of broken images, let us know as we’ve put a bunch of logic in place already that should have avoided this issue, but given you’re running 4.12 and still see it, something else appears to be wrong.

Offering sequence of bad user input that will generate this issue. Hopefully it is helpful.

  1. clean install from source of lxd version 5.6
  2. $ lxd init
    Would you like to use LXD clustering? (yes/no) [default=no]: no
    Do you want to configure a new storage pool? (yes/no) [default=yes]: no
    Would you like to connect to a MAAS server? (yes/no) [default=no]: no
    Would you like to create a new local network bridge? (yes/no) [default=yes]: yes
    What should the new bridge be called? [default=lxdbr0]: lxdbr0
    What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
    What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
    Would you like the LXD server to be available over the network? (yes/no) [default=no]: no
    Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: yes
    Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes
  1. $ lxc launch images:ubuntu/20.04 ubuntu-container
    Creating ubuntu-container
    Error: Failed instance creation: Failed creating instance record: Failed initialising instance: 
          Invalid devices: Failed detecting root disk device: No root device could be found
  1. the stupid user input of no storage device, thinking dir was automatically there in step 2 because I’d already used lxc caused error in step 3.
  2. attempt to lxd init with btrfs, w/o btrfs drivers installed, may or may not be relevant. Also triggered issue Error: Failed to update profile “default”: Device validation failed for “eth0”: Cannot use “nictype” property in conjunction with “network” property before I figured out lxd init did not clear out or reset, but built on existing only. Again this is stupid/naive user input. Eventually ran lxd init with dir but it errored on nic issue so not sure it completed successfully. Still working through docs on how to manually configure lxd option, ie what option is actually wrong.
  3. attempt to list and delete default profile to see what is happening
    $ lxc profile list
    +---------+---------------------+---------+
    |  NAME   |     DESCRIPTION     | USED BY |
    +---------+---------------------+---------+
    | default | Default LXD profile | 0       |
    +---------+---------------------+---------+

$ lxc profile delete default
Error: The "default" profile cannot be deleted

  1. failed attempt to launch: $ lxc launch images:ubuntu/20.04 ubuntu-container
    Creating ubuntu-container
    Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Invalid devices: Failed detecting root disk device: No root device could be found

$ lxc image list

   +-------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
    | ALIAS | FINGERPRINT  | PUBLIC |             DESCRIPTION             | ARCHITECTURE |   TYPE    |   SIZE   |         UPLOAD DATE          |
    +-------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
    |       | 854b78f88d8b | no     | Ubuntu focal amd64 (20221019_07:42) | x86_64       | CONTAINER | 111.10MB | Oct 19, 2022 at 1:21pm (UTC) |
    +-------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
  1. try to edit but not knowing what to edit to “add back default that is already there”
    $ lxc image edit 854b78f88d8b
### This is a YAML representation of the image properties.
### Any line starting with a '# will be ignored.
###
### Each property is represented by a single line:
### An example would be:
###  description: My custom image

auto_update: true
properties:
  architecture: amd64
  description: Ubuntu focal amd64 (20221019_07:42)
  os: Ubuntu
  release: focal
  serial: "20221019_07:42"
  type: squashfs
  variant: default
public: false
expires_at: 1970-01-01T00:00:00Z
profiles:
- default

I was able to overcome the failure to create container error show above caused by a bad lxd init by creating a storage pool and explicitly specifying it during container creation per [R1].

   $ lxc storage create pool1 dir
   $ lxc storage list
          # now shows storage
   $ sudo ls /var/lib/lxd/storage-pools/
          #  shows: pool1
    # launch using that storage pool (this worked!)
    $ lxc launch images:ubuntu/20.04 ubuntu-container -s pool1

the following to make it the storage pool a default, as mentioned in [R1] for subsequent containers to not need the -s option did NOT work.

    $ lxc profile device set default root pool=pool1
           Error: Device doesn't exist
    $ lxc profile dir set default root pool=pool1
           Error: unknown command "dir" for "lxc profile"

References

  1. How to manage storage pools - LXD documentation

This issue is caused by a missing “root” definition under the “devices” section of the default profile.

Solution is to edit the default profile by running:
lxc profile edit default

Then add the missing “root” section under “devices”.
Example of how the profile should look like :

config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
1 Like