"No root device could be found" error when running snapcraft on a LXD install with customized storage pool


I originally posted a question in the Linux Containers forum, but this error only pops up when running snapcraft, so I figured I’d also ask here.

Please check the original forum post for more information:


I tried to remove snapcraft (sudo snap remove --purge snapcraft) and reinstall it (sudo snap install snapcraft --classic), but I still get the same error:

$ snapcraft
Launching instance...                                                                                                                                                                                                                                         Traceback (most recent call last):
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_providers/lxd/lxc.py", line 549, in launch
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_providers/lxd/lxc.py", line 98, in _run_lxc
    return subprocess.run(lxc_cmd, check=check, stdin=stdin.value, **kwargs)
  File "/snap/snapcraft/8567/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'launch', 'craft-com.ubuntu.cloud-buildd:core22', 'local:snapcraft-xxx-on-amd64-for-amd64-47979909', '--config', 'raw.idmap=both 1000 0', '--config', 'security.syscalls.intercept.mknod=true']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/8567/bin/snapcraft", line 8, in <module>
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/cli.py", line 228, in run
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/cli.py", line 204, in _run_dispatcher
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
    return self._loaded_command.run(self._parsed_command_args)
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 259, in run
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 132, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 208, in run
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 249, in _run_command
    _run_in_provider(project, command_name, parsed_args)
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 530, in _run_in_provider
    with provider.launched_environment(
  File "/snap/snapcraft/8567/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_providers/lxd/lxd_provider.py", line 126, in launched_environment
    instance = launch(
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_providers/lxd/launcher.py", line 205, in launch
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_providers/lxd/lxd_instance.py", line 407, in launch
  File "/snap/snapcraft/8567/lib/python3.8/site-packages/craft_providers/lxd/lxc.py", line 557, in launch
    raise LXDError(
craft_providers.lxd.errors.LXDError: Failed to launch instance 'snapcraft-xxx-on-amd64-for-amd64-47979909'.
* Command that failed: "lxc --project snapcraft launch craft-com.ubuntu.cloud-buildd:core22 local:snapcraft-xxx-on-amd64-for-amd64-47979909 --config 'raw.idmap=both 1000 0' --config security.syscalls.intercept.mknod=true"
* Command exit code: 1
* Command output: b'Creating snapcraft-xxxc-on-amd64-for-amd64-47979909\n'
* Command standard error output: b'Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Invalid devices: Failed detecting root disk device: No root device could be found\n'

Help! :frowning:

@mr_cal do you know what could be happening here?

It’s hard to say. There are a two things working against us:

  1. Snapcraft isn’t tracking the state of the instance, so we don’t know if it something went wrong during the previous launch, setup, or warmup of the instance. (issue is here)

  2. snap remove --purge snapcraft doesn’t remove lxd instances and images, so this command doesn’t get to a clean state. This is on our roadmap.

I’d start with snapcraft clean, which will remove the instance. If that doesn’t work, there is a possibility you need to remove the cached image too, which I described here:

the not-so-pretty workaround is going to be to run snapcraft clean and delete the cached LXD image (which you can see with lxc --project snapcraft image list).

Hello! Thomas on the LXD forum helped me out.

The problem was caused because the snapcraft project in the default LXD profile uses the default storage pool, which in my case pointed to a partition with not enough disk space left. The solution was to create a storage pool somewhere else (which I had done, and named default since I had removed entirely the previous storage pool), and to edit the snapcraft project configuration (and not only the default profile configuration) to point to that new storage pool.

In a nutshell:

lxc profile edit default --project snapcraft

and update the devices section from

    name: eth0
    network: lxdbr0
    type: nic


    name: eth0
    network: lxdbr0
    type: nic
    path: /
    pool: default
    type: disk
1 Like