无法删除卷已满的 LXC 容器及其卷本身

无法删除卷已满的 LXC 容器及其卷本身

我最近一直在研究 LXC/LXD,结果发现有几个容器停止了:

❯ lxc list
+------------------------------------+---------+------+------+-----------+-----------+
|                NAME                |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |
+------------------------------------+---------+------+------+-----------+-----------+
| build                              | STOPPED |      |      | CONTAINER | 0         |
+------------------------------------+---------+------+------+-----------+-----------+
| build-2020-05-27-180024-06f86fd0ac | STOPPED |      |      | CONTAINER | 0         |
+------------------------------------+---------+------+------+-----------+-----------+

清理时间:

❯ lxc delete build
Error: Error deleting storage volume: Failed deleting subvolume "/var/snap/lxd/common/lxd/storage-pools/default/containers/build": Failed to run: btrfs subvolume delete /var/snap/lxd/common/lxd/storage-pools/default/containers/build: ERROR: cannot delete '/var/snap/lxd/common/lxd/storage-pools/default/containers/build': No space left on device
❯ lxc storage info default
info:
  description: ""
  driver: btrfs
  name: default
  space used: 970.61MB
  total space: 1000.00MB
used by:
  containers:
  - build
  - build-2020-05-27-180024-06f86fd0ac
  images:
  - 40775fd923e2a77f56ce3c028ce22ad43b9254bb12766b12eeeefb32a3a145da
  profiles:
  - default

显然音量太小了。我解决这个问题的简单方法是通过 将音量大小从 增加到。1G由于没有明显的方法应用更改的设置,我相信它会自动应用。结果发现并非如此(正如事后所报告的那样)。10GBlxc storage edit defaultlxc storage editlxc storage info default

下次尝试:让我们删除叛乱卷,以便我可以删除容器:

❯ lxc storage volume list default
+-----------+------------------------------------------------------------------+-------------+---------+
|   TYPE    |                               NAME                               | DESCRIPTION | USED BY |
+-----------+------------------------------------------------------------------+-------------+---------+
| container | build                                                            |             | 1       |
+-----------+------------------------------------------------------------------+-------------+---------+
| container | build-2020-05-27-180024-06f86fd0ac                               |             | 1       |
+-----------+------------------------------------------------------------------+-------------+---------+
| image     | 40775fd923e2a77f56ce3c028ce22ad43b9254bb12766b12eeeefb32a3a145da |             | 1       |
+-----------+------------------------------------------------------------------+-------------+---------+
❯ lxc storage volume delete default build-2020-05-27-180024-06f86fd0ac
Error: not found

现在我有点不知所措。我有什么选择可以删除容器(或调整卷大小 - 这反过来应该允许删除)?


更新 1:以下是有关所用系统的一些规格。

❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
❯ snap list | grep lxd
lxd    4.1    15161    latest/stable    canonical*        -

更新 2:同时,我尝试“手动”调整卷大小,如下所示:

truncate -s +500G /var/snap/lxd/common/lxd/disks/default.img
mount -t btrfs /var/snap/lxd/common/lxd/disks/default.img /mnt/test
sudo btrfs filesystem resize max /mnt/test/
reboot # because why not, hopfeully lxd catches up

重启后,我可以成功删除图像和卷。

此时一切看起来都很好。然而,当我创建一个新容器时,它拒绝删除它,并出现与上述相同的症状。卷也是如此。

据说lxc storage show default升级到 10G 后重启后 lxd 就能识别。我认为不可能真的达到了 10G 容量。

相关内容