How to fix lxc launch Failed getting root disk: No root device could be found

Problem:

While trying to launch a lxc container using a command like

fix_lxc_launch.sh
lxc launch ubuntu:22.04 mycontainer

you see the following error message:

lxc_launch_error.txt
Creating mycontainer
Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Failed getting root disk: No root device could be found

Solution

You didn’t initialize your LXD storage properly. Run

lxd_init.sh
lxd init

in order to configure the storage for lxd. For most setups except performance-critical production setups, I recommend to use the dir storage backend because it does not require any further configuration. You can leave all other options at their default values.

lxd_init_example.txt
Name of the storage backend to use (zfs, btrfs, ceph, cephobject, dir, lvm) [default=zfs]: dir

Check out similar posts by category: Container, LXC