Using thin provisioned disks with virtual machines
search cancel

Using thin provisioned disks with virtual machines

book

Article ID: 337348

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

Symptoms:
This article provides information on thin provisioned disks within VMware ESXi/ESX.

Environment

VMware ESX 4.0.x
VMware vSphere ESXi 5.1
VMware vCenter Server 5.1.x
VMware vCenter Server 5.5.x
VMware vCenter Server 4.0.x
VMware ESXi 3.5.x Embedded
VMware ESXi 4.0.x Installable
VMware vCenter Server 5.0.x
VMware vSphere ESXi 5.5
VMware ESX Server 3.5.x
VMware ESX Server 3.0.x
VMware vSphere ESXi 5.0
VMware ESX 4.1.x
VMware ESXi 4.0.x Embedded
VMware ESXi 4.1.x Embedded
VMware ESXi 4.1.x Installable
VMware ESXi 3.5.x Installable
VMware VirtualCenter 2.0.x
VMware VirtualCenter 2.5.x

Resolution

What is a thin provisioned disk?

When creating a virtual disk file, by default VMware ESXi/ESX uses a thick type of virtual disk. The thick disk pre-allocates all of the space specified during the creation of the disk. For example, if you create a 10 megabyte disk, all 10 megabytes are pre-allocated for that virtual disk.

In contrast, a thin virtual disk does not pre-allocate the space. Blocks in the VMDK file are not allocated and backed by physical storage until they are written during the normal course of operation. Reading an unallocated block returns zeroes, but the block is not backed with physical storage until it is written.

Considerations

When implementing thin provisioning in VMware environment:
  • Thin provisioned disks can grow to the full size specified at the time of virtual disk creation, but do not shrink. After allocating blocks, blocks cannot be un-allocated.
     
  • By implementing thin provisioned disks, you are able to over-allocate storage. If storage is over-allocated, thin virtual disks can grow to fill an entire datastore if left unchecked.
     
  • With NFS datastores, the provisioned disk format is thin provisioned by default and cannot be changed. With vSphere 5.0, you can specify the provisioned format. For example, you can specify thick provisioning if the storage array or filer supports it through VAAI.
     
  • VMware ESX 3.x is not aware of thin provisioning when reporting disk space usage using VMware Infrastructure Client and VirtualCenter.
     
  • VMware ESX 4.x is aware of thin provisioning in the form of the storage views plug-in for vCenter Server.
     
  • When a thin provisioned disk grows, the VMFS metadata must be locked to make changes to a file. The ESXi/ESX host must make a SCSI reservation to make changes. For more information about SCSI reservations, see Analyzing SCSI Reservation conflicts on VMware Infrastructure 3.x, vSphere 4.x and vSphere 5.x (1005009).
     
  • If a guest operating system needs to make use of a virtual disk, the guest operating system must first partition and format the disk to a file system it can recognize. Depending on the type of format selected within the guest operating system, the format may cause the thin provisioned disk to grow to full size.

    For example, if you present a thin provisioned disk to a Microsoft Windows operating system and format the disk, unless you explicitly select the Quick Format option, the Microsoft Windows format tool writes information to all of the sectors on the disk, which in turn inflates the thin provisioned disk to full size.

How is thin provisioning used in VMware ESXi/ESX?

In ESX 3.x and VirtualCenter 2.x, the use of thin provisioning should be limited to templates. When deploying a virtual machine that used for production, VMware recommends using the Deploy a VM from template option instead of the Convert this template to VM option. This ensures that the virtual machine which is deployed using thick virtual disks. In ESX 3.x, the use of thin virtual disks in production may result in performance degradation since disk space for the thin disks is allocated as the disks grow, and the allocated disk space is likely not contiguous.

In ESX/ESXi 4.x and later versions, thin virtual disks are fully supported in production environments. You can specify whether you want create a thin or thick disk when creating virtual machines or adding disks to existing virtual machines.

Verifying how much space a thin provisioned virtual disk file is using

These steps demonstrate the differences between a normal and a thin disk using the service console. Similar steps can be used to verify the space usage of a pre-existing thin provisioned virtual disk file:

Note: These steps make use of the du command, which is only available in the ESX classic service console.
  1. Create a normal virtual disk file by running the command:

    vmkfstools -c 10M normal.vmdk
     
  2. Run the command:

    ls -alh normal*.vmdk

    The output is similar to:

    -rw------- 1 root root 10M Oct 28 11:34 normal-flat.vmdk
    -rw------- 1 root root 367 Oct 28 11:34 normal.vmdk


    Note the file sizes. In the example above, the ls utility reports that the normal-flat.vmdk file is 10 MB in size as specified in step 1.
     
  3. Run the command:

    du -h normal*.vmdk

    The output is similar to:

    10M normal-flat.vmdk
    64K normal.vmdk


    Note that the du (disk usage) utility also reports that the normal-flat.vmdk file is 10 MB in size.
     
  4. Remove the files by running the command:

    vmkfstools -U normal.vmdk
     
  5. Create a thin virtual disk file by running the command:

    vmkfstools -c 10M -d thin thin.vmdk
     
  6. Run the command:

    ls -alh thin*.vmdk

    The output is similar to:

    -rw------- 1 root root 10M Oct 28 11:34 thin-flat.vmdk
    -rw------- 1 root root 391 Oct 28 11:34 thin.vmdk


    Note the file sizes. In the example above, the ls utility reports that the thin-flat.vmdk file is 10 MB in size as specified in step 7.
     
  7. Run the command:

    du -h thin*.vmdk

    The output is similar to:

    2.0M thin-flat.vmdk
    64K thin.vmdk


    Note: The du (disk usage) utility reports that the thin-flat.vmdk file is only 2 MB in size.
     
  8. Remove the files by running the command:

    vmkfstools -U thin.vmdk

Thin provisioning and storage devices

Depending on the type of storage device you are using to house a virtual disk file, it may employ a similar mechanism on the back end to maximize storage. When using NFS to store your virtual disks, you may observe similar disk usage to that of a thin provisioned virtual disk. The lower disk usage can be observed even when explicitly creating a normal or thick virtual disk.

These steps demonstrate thin provisioning on an NFS datastore:

Note: These steps make use of the du command, which is only available in the ESX classic service console.
 
  1. Log into the ESX host via the Service Console as root.
     
  2. Navigate to an NFS datastore.
     
  3. Create a normal virtual disk file by running the command:

    vmkfstools -c 10M thick.vmdk
     
  4. Run the command:

    ls -alh thick*.vmdk

    The output is similar to:

    -rw------- 1 root root 10M Oct 28 11:34 thick-flat.vmdk
    -rw------- 1 root root 367 Oct 28 11:34 thick.vmdk


    Note the file sizes. In the example above, the ls utility reports that the thick-flat.vmdk file is 10 MB in size as specified in step 3.
     
  5. Run the command:

    du -h thick*.vmdk

    The output is similar to:

    136K thick-flat.vmdk
    8.0K thick.vmdk


    Note: The du (disk usage) utility reports that the thick-flat.vmdk file is only 136 KB in size.
     
  6. Remove the files by running the command:

    vmkfstools -U thick.vmdk

Note: When using thin provisioned disks with Microsoft operating systems such as Windows 2008 or Windows 7, if you perform a Full Format of the disk, this will inflate the thin provisioned disk to the full size. To avoid this situation, select the option to perform a Quick Format. 

Additional Information

For more information, see:
For translated versions of this article, see:

 

Analyzing SCSI Reservation conflicts on VMware Infrastructure 3.x, vSphere 4.x, vSphere 5.x and vSphere 6.0
Utilizar discos de aprovisionamiento fino con máquinas virtuales
Como usar discos com provisionamento dinâmico com máquinas virtuais
将精简置备磁盘用于虚拟机
仮想マシンでのシン プロビジョニング ディスクの使用
VMware 上でシンプロビジョニングで作成したディスクでは、Windows 2012 の 「データ重複除去」 機能を有効にしても領域が解放されない