LVM Snapshot Storage Requirements

Programster

I'm a bit confused about how LVM snapshots are stored and work. I understand that when you create a snapshot with LVM, it doesn't take up any space, but as you make changes to the files on your system, your LVM snapshot volume will grow in size. If they grow in size past the size of their partition, they will be "dropped" and disappear, which is why it is not a good backup solution (other than the fact that it's also on the same physical system).

Does LVM snapshot storage work like the diagram below?

enter image description here

I am trying to show a scenario where the root filesystem partition is mostly empty and has a small amount of data shown in purple. I create a snapshot partition called "Snapshot 1" that gradually fills up when I make changes to the original files, although I'm pretty sure LVM is block-based rather than file-based.

Question

Does this mean that if I had a 100 GB root partition that was only storing 20GB of data, I would never need to worry about my snapshot partition overflowing if I gave it a 21GB size? Or would the snapshot partition have to be as large or larger than the root partition because it also records the differences of the unused space (blocks of 0's)?

Emmanuel Rosa

Unfortunately, the storage requirements are not quite that straight forward:

COW snapshots are created when a size is specified. The size is allocated from space in the VG, and is the amount of space that can be used for saving COW blocks as writes occur to the origin or snapshot. The size chosen should depend upon the amount of writes that are expected; often 20% of the origin LV is enough. If COW space runs low, it can be extended with extend (shrinking is also allowed with lvreduce.) A small amount of the COW snapshot LV size is used to track COW block locations, so the full size is not available for COW data blocks. Use lvs to check how much space is used, and see --monitor to to automatically extend the size to avoid running out of space. - man lvcreate

Note how the man page doesn't mention any particulars:

...often 20% of the origin LV is enough...A small amount of the COW snapshot LV size is used...

The conclusion I draw from this is that there's no specific way to calculate exactly what size the snapshot LV needs to be to ensure it never runs out of space.

Essentially, since the snapshot LV stores the original blocks prior to being changed, in order for it to never run out of space it would have to be large enough to hold the origin LV plus a little bit more so it can track the COW block locations.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Snapshot size in lvm

LVM snapshot not updating when LVM is modified

LVM Snapshot Tutorial on Ubuntu Server

How large should an LVM snapshot be?

how to snapshot thin provisioned lvm

Unable to drop LVM2 snapshot of rootfs

Encrypting data written to an LVM snapshot with a different key

Proper way to remove an active / inactive LVM snapshot

LVM snapshot - performance for write-only data

How to "keep" data from an LVM snapshot?

BackupPc doesn't backup mounted LVM Snapshot?

lvm: create snapshot between volume groups

LVM snapshot: Failed to wipe snapshot exception store, udev doesn't create the partition before lvm tries to wipe it

How to pause MySQL before taking an LVM/ZFS snapshot?

LVM Snapshot - Copy on write - does it apply to new data?

shared LVM storage between KVM virtuals

Azure File Storage - Revert to prior snapshot

Internal storage requirements of C++ UnorderedAssociativeContainer

Converting existing disk to lvm, so I can increase the storage?

Why is the loop-lvm device storage not suitable for production?

Recommended storage scheme for home server? (LVM/JBOD/RAID 5...)

How do I extend the storage space on a lvm filesystem in Linux?

How to create a read-only snapshot in LVM, and then rollback to it after some work?

How do I avoid booting into BusyBox when reverting from LVM snapshot?

Can't return the value on snapshot on firebase cloud storage

How to process a file from one to another without doubled storage requirements?

Requirements in order to control a Linux controller via MegaRAID Storage Management on Windows

Can I use Eigen sparse matrices for general storage requirements

AWS Free Tier services by usage - 1 GB of Amazon Elastic Block Storage snapshot storage | Unable to find where I am using storage