jasonrobinson
Enthusiast
Enthusiast

Get-Snapshot SizeMB property bug in 4.1

Anyone else notice that the SizeMB property on the get-snapshot cmdlet is still reporting wrong data with PowerCLI 4.1?

_____________

Jason

Twitter: @jrob24

Jason @jrob24
0 Kudos
15 Replies
LucD
Leadership
Leadership

I don't think that Get-Snapshot is reporting "wrong" data, it's a matter of how vSphere interpretes how the size of a snapshot is calculated.

As I already explained in my yadr – A vdisk reporter post, the hypervisor logic points internally for a snapshot to the previous files.

For example, in the object that represents the first snapshot, the file pointers will point to the original VMDK files.

So the disk size, in SizeMB, that you see in the first snapshot of a guest, is the size of the original vdisks that existed when the snapshot was taken.

I found that unlogical as well, and that was one of the reasons I wrote the yadr script.

To help you visualise this you can create an UML diagram of a guest that has one or more snapshots.

See my UML diagram your VM, vdisks and snapshots post for that.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kevo12
Enthusiast
Enthusiast

Samething here... SizeMB property does not reflect the real size of the snapshot.

0 Kudos
LucD
Leadership
Leadership

Might I ask how you determine the real size of the snapshot ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kevo12
Enthusiast
Enthusiast

Manually... I added up the sizes of the delta disk and the .vmsn file.

0 Kudos
LucD
Leadership
Leadership

But that is not the way vSphere calculates the snapshot size.

See the explanation in my yadr – A vdisk reporter post.

In short, for the size of the first snapshot the system will take the size of the original vmdk files.

That was the main reason why I wrote my yadr script.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kevo12
Enthusiast
Enthusiast

thanks for the info...

But adding up the sizes of the delta disk should tell me how much additional storage is being used as a result of the snapshots. Right?

Thats all I'm looking for...

0 Kudos
LucD
Leadership
Leadership

Correct, and that's exactly what I explain in my yadr post.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonrobinson
Enthusiast
Enthusiast

So any clue where the value for 'Snapshot Space' is pulled from on the Storage View? Because that what I would like to add to an existing daily report we have.

_____________

Jason

Twitter: @jrob24

Jason @jrob24
0 Kudos
LucD
Leadership
Leadership

I suspect that value is calculated like this

$report = @()
Get-View -ViewType VirtualMachine |%{
	$vm = $_
	$fileList = @()
	$vm.LayoutEx.Disk | %{
		$_.Chain | Select -Skip 1 | %{
			$_.FileKey | %{
				$fileList += $_
			}
		}
	}
	$snapSize = 0
	$vm.LayoutEx.File | where{$fileList -contains $_.Key} | %{
		$snapSize += $_.Size
	}
	$row = "" | Select Name,'Snapshot Space (GB)'
	$row.Name = $vm.Name
	$row.'Snapshot Space (GB)' = "{0:N2}" -f ($snapSize/1GB)
	$report += $row
}
$report

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonrobinson
Enthusiast
Enthusiast

Ok I ran that and it doesnt translate to exactly what vCenter is saying. The script above reported 0.22GB and VC reported 4.01GB so there is still a fairly large decrepancy.

_____________

Jason

Twitter: @jrob24

Jason @jrob24
0 Kudos
LucD
Leadership
Leadership

Strange, ran it again in my environment and it seems to produce the correct sizes.

Did you do an "Update" in the Storage Views tab ?

Anything special about that specific guest and it's snapshots ?

Are the figures incorrect for all guests ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonrobinson
Enthusiast
Enthusiast

Ok I ran it against another vCenter and I still saw some decrepancies. From my research it looks like VC is only counting the vmsn file size and the script above is counting the snapshot vmdks. I assume that if we deleted the snapshot that we would clean up the total disk space of both the vmsn and the snapshot vmdks, so I would like to collect both values.

_____________

Jason

Twitter: @jrob24

Jason @jrob24
0 Kudos
LucD
Leadership
Leadership

That could indeed be the explanation, the .vmsn file.

We have a rule of not taking memory in a snapshot, that explains why I don't see the discrepancy.

I'll give you an updated script in a minute.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

Can you check if this gives a better result.

$report = @()
Get-View -ViewType VirtualMachine |%{
	$vm = $_
	$fileList = @()
	$vm.LayoutEx.Disk | %{
		$_.Chain | Select -Skip 1 | %{
			$_.FileKey | %{
				$fileList += $_
			}
		}
	}
	$snapSize = 0
	$vm.LayoutEx.File | where{$fileList -contains $_.Key -or "snapshotList","snapshotData" -contains $_.Type} | %{
		$snapSize += $_.Size
	}
	$row = "" | Select Name,'Snapshot Space (GB)'
	$row.Name = $vm.Name
	$row.'Snapshot Space (GB)' = "{0:N2}" -f ($snapSize/1GB)
	$report += $row
}
$report

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
admin
Immortal
Immortal

Hi guys,

Look at the blog post about snapshot size -> http://blogs.vmware.com/vipowershell/2010/09/snapshot-size.html

It describes how the snapshot size is calculated. Also you can find a script that can be used now to get correctly calculated snapshot size.

Vitali

PowerCLI team

0 Kudos