10

I see a lot of questions and answers surrounding thin provisioning on VMWare ESXi but not exactly what I'm encountering. I am creating a brand new VM and specifying a 100GB thin provisioned hard disk. From all I've read, I'm expecting the physical size of the vmdk file to be less than 100GB. However, it is still creating a xxx-flat.vmdk that is 100GB.

I'm trying to set up a base system that I can then simply copy around and customize like I've done with VMWare Workstation in the past. Very easy! When I power up the copy, VMWare asks me if I've copied it, I answer "yes" and I'm off and running. However, with what appears to me to be a bug in ESXi 5.5, I'll be copying around a 100GB+ which means I'd be just about as fast to reinstall the OS every time I wanted a new instance.

Has anyone experienced this?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
Thomas Doman
  • 203
  • 1
  • 2
  • 6
  • 2
    In addition to the answer by Shane and Ed, it should be pointed out that if you do a full format (rather than a quick format) on a thin provisioned disk, you'll end up occupying the full provisioned size, because a full format will write data to all the space. So.. something to keep in mind, on the general topic. – HopelessN00b Jun 26 '14 at 23:25
  • Thank you all for the answers, I'll try these methods out and report back. One detail I should have added to the original question is that the effect I'm trying to achieve is like a clone. For example, I've installed and gotten all the updates for Windows Server 2008 R2. Now I want to specialize. So, clone it and make a Domain Controller, clone it again and make an web application server, clone it again and make an SQL server. Manually copying for this approach worked fine on VMWare Workstation where it creates -snnn.vmdk files. Looks like I need to use utilities to achieve that with ESXi. – Thomas Doman Jun 27 '14 at 15:51
  • Oh, and I'm not even changing datastores. I want all these "clones" on the same datastore in ESXi. Also, I assumed that ESXi would also add -snnn.vmdk as it grew so that's why the sparse file was a surprise. – Thomas Doman Jun 27 '14 at 15:53

2 Answers2

15

That hundred gig file is a sparse file - there's nothing in it, the filesystem simply knows that's the intended size.

You can see the real size in the vSphere client:

client

..despite the apparent size when you're looking at the raw files..

console

The problem you're having is that you're removing that file from the VMFS filesystem. Wherever it's going and however it's getting there, the sparse file is only sparse as long as it's on VMFS; ESXi is forced to feed you the full apparent file, with all those extra 0s.

Storage vMotion and vmkfstools will handle thin disks correctly if you're moving between ESXi hosts; exporting to OVF is another good option for not moving around the full thick disk.

Generally speaking, you should avoid trying to work directly with the flat files, instead using the proper tools to move or clone the logical VMDK (which might have flat files, snapshots, etc).

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
7

This is because thin-provisioned files in ESXi are sparse files. The method you're using to move them around won't preserve that thin attribute.

There are ways around this. Please see: Move VMware ESXi VM to new datastore - preserve thin-provisioning

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • Also if you copy the vmdk using the vsphere client it retains its thinness when you copy the files rather than the folder containing them. (providing the new filesystem supports thin) – JamesRyan Jun 27 '14 at 10:50
  • Though both Shane and Ed gave me essentially the same options, I'm marking Ed's as the answer since his link provides more detail on each. I ultimately used File -> Export -> Export OVF template from vSphere with the name I wanted for my new VM and then I redeployed that OVF back to the same datastore. Thanks again everyone! – Thomas Doman Jun 27 '14 at 21:07