VMware Cloud Community
malabelle
Enthusiast
Enthusiast

Increase Datastore

Hi,

is there a way to increase a datastore by powercli?

I tried with vcli and it gives me that

C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>vmkfstools.pl --growfs /vmfs/devices/naa.600507630affc1f30000000000000040:1 --server esx1.domain.local --username root --password "blablabla"
Unknown option: growfs
For a summary of command usage, type 'C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vmkfstools.pl --help'.
For documentation, type 'perldoc C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vmkfstools.pl'.
vExpert '16, VCAP-DCA, VCAP-DCD
0 Kudos
4 Replies
LucD
Leadership
Leadership

Afaik there is no PowerCLI cmdlet to extend a datastore.

You can do it by using the vSphere API from PowerCLI, but it is a rather complex process.

How to use the vmkfstools.pl script is documented in KB1009125


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

0 Kudos
malabelle
Enthusiast
Enthusiast

Thanks. I had read it, but it doesn't work when I try the last command.

[root@esx1 ~]# esxcfg-scsidevs -l -d naa.600507630affc1f30000000000000040
naa.600507630affc1f30000000000000040
   Device Type: Direct-Access
   Size: 81920 MB
   Display Name: IBM Fibre Channel Disk (naa.600507630affc1f30000000000000040)
   Plugin: NMP
   Console Device: /dev/sdal
   Devfs Path: /vmfs/devices/disks/naa.600507630affc1f30000000000000040
   Vendor: IBM       Model: 2107900           Revis: 5.63
   SCSI Level: 5  Is Pseudo: false Status: on
   Is RDM Capable: true  Is Removable: false
   Is Local: false
   Other Names:
      vml.0200210000600507630affc1f30000000000000040323130373930

[root@esx1 ~]# vmkfstools --growfs /vmfs/devices/disks/vml.0200210000600507630affc1f30000000000000040323130373930:1 /vmfs/devices/disks/vml.0200210000600507630affc1f30000000000000040323130373930:1
Error: No such file or directory

What I don't understand, since the "Increase" option is a GUI button, it odd it is not scriptable by powercli, don't you think?

vExpert '16, VCAP-DCA, VCAP-DCD
0 Kudos
LucD
Leadership
Leadership

You can do this in a PowerCLI script but it will require the use of some SDK API.

Have a look with Onyx what goes on behind the scene when you click the Increase button.


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

0 Kudos
malabelle
Enthusiast
Enthusiast

Ok, thanks, good Idea, I did'nt think about Onyx

here it is.

# ------- QueryAvailableDisksForVmfs -------

$datastore = New-Object VMware.Vim.ManagedObjectReference
$datastore.type = "Datastore"
$datastore.value = "4d6e5ef0-4151b9f4-6e1a-f4ce46880b48"

$_this = Get-View -Id 'HostDatastoreSystem-ha-datastoresystem'
$_this.QueryAvailableDisksForVmfs($datastore)

# ------- QueryVmfsDatastoreExpandOptions -------

$datastore = New-Object VMware.Vim.ManagedObjectReference
$datastore.type = "Datastore"
$datastore.value = "4d6e5ef0-4151b9f4-6e1a-f4ce46880b48"

$_this = Get-View -Id 'HostDatastoreSystem-ha-datastoresystem'
$_this.QueryVmfsDatastoreExpandOptions($datastore)

# ------- QueryVmfsDatastoreExtendOptions -------

$datastore = New-Object VMware.Vim.ManagedObjectReference
$datastore.type = "Datastore"
$datastore.value = "4d6e5ef0-4151b9f4-6e1a-f4ce46880b48"

$_this = Get-View -Id 'HostDatastoreSystem-ha-datastoresystem'
$_this.QueryVmfsDatastoreExtendOptions($datastore, "/vmfs/devices/disks/naa.600507630affc1f30000000000000040", $true)

# ------- ComputeDiskPartitionInfo -------

$layout = New-Object VMware.Vim.HostDiskPartitionLayout
$layout.total = New-Object VMware.Vim.HostDiskDimensionsLba
$layout.total.blockSize = 8225280
$layout.total.block = 12270
$layout.partition = New-Object VMware.Vim.HostDiskPartitionBlockRange[] (1)
$layout.partition[0] = New-Object VMware.Vim.HostDiskPartitionBlockRange
$layout.partition[0].partition = 1
$layout.partition[0].type = "vmfs"
$layout.partition[0].start = New-Object VMware.Vim.HostDiskDimensionsLba
$layout.partition[0].start.blockSize = 8225280
$layout.partition[0].start.block = 0
$layout.partition[0].end = New-Object VMware.Vim.HostDiskDimensionsLba
$layout.partition[0].end.blockSize = 8225280
$layout.partition[0].end.block = 12269

$_this = Get-View -Id 'HostStorageSystem-storageSystem'
$_this.ComputeDiskPartitionInfo("/vmfs/devices/disks/naa.600507630affc1f30000000000000040", $layout)

# ------- ComputeDiskPartitionInfoForResize -------

$partition = New-Object VMware.Vim.HostScsiDiskPartition
$partition.diskName = "naa.600507630affc1f30000000000000040"
$partition.partition = 1

$blockRange = New-Object VMware.Vim.HostDiskPartitionBlockRange
$blockRange.partition = 1
$blockRange.type = "vmfs"
$blockRange.start = New-Object VMware.Vim.HostDiskDimensionsLba
$blockRange.start.blockSize = 8225280
$blockRange.start.block = 0
$blockRange.end = New-Object VMware.Vim.HostDiskDimensionsLba
$blockRange.end.blockSize = 8225280
$blockRange.end.block = 12269

$_this = Get-View -Id 'HostStorageSystem-storageSystem'
$_this.ComputeDiskPartitionInfoForResize($partition, $blockRange)

# ------- ExpandVmfsDatastore -------

$datastore = New-Object VMware.Vim.ManagedObjectReference
$datastore.type = "Datastore"
$datastore.value = "4d6e5ef0-4151b9f4-6e1a-f4ce46880b48"

$spec = New-Object VMware.Vim.VmfsDatastoreExpandSpec
$spec.diskUuid = "0200210000600507630affc1f30000000000000040323130373930"
$spec.partition = New-Object VMware.Vim.HostDiskPartitionSpec
$spec.partition.chs = New-Object VMware.Vim.HostDiskDimensionsChs
$spec.partition.chs.cylinder = 12270
$spec.partition.chs.head = 255
$spec.partition.chs.sector = 63
$spec.partition.totalSectors = 197132288
$spec.partition.partition = New-Object VMware.Vim.HostDiskPartitionAttributes[] (1)
$spec.partition.partition[0] = New-Object VMware.Vim.HostDiskPartitionAttributes
$spec.partition.partition[0].partition = 1
$spec.partition.partition[0].startSector = 128
$spec.partition.partition[0].endSector = 197117549
$spec.partition.partition[0].type = "vmfs"
$spec.partition.partition[0].logical = $false
$spec.partition.partition[0].attributes = 0
$spec.extent = New-Object VMware.Vim.HostScsiDiskPartition
$spec.extent.diskName = "naa.600507630affc1f30000000000000040"
$spec.extent.partition = 1

$_this = Get-View -Id 'HostDatastoreSystem-ha-datastoresystem'
$_this.ExpandVmfsDatastore($datastore, $spec)

vExpert '16, VCAP-DCA, VCAP-DCD
0 Kudos