Btrfs
如何刪除名稱中帶有 <FS_TREE> 的 btrfs 子卷
我有一堆像這樣的 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'
刪除這些快照的正確語法是什麼?
我能夠通過首先安裝整個 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
最簡單的方法是使用內置
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