Page 1 of 1

What makes the size of a snapshot?

Posted: 30. Sep 2017, 11:20
by Notorand.IT
I have a guest that's running on 8GB RAM and 256 GB disk.
I don't know why, but sometimes the snapshot (two files) is just a couple of GB in size.
Sometimes instead the snapshot goes close to a 200 GB in size.
What's making such a difference?

TALIA!

Re: What makes the size of a snapshot?

Posted: 30. Sep 2017, 12:43
by mpack
There is nothing random or unpredictable about it. A snapshot VDI is just a dynamic VDI, and just like any other dynamic VDI it starts off at 2MB (the header) and it never shrinks. It can only grow, as sectors are written to.

Dynamic VDI: every time a sector is written, the 1MB image block containing that sector is allocated on the host, if that 1MB block was not already allocated. Usually the VDI reaches a stable state, where the probability that the OS will use a sector that wasn't already in use diminishes close to zero. You might consider this the natural size of the VDI and is hopefully way less than the logical size. If you purposely write to every sector (e.g. by doing a disk surface scan) then you'll maximize the host size of the VDI file, effectively making it a fixed size drive.

Incidentally, this gives the lie to people who pass around the garbage urban myth that fixed VDI is faster. Take a 64GB dynamic VDI: so that is 1MB blocks x 65536. That is a maximum 65536 1MB writes - you're never going to notice that when amortized over the lifetime of the VM.

What isn't garbage is the known fact that snapshots are a house of cards waiting to collapse. I hope you make proper backups if your data is important.

Re: What makes the size of a snapshot?

Posted: 30. Sep 2017, 12:48
by Notorand.IT
Thanks for the insight.
The point is that I take two subsequent snapshots and it is the first one that becomes very large.
So, according to what you say that, the guest is making a lot of disk I/o while the snapshot is being created. Correct?
Anyway, I don't think snapshots are buggy. Do you?

Re: What makes the size of a snapshot?

Posted: 30. Sep 2017, 12:54
by mpack
Notorand.IT wrote: So you say that the guest is making a lot of disk I/o while the snapshot is being created. Correct?
No. Creating a snapshot involves no disk activity to speak of. It is the guest OS writing to the disk which creates disk activity. A new snapshot will grow quickly if the guest OS is doing a lot of writes over wide areas of the virtual disk.
Notorand.IT wrote: Anyway, I don't think snapshots are buggy. Do you?
I'm not sure I understand the question. Snapshots themselves are a concept - concepts cannot have bugs. The code which implements it sometimes has bugs, though I'm not aware of any bugs in the current implementation (5.1.28). The problems which people have with snapshots is nothing to do with bugs, it has to do with being an inherently fragile structure.

Re: What makes the size of a snapshot?

Posted: 30. Sep 2017, 13:13
by Notorand.IT
My point is that the snapshot I take, the first one, is sometimes really big.
The immediately second one is "normal".
So is the guest doing so much I/O that the snapshot gets huge and slow?

Re: What makes the size of a snapshot?

Posted: 30. Sep 2017, 15:27
by mpack
I think my previous answers should be enough to deal with that question.

Re: What makes the size of a snapshot?

Posted: 30. Sep 2017, 15:33
by Notorand.IT
mpack wrote:I think my previous answers should be enough to deal with that question.
Clearly I thought otherwise. But nevermind.