2

I have been reading about LVM Snapshots, and I have a general understanding of how it works. If a snapshot is made of source data, I understand that the copy-on-write (COW) means that if a modification is made to existing source volume data, then the "old" data from the source volume is copied to the snapshot volume before the source data is modified.

My question is specifically about what happens to the snapshot volume when "new" data is written to the source volume (ie. not modifying data that is in the source volume already). Is this new data copied to the snapshot volume?

1 Answer 1

3

The short answer is no, new data isn't copied to the snapshot volume. A snapshot really is just that, in appearances anyway: a snapshot of a volume, frozen at the time the snapshot was taken.

At the LVM level, the system doesn't know that you're writing new data – it just sees blocks being written, and it doesn't know if the data being written is replacing an existing file or creating a new one.

3
  • Thanks! Now that I think about it a bit more, that makes sense. The "original" data is copied over to the snapshot volume, but for new writes the original data is nothing, which means that nothing should be copied to the snapshot volume. Mar 18, 2016 at 22:58
  • To be clear on this: I have a file of 10M on the source. I appended some data in that file. Now the file size is 15M. Then the 10M file will be copied on the snapshot. If I do the same thing all over again, by making the 15M file to 20M, then the 15M file will replace the 10M file on the snapshot ? Is that right ? May 22, 2021 at 5:56
  • 1
    @Kavish no, a snapshot remains as it was when it was created, just like a photograph. You need to create a new snapshot if you want to preserve a later state. May 22, 2021 at 6:05

You must log in to answer this question.

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