14

OpenSUSE (among other distributions) uses snapper to take snapshots of btrfs partitions. Some people think the default snapshot intervals take up too much space too quickly, but whether or not you believe that, there are times when you want to clear space on your filesystem and often find that the btrfs snapshots are taking a significant amount of space. Or, in other cases you may want to clear the filesystem of all excess data before moving it to/from a VM or changing the storage medium or something along those lines.

But, I can't seem to find a command to quickly wipe all of the snapshots snapper has taken, either via snapper or another tool. How would I do this?

22

The command in recent versions of snapper is (I don't remember when it was introduced, but the version in e.g., openSUSE 13.2 supports this):

snapper delete number1-number2

So to delete all snapshots (assuming you have no more than 100000 of them) you'd do:

snapper delete 1-100000

Obviously this only deletes snapshots on the default root config, so for a different config it would be:

snapper -c configname delete number1-number2
  • I'm now getting an error: Snapshot '100000' not found. – Pavel Šimerda Jan 30 '18 at 17:07
  • ty, ty, ty. noting, the range operator didn't work, i had to manually delete all 20 snapshots. – Paul Vixie Jul 28 '18 at 15:26
3

You can use a for loop to delete all snapshots within a range (run as root).

# for i in `seq 1 999`; do snapper delete $i; done

This will hit some invalid entries (when the number doesn't correspond to a snapshot ID), which will result in a harmless error log.

To determine the range (lower and upper limit) of snapshot IDs, so that the loop won't run unnecessarily long, use:

snapper list

I found this solution along with a discussion about how to reduce the snapper interval and retention settings.

-1

If you're working on an older version of snapper like on Debian jessie, you can use bash-expansion:

snapper delete {1..999}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.