2

If I understand correctly, btrfs snapshots store just what changed with respect to a base filesystem called the "first root filesystem". My first root filesystem was created in 2017 and thus snapshots are pretty big because a lot changed since then. Is it possible to make my current file system the "first root filesystem" so that snapshots are not that heavy?

6
  • BTRFS snapshots reference data at the time the snapshots were taken. When you attempt to change that data, it first gets copied leaving the original data intact. If you keep many snapshots, then sure they can use up a lot of storage space in total, but the individual snapshots themselves don't grow in size. It sounds like you have snapshots referencing old data don't use anymore. To free up space, simply delete the snapshots you don't need. Commented Oct 23, 2020 at 8:52
  • Thanks for the answer. However, my first root file system (snapshot number #1) has the date: Wed 31 May 2017. If I restore to that snapshot, wouldn't I move to the fielsystem that I had on that date?
    – M. Buil
    Commented Oct 26, 2020 at 17:52
  • Yes. Snapshots are also directories, so you can even take a peak to see what's in the snapshot. Commented Oct 26, 2020 at 19:16
  • But that means the changes between my today's filesystem and my filesystem on Wed 31 May 2017 must be kept somewhere. The amount of changes must be huge and growing everyday and thus the required space to store those changes, or? So, how can the snapshots not grow in size?
    – M. Buil
    Commented Oct 27, 2020 at 11:52
  • I think you are equating BTRFS snapshots to diffs, such as those used in Git. I made the same assumption at first. A snapshot is the data frozen in time; No diffs are involved. Here's a simple experiment to prove it: Create a subvolume, change the data in it, and snapshot it. Repeat, say... a handful of times to simulate recording changes in Git. Then, delete some intermediate snapshots. You'll notice that the remaining snapshots remain unaffected. In fact, if diffs were being used deleting intemediate snapshots would wreck the filesystem. Commented Oct 27, 2020 at 22:13

1 Answer 1

1

BTRFS snapshots reference data at the time the snapshots were taken. When you attempt to change that data, it first gets copied, leaving the original data intact. If you keep many snapshots, then sure they can use up a lot of storage space in total, but the individual snapshots themselves don't grow in size. It sounds like you have snapshots referencing old data don't use anymore. To free up space, simply delete the snapshots you don't need.

Explanation

Simply put, a snapshot is data frozen in time; No diffs are involved, nor is it similar in implementation to LVM snapshots. Here's a simple experiment to prove it:

  1. Create a subvolume.
  2. Change the data in it.
  3. Snapshot it.
  4. Repeat, say... a handful of times to simulate recording various changes.
  5. Delete some of the intermediate snapshots.

You'll notice that the remaining snapshots remain unaffected. If diffs were being used, then deleting intemediate snapshots would not be allowed because they would destroy the filesystem.

1
  • I was almost going to argue with this, "well then why is first root filesystem way larger then everything else? 17 vs everything else single digits!" Then I realized it was 17MiB vs GiB for everything else. That mistake is what lead me to search this topic. I wonder how many others have done the same.
    – EricS
    Commented Dec 31, 2023 at 15:27

You must log in to answer this question.

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