How to delete a btrfs snapshot

btrfssnapshot

I'm new to btrfs and I am trying to delete some snapshots I made a few months ago. They're taking up about 20GB of space, and I need that space back.

This seems to list the snapshots:

↪ sudo btrfs subvolume list /
ID 257 gen 82021 top level 5 path @
ID 258 gen 82021 top level 5 path @home
ID 263 gen 81983 top level 5 path @home/.ecryptfs/mlissner/.Private/ECRYPTFS_FNEK_ENCRYPTED.FWa8iOdaTukmNEROkGj4b5OZHZ0bKOqrvAQxu4dgX.2jUELJL22wpV94oU--/ECRYPTFS_FNEK_ENCRYPTED.FWa8iOdaTukmNEROkGj4b5OZHZ0bKOqrvAQxHunTlBS-30iHyukjeY9-EE--/root_post_install_2014-04-29
ID 364 gen 81986 top level 5 path @home/.ecryptfs/mlissner/.Private/ECRYPTFS_FNEK_ENCRYPTED.FWa8iOdaTukmNEROkGj4b5OZHZ0bKOqrvAQxu4dgX.2jUELJL22wpV94oU--/ECRYPTFS_FNEK_ENCRYPTED.FWa8iOdaTukmNEROkGj4b5OZHZ0bKOqrvAQxHunTlBS-30iHyukjeY9-EE--/root_post_install_2014-05-04
ID 376 gen 81996 top level 5 path @home/.ecryptfs/mlissner/.Private/ECRYPTFS_FNEK_ENCRYPTED.FWa8iOdaTukmNEROkGj4b5OZHZ0bKOqrvAQxu4dgX.2jUELJL22wpV94oU--/ECRYPTFS_FNEK_ENCRYPTED.FWa8iOdaTukmNEROkGj4b5OZHZ0bKOqrvAQxHunTlBS-30iHyukjeY9-EE--/root_post_install_2014-05-14

How do I delete them? When I try the obvious thing, I get an error:

↪ sudo btrfs subvolume delete root_post_install_2014-04-29
Delete subvolume '/home/mlissner/.btrfs/snapshots/root_post_install_2014-04-29'
ERROR: cannot delete '/home/mlissner/.btrfs/snapshots/root_post_install_2014-04-29' - Device or resource busy

I'm feeling a bit lost and Googling is revealing no real help. I'm happy to post more information if that will help, but for now, I'm a baffled how to proceed.

Best Answer

From the output, I am guessing that the subvolume of which you have snapshots is actually an ecryptfs private directory. If that is correct, can you try unmounting the private directory and then try to delete the snapshots?

The error message states that the device is in use. Assuming you are not using that directory as a current working directory, and no other process is actively using the data in the snapshot, that leaves the encryption layer to worry about.

EDIT: my original assumption was that you only had a Private folder encrypted. From your comments, I guess that your whole home is encrypted. So if we want to manipulate that, we need your home to be inactive. For a convenient way to deal with this, you can try the following:

A. Add another user to the system giving that other user administrative rights (i.e. the right to use sudo). Instructions for how to do this in Ubuntu: add a user, then give the user administrative rights

B. Log on with the newly created user. Now try to list and destroy the snapshots. Make sure the original user is not logged in, as that will trigger the decryption (and thus, the use) of you home directory.

C. Remove the user created in the first step, unless you see a need to keep it around.

Oh, and, please make sure you have a back-up of the file systems you manipulate. A mistake is quickly made.

Related Topic