如何删除名称为<FS_TREE>的btrfs子卷


9

我有一堆这样的btrfs快照:

20:17:37 [root@galaxy /]$ btrfs subvolume list -a / |grep apt
ID 271 gen 348 top level 5 path <FS_TREE>/@apt-snapshot-2013-04-17_21:44:30
ID 272 gen 352 top level 5 path <FS_TREE>/@apt-snapshot-2013-04-17_21:46:25
ID 273 gen 361 top level 5 path <FS_TREE>/@apt-snapshot-2013-04-17_21:51:13
... # lots more

我想摆脱它们。所以我尝试了

20:21:31 [root@galaxy ~]$ btrfs subvolume delete '/<FS_TREE>/@apt-snapshot-2013-04-17_21:44:30'
ERROR: error accessing '/<FS_TREE>/@apt-snapshot-2013-04-17_21:44:30'
20:21:36 [root@galaxy ~]$ btrfs subvolume delete '<FS_TREE>/@apt-snapshot-2013-04-17_21:44:30'
ERROR: error accessing '<FS_TREE>/@apt-snapshot-2013-04-17_21:44:30'
20:21:43 [root@galaxy ~]$ btrfs subvolume delete '/@apt-snapshot-2013-04-17_21:44:30'
ERROR: error accessing '/@apt-snapshot-2013-04-17_21:44:30'
20:21:47 [root@galaxy ~]$ btrfs subvolume delete '@apt-snapshot-2013-04-17_21:44:30'
ERROR: error accessing '@apt-snapshot-2013-04-17_21:44:30'

删除这些快照的正确语法是什么?

Answers:


10

通过首先装入整个btrfs卷(而不是@子卷),然后从那里开始工作,我能够删除这些快照:

# mount /dev/mapper/whatever /mnt -o subvol=/
# ls /mnt
@
@apt-snapshot-2013-04-17_21:44:30
...

因此,在这一点上,所有子体积(包括时髦apt-snapshot的)都可见/mnt,因此我们可以删除它们:

# btrfs subvol delete /mnt/@apt-snapshot-2013-04-17_21:44:30
# umount /mnt

2
为此,您是否需要使用现场CD?
mlissner'3

2
不,我可以从@同一文件系统运行系统时执行此操作。
仙人掌

1

最简单的方法是使用内置apt-btrfs-snapshot命令:

与普通快照删除不同,您无需挂载文件系统即可删除快照。

首先,apt-btrfs-snapshot使用以下命令列出可用的快照:

sudo apt-btrfs-snapshot list

这是该命令的输出示例:

@apt-snapshot-old-root-2015-10-19_20:20:10
@apt-snapshot-2015-10-28_19:00:46
@apt-snapshot-2015-10-28_19:09:14
@apt-snapshot-2015-10-29_04:40:07
@apt-snapshot-2015-10-29_06:35:57
@apt-snapshot-2015-10-29_07:03:39
@apt-snapshot-2015-10-30_03:49:05
@apt-snapshot-2015-10-30_17:53:59

要删除快照@apt-snapshot-2015-10-30_17:53:59,请运行:

sudo apt-btrfs-snapshot delete @apt-snapshot-2015-10-30_17:53:59

您还可以按日期删除许多快照。这是一个命令示例,该命令将删除所有早于0天的快照。

sudo apt-btrfs-snapshot delete-older-than 0d   

这是该命令的输出示例:

Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-odfe0o4g/@apt-snapshot-old-root-2015-10-19_20:20:10'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-odfe0o4g/@apt-snapshot-old-root-2015-10-19_20:20:10' - Directory not empty
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-b2zv18qr/@apt-snapshot-2015-10-28_19:00:46'
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-zjglvefe/@apt-snapshot-2015-10-28_19:09:14'
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-lj3v74qa/@apt-snapshot-2015-10-29_04:40:07'
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-vztc82zr/@apt-snapshot-2015-10-29_06:35:57'
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-q0ou8e24/@apt-snapshot-2015-10-29_07:03:39'
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-dw8eq0vv/@apt-snapshot-2015-10-30_03:49:05'
Delete subvolume (no-commit): '/tmp/apt-btrfs-snapshot-mp-vgo2yuf2/@apt-snapshot-2015-10-30_17:53:59'

如您所见,可用快照已删除。但是,最旧的快照“ old-root”没有被删除,即使它早于0天,仍可以用于回滚。

运行以下命令以获取功能的完整列表:

apt-btrfs-snapshot --help

我刚刚尝试过,然后sudo apt-btrfs-snapshot delete-older-than 30d删除了所有快照...
Cactus

@Cactus如果所有快照都早于30天,那就应该这样做。要在开始之前进行验证,可以运行:sudo apt-btrfs-snapshot list-older-than 30d查看30天之前的内容。
mchid 2015年

@Cactus虽然不应该删除oldroot,但仍可以将其用作还原点。
mchid 2015年

请注意,apt-btrfs-snapshot并非在每个发行版中都是“内置”的。特别是,它似乎在Debian仓库中不可用。
user44400
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.