Re: BTRFS snapshot space consumption (was: New laptop: need advice on choice...)
- Date: Sun, 14 Apr 2019 02:54:04 +0200 (CEST)
- From: Matthew Crews <mailinglists@xxxxxxxxxxxxx>
- Subject: Re: BTRFS snapshot space consumption (was: New laptop: need advice on choice...)
On 4/13/19 5:40 PM, Peter Wiersig wrote:
> Peter Wiersig <peter@xxxxxxxxxxxxxxx> writes:
>> I would be pissed if my OS removes snapshots I might or might not need
>> in the future. That's a release critical bug in my eyes. Yeah, I know
>> Microsoft and Apple do that automatically if your capacity runs out, but
>> that's also why I don't recommend them at all.
> Ok, I checked https://en.opensuse.org/Portal:Snapper and they do support
> LVM and ext4, and they have a bullet of auto-removing old snapshots. I
> hope they did it right, perhaps I need to make a new test drive with the
> latest release.
> Snapshots on ZFS can't be zero cost, so you need to account for them
> there, too.
ZFS Snapshots are nearly zero cost to create the snapshot, since ZFS
(and likewise BTRFS) are copy-on-write file systems. What it does is
records the deltas after the snapshots.
This is a good thinkg as it saves on disk space.
You create a random 10 MB file, and take a snapshot. You then alter the
5 tail MBs and add five more MBs at the tail. You are left with:
Pre-Snapshot | 5MB chunk #1 | 5MB chunk #2 | - total 10MBs
Post-Snapshot | 5MB chunk #1 | 5MB chunk #3 | 5MB chunk #4 | - total 15MBs
Actual disk usage will be 20 MBs, since the 5MB chunk #1 is only
recorded on disk once, not twice.
Here is a good talk on the subject by Michael Lucas, one of the premier
experts on ZFS. Its worth noting that a lot of the concepts apply to
BTRFS to varying degrees: