18

sudo btrfs subvolume show / outputs

/
    Name:           @
    uuid:           1f0da442-cdf3-144c-a4ce-f6c06248cfde
    Parent uuid:        -
    Creation time:      2014-08-16 19:06:51
    Object ID:      257
    Generation (Gen):   30683
    Gen at creation:    6
    Parent:         5
    Top Level:      5
    Flags:          -
    Snapshot(s):
                @apt-snapshot-release-upgrade-utopic-2014-11-28_15:10:02

Now, I want to delete the snapshot @apt-snapshot-release-upgrade-utopic-2014-11-28_15:10:02.

I tried:

sudo btrfs subvolume delete @apt-snapshot-release-upgrade-utopic-2014-11-28_15:10:02

Only got:

Transaction commit: none (default)
ERROR: error accessing '@apt-snapshot-release-upgrade-utopic-2014-11-28_15:10:02'

2 Answers 2

10

I have a set of 3 drives running btrfs for data (not the operating system drive), and after testing it I found that btrfs snapshots behave like subvolumes.

For example, you can create a read-only snapshot like so:

sudo btrfs subvolume snapshot -r /mnt/data/some_dir /mnt/data/@some_dir-snapshot-test

Then, to delete the snapshot again:

sudo btrfs subvolume delete /mnt/data/@some_dir-snapshot-test

Be very careful not to delete the original subvolume! It's very easy to accidentally delete the original subvolume instead of the snapshot if you're not careful. Make sure you have tested backups!

5
  • I have mounted whole drive to /home point. It's formatted as btrfs. I have my user home directory there. Few days ago I delete 70 gigabyte of data from /home/my-user/Downloads and /home/my-user/torrents. The free space measure didn't move a tiny bit. I thought that I have to delete snapshots so I did the way You provided. It helped a little. I recovered only 20GB. Do you know what is going on? How can I recover all that free space? Best regards!
    – Marecky
    Apr 5, 2021 at 23:30
  • @Marecky I once had a situation where I couldn't free 1TB of data because I had it mounted as a loopback device. Have you tried rebooting yet? You might also want to run a full balance: sudo btrfs balance start -v /absolute/path/to/mount/point. Apr 6, 2021 at 18:37
  • 1
    Thanks, I did something like trim SSD and it btrfs recalculated the free space. I'm not quite sure it helped. It could be something else. I wanted to run btrfs balance but I think I made a restart and it was the thing.
    – Marecky
    Apr 7, 2021 at 0:06
  • I think I lost some data. Is it possible to delete data when removing snapshots? How I could recover it? What is the original subvolume? The one with id = 1? I deleted it
    – Marecky
    Apr 7, 2021 at 10:17
  • @Marecky If snapshots contain data that isnt' present anywhere else, then yes you can delete data when deleting snapshots. The id of the root subvolume is 5. That would be a different question though here on Stack Exchange, but my immediate advice is take a block-for-block backup copy of the hard drive, and work from that. Apr 7, 2021 at 23:14
2

Here is good answer

The snapshot exists in the real root of the filesystem, which is not what you have mounted in /. You have the /@ subvolume mounted in /, so there is no such file with that name. You have to mount the real root volume somewhere and use that path to reference the snapshot.

Or you can use apt-btrfs-snapshot delete instead.

1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Toto
    Nov 22, 2021 at 17:29

You must log in to answer this question.

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