My root file system is on a btrfs partition. My /chroot directory has a number of btrfs subvolumes in it which prevent me from deleting it with rm -rf /chroot. In an attempt to delete all the subvolumes, I tried listing just the subvolumes below /chroot by using the -o, which the man page says "print only subvolumes below specified path".

# btrfs subvolume list -o /chroot
ID 593 gen 6616 top level 5 path chroot/base-devel/root
ID 594 gen 6618 top level 5 path chroot/multilib-devel/root
ID 595 gen 6620 top level 5 path chroot/base/root
ID 597 gen 6624 top level 5 path chroot/twm/root
ID 599 gen 6628 top level 5 path chroot/lxde/root
ID 601 gen 6655 top level 5 path chroot/wheezy/root
ID 602 gen 6684 top level 5 path chroot/sid/root
ID 603 gen 6862 top level 5 path var/lib/machines

To my surprise, this returns the subvolume in /var/lib/macines (which I do not want to delete). This leads me to 3 questions:

  1. What does the -o option do?

  2. How do I list only subvolumes below /chroot

  3. How can I delete a directory with an unknown number of subvolumes?

I am running Arch Linux with the 4.2.5 kernel and btrfs-progs v4.3.1

  • What kernel are you running and what version of the btrfs tools do you have installed? This is probably a bug in the tools.
    – David King
    Dec 23, 2015 at 16:31
  • @DavidKing see edit. I am running a fairly recent kernel and btrfs-progs.
    – StrongBad
    Dec 23, 2015 at 19:15
  • I would file a bug report with btrfs. In the mean time could you pipe the list of directories through grep chroot?
    – David King
    Dec 24, 2015 at 1:21
  • yes I often wonder if I delete all subvolumes including @ will that wipe out my root fs! worlds most annoying power feature.
    – Tomachi
    Aug 4, 2021 at 4:54

3 Answers 3


The following command removes all subvolumes in the /chrootdirectory:

ls /chroot | xargs btrfs subvolume delete

In case there are files or directories that are not btrfs subvolumes present, an error will be printed, but they are not removed.

(Tested on Debian with the 4.6.0 kernel and btrfs-progs v3.17)

  • I get ERROR: Not a Btrfs subvolume: Invalid argument when I try this with /mnt/kubuntu/@/.snapshots running from another AVLinux install . Yet btrfs subvolume list ./ shows heaps in there. Final one is ID 4302 gen 13347652 top level 4103 path 12/snapshot
    – Tomachi
    Jul 15, 2021 at 20:00

The path in btrfs subvolume delete <path> supports globbing.

For example, I had a subvolume that was being snapshot and each snapshot was its own subvolume. (ie /mnt/newDrive/.snapshots/1/snapshot/new_subvol was its own subvolume) :

user@machine:/mnt/newDrive/.snapshots$ tree
├── 1
│   ├── info.xml
│   └── snapshot
│       └── new_subvol
├── 104
│   ├── info.xml
│   └── snapshot
│       └── new_subvol
├── 111
│   ├── info.xml
│   └── snapshot
│       └── new_subvol

To delete all these subvolumes all I had to do was

sudo btrfs subvolume delete /mnt/newDrive/.snapshots/*/snapshot/new_subvol

After that, all the subvolumes were gone and and I could easily delete /mnt/newDrive/.snapshots with

rm -rf /mnt/newDrive/.snapshots

Hope this is helpful!


To answer your third question, you can use btrfs-rm.

I use it on a docker installation running on btrfs, to cleanup the whole docker dir on a regular basis. Use at your own risk, but works for me (TM).

sudo ./btrfs-rm  /var/lib/docker/*   # create clean empty dir for docker

Download: https://github.com/DirkTheDaring/btrfs-rm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .