btrfs – How to Delete Subvolumes with in Their Name

btrfssnapshot

I have a bunch of btrfs snapshots like so:

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

I would like to get rid of them. So I tried

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'

What's the correct syntax to delete these snapshots?

Best Answer

I was able to delete these snapshots by first mounting the whole btrfs volume (not the @ subvolume) and then working from there:

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

So at this point, all subvolumes (including the funky apt-snapshot ones) are visible in /mnt, so we can delete them:

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