I have a regular directory than contains directly underneath it several btrfs snapshots. Is it safe to do an rm -rf on the parent directory, or do I need to first do a btrfs subvolume delete SUBVOL on each of the snapshots before removing the parent directory?


2 Answers 2


rm -rf is not unsafe per se, so go ahead and run it. However, it won't completely work. For some reason, an empty Btrfs subvolume cannot be removed with the rmdir(2) system call.

rm -rf will remove all of the contents of all of the subvolumes (regular files, etc...) but the empty subvolumes themselves as well as the parent directories of all those subvolumes will remain. You will have to delete those with btrfs subvolume delete and then run rm -rf again to take care of all the now-empty non-subvolume directories that couldn't be deleted earlier.

You probably know that deleting a subvolume with btrfs subvolume delete is much faster than deleting all its contents. So if you know ahead of time that the directory tree you are about to rm -rf has subvolumes in it, you can save yourself some work and time by btrfs subvolume delete'ing them first, then running rm -rf (which will work completely) after that.


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 .