Checking VMFS version and block sizes with PowerCLI 2

It is an important practice to stay up to date on your VMFS versions as you upgrade vSphere. I have seen many clients that have upgraded from 4.1 to 5.0 or even directly to 5.1 without ever checking on their datastores. They assume that just because their VMs are up and running that they are good to go. VMware lists updating the VMFS versions in their upgrade guides for a reason! Due to the increased frequency of this problem in client environments, I decided to publish this post.

I came across the below snippet of PowerCLI code (thanks goes out to Luc Dekens), that queries all datastores and displays the version of VMFS and the respective filesystem block sizes.

The following benefits / limitations come from VMware KB2003813.

Why switch to VMFS-5?

  • Improved scalability and performance.
  • Does not use SCSI-2 Reservations, but uses the ATS VAAI primitives.
  • Uses GPT (GUID Partition Table) rather than MBR, allowing for pass-through RDM files greater than 2TB.
  • Newly created VMFS-5 datastores use a single block size of 1MB.
  • Supports very small files (<1KB) by storing them in the metadata rather than in the file blocks.
  • Uses sub-blocks of 8K rather than 64K, which reduces the space used by small files.
  • Uses SCSI_READ16 and SCSI_WRITE16 cmds for I/O (VMFS-3 used SCSI_READ10 and SCSI_WRITE10 cmds for I/O).

What are the limitations for VMFS-5?

  • VMFS-5 limits the number of extents to 32 and the total datastore size to 64TB, but the individual extents are not limited to 2TB each. For example, you can create a datastore with a LUN size of 64TB, or one with up to 32 extents up to maximum size of 64TB.
  • Only pass-through RDMs (Raw Device Mapping) can be created with a size >2TB. Non-pass-through RDMs and virtual disk files are still limited to 512B ~ 2TB.
  • Passthrough RDMs are supported up to ~60TB in size.
  • Both upgraded and newly-created VMFS-5 volumes supported the larger Passthrough RDM size.

It is also important to note that VMFS volumes can be upgraded on the fly with no downtime.  Snippet from the same VMware KB:

Can I upgrade while my virtual machines are running?
Yes. Upgrading from VMFS-3 to VMFS-5 can be done on-the-fly (virtual machines do not need to be powered-off, suspended, or migrated).

To check VMFS version & block sizes:

Get-Datastore | Get-View | Select-Object Name,@{N="VMFS version";E={$_.Info.Vmfs.Version}},@{N="BlocksizeMB";E={$_.Info.Vmfs.BlockSizeMB}}

To automatically upgrade from VMFS3 to VMFS5 with no downtime (again, thanks go out to Luc Dekens):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function ConvertTo-Vmfs5{
<# .SYNOPSIS  Upgrade a datastore to VMFS5 .DESCRIPTION The function will convert the datastores that   are passed to it to VMFS5. .NOTES  Author:  Luc Dekens .PARAMETER Datastore   The datastore(s) to be upgraded   The parameter accepts a string or an object returned by the   Get-Datastore cmdlet. .EXAMPLE   PS> ConvertTo-Vmfs5 -Datastore "DS*"
.EXAMPLE
  PS> Get-Datastore -Name "DS1" | ConvertTo-Vmfs5
#>
 
  param(
  [CmdletBinding()]
  [parameter(Mandatory = $true, ValueFromPipeline = $true)]
  [PSObject[]]$Datastore
  )
 
  process{
    foreach($ds in $Datastore){
      if($ds.getType().Name -eq "string"){
        $ds = Get-Datastore -Name $ds
      }
      $poweredHosts = $ds.ExtensionData.Host | %{Get-View -Id $_.Key} |
      where {$_.Runtime.PowerState -eq "PoweredOn"}
 
      $oldHost = $poweredHosts | 
      where {$_.Capability.SupportedVmfsMajorVersion -notcontains 5}
      if($oldHost){
        Write-Warning "One of the connected hosts doesn't support VMFS5"
        exit
      }
      $vmfsPath = $ds.ExtensionData.Host[0].MountInfo.Path
      $storSys = Get-View ($poweredHosts | Get-Random).ConfigManager.StorageSystem
 
      $storSys.UpgradeVmfs($vmfsPath)
    }
  }
}
 
function Get-VmfsPartitionInfo{
<# .SYNOPSIS  Retrieves partition info for a datastore .DESCRIPTION The function will retrieve partition information   for one or more datastores .NOTES  Author:  Luc Dekens .PARAMETER Datastore   The datastore(s) for which the partition info shall be   returned. The parameter accepts a string or an object   returned by the Get-Datastore cmdlet. .EXAMPLE   PS> Get-VmfsPartitionInfo -Datastore "DS*"
.EXAMPLE
  PS> Get-Datastore -Name "DS1" | Get-VmfsPartitionInfo
#>
  param(
  [CmdletBinding()]
  [parameter(Mandatory = $true, ValueFromPipeline = $true)]
  [PSObject[]]$Datastore
  )
 
  process{
    foreach($ds in $Datastore){
      if($ds.getType().Name -eq "string"){
        $ds = Get-Datastore -Name $ds
      }
      $poweredHosts = $ds.ExtensionData.Host | %{Get-View -Id $_.Key} |
      where {$_.Runtime.PowerState -eq "PoweredOn"}
      $storSys = Get-View ($poweredHosts | Get-Random).ConfigManager.StorageSystem
 
      $ds.ExtensionData.Info.Vmfs.Extent | %{
        $devicePath = "/vmfs/devices/disks/" + $_.DiskName
        $storSys.RetrieveDiskPartitionInfo($devicePath) | %{
          New-Object PSObject -Property @{
            Name = $ds.Name
            Version = $ds.FileSystemVersion
            Device = $_.DeviceName
            PartitionFormat = $_.Spec.PartitionFormat
            BlockSizeMB = $ds.ExtensionData.Info.Vmfs.BlockSizeMb
            Blocks = $_.Layout.Total.Block
          }
        }
      }
    }
  }
}