Hello,
I’m running out of space on my main desktop disk, so the default btrfs image used by LXD was too small, and in consequence creating new containers failed. In particular, I could not build snaps using snapcraft anymore.
After unsuccessfully trying to use another storage pool for snapcraft, I removed lxd entirely:
sudo snap remove --purge lxd
then reinstalled it, but skipped the storage pool creation during the init:
lxd init
I used the following commands to create a 50GB image file and use it as a btrfs storage pool:
mkdir -p /mnt/downloads/lxd/
cd /mnt/downloads/lxd/
sudo truncate -s50G 50GB.img
sudo losetup --show --find 50GB.img # this output `/dev/loop39`
lxc storage create default btrfs source=/dev/loop39
lxc storage list
+---------+--------+--------------------------------------+-------------+---------+---------+
| NAME | DRIVER | SOURCE | DESCRIPTION | USED BY | STATE |
+---------+--------+--------------------------------------+-------------+---------+---------+
| default | btrfs | 66fbe839-0c7e-4c06-8a0b-66aca8878ef6 | | 2 | CREATED |
+---------+--------+--------------------------------------+-------------+---------+---------+
I added the root device to the default profile:
lxc profile device add default root disk path=/ pool=default
Creating a container works fine:
$ lxc launch images:ubuntu/jammy jammy
Creating jammy
Starting jammy
$ lxc shell jammy
root@jammy:~#
Unfortunately, when running snapcraft
, the following error pops up:
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.
(...)
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-xxx-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'
More info from lxc:
$ lxc project list
+-------------------+--------+----------+-----------------+-----------------+----------+---------------------+---------+
| NAME | IMAGES | PROFILES | STORAGE VOLUMES | STORAGE BUCKETS | NETWORKS | DESCRIPTION | USED BY |
+-------------------+--------+----------+-----------------+-----------------+----------+---------------------+---------+
| default (current) | YES | YES | YES | YES | YES | Default LXD project | 3 |
+-------------------+--------+----------+-----------------+-----------------+----------+---------------------+---------+
| snapcraft | YES | YES | YES | YES | NO | | 2 |
+-------------------+--------+----------+-----------------+-----------------+----------+---------------------+---------+
$ lxc project show default
config:
features.images: "true"
features.networks: "true"
features.profiles: "true"
features.storage.buckets: "true"
features.storage.volumes: "true"
description: Default LXD project
name: default
used_by:
- /1.0/profiles/default
- /1.0/images/a5b7d073427e6b05f9b4907d9446548ccac9676e14a00af047482cf4a4ffbb98
- /1.0/networks/lxdbr0
$ lxc project show snapcraft
config:
features.images: "true"
features.profiles: "true"
features.storage.buckets: "true"
features.storage.volumes: "true"
description: ""
name: snapcraft
used_by:
- /1.0/profiles/default?project=snapcraft
- /1.0/images/5de93bcc5cddf2ede3e74f88c313deb056eab006dd131618a5d412dc4a5e5534?project=snapcraft
$ lxc profile list
+---------+---------------------+---------+
| NAME | DESCRIPTION | USED BY |
+---------+---------------------+---------+
| default | Default LXD profile | 1 |
+---------+---------------------+---------+
$ lxc profile show default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:
- /1.0/instances/jammy
I’m running Ubuntu 20.04, and here is my filtered out snap list
:
Name Version Rev Tracking Publisher Notes
lxd 5.8-ee04373 23972 latest/stable canonical✓ -
multipass 1.10.1 8140 latest/stable canonical✓ -
snap-store 41.3-64-g512c0ff 599 latest/stable/… canonical✓ -
snapcraft 7.2.8 8567 7.x/stable canonical✓ classic
snapd 2.57.5 17576 latest/stable canonical✓ snapd