this post was submitted on 05 Oct 2024
6 points (100.0% liked)

btrfs

112 readers
1 users here now

founded 1 year ago
MODERATORS
 

Let's say i made 10 snapshots on top of the base.

Now can i delete snap no. 5? Will the snaps after 5 will be affected?

Solved

Yes, one can delete consecutive snapshots. The data won't be deleted unless all snaps ( reference points ) get deleted.

Note: If you delete the original file and delete all the snapshots made when the file is still there, the file will get deleted permanently.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] seaQueue@lemmy.world 2 points 1 month ago (1 children)

If you want a better mental model of how snapshots work think of it like this: every file on disk is comprised of data blocks. The filesystem keeps a map of what data blocks belong to what files and how many references there are to these blocks. If a data block is referenced in the current running version of the filesystem as well as snapshots B C and D there will be 4 references in that block's count. If B C and D are removed the reference count drops to 1. If the file is then modified (ie: overwritten with new data) the number of references to the original block drops to zero and it will be marked to be freed for reuse.

How long data is kept around depends on whether or not anything on the filesystem (files or files contained in snapshots) still points to that data. It's a lot like reference counting and garbage collecting in memory if that helps. All of this to say: it doesn't matter if you delete snapshots from the middle of a sequence, later snapshots will retain references to data that they need so the data will be kept until the reference count for it drops to 0.

[โ€“] gpstarman 1 points 1 month ago