I'm working on a workflow that i plan on publishing as an XAAS to our Windows Support Team to utilize that allows them to extend OS disks. I have the code down to extend the vmdk, but i'm having issues extending the partition inside the OS. I'm working of info from this blog post here. I've also tried diskpart, but just can't seem to get this to work. Anybody else get this to work, or maybe know how to do this?
Thanks
The significant challenge here is not the in-guest partition extension, but the fact that you cannot programatically correlate the virtual disk IDs from the virtual hardware side to the mount points inside the guest. I've looked at that in the past and this is always the blocker. The issue arises when you have more than one disk of the same size and you wanted to extend one but not the other. There's no way to identify that disk from the other.
Where/how are you getting the disk's UUID?
this code run in the guest returns the UUID based on drive letter:
$driveletter = "%%driveLetter"
$colDiskDrives = get-wmiobject -query "Select * From Win32_DiskDrive"
$allDrive = @()
Foreach ($drive in $colDiskDrives)
{
$o_drive = New-Object PSObject
$a = $drive.DeviceID.Replace("\", "\\")
if($drive.serialnumber -ne $null)
{
$o_drive | Add-Member -type NoteProperty -Name UUID -value $drive.SerialNumber
$colPartitions = get-wmiobject -query "Associators of {Win32_DiskDrive.DeviceID=""$a""} WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Foreach ($Partition in $colPartitions)
{
$b = $Partition.DeviceID
$colLogicalDisk = get-wmiobject -query "Associators of {Win32_DiskPartition.DeviceID=""$b""} WHERE AssocClass = Win32_LogicalDiskToPartition"
If ($colLogicalDisk.Caption -ne $null)
{
$o_drive | Add-Member -type NoteProperty -Name DriveLetter -value $colLogicalDisk.Caption.ToString()
}
Else
{
#No letter assigned.
}
}
}
else
{
#No UUID found.
}
$allDrive += $o_drive
}
($allDrive | ? {$_.DriveLetter -eq "$($driveletter):"}).UUID.toUpper()
This code in a task, mathes the UUID returned from the guest to the UUID on the disk:
System.log(returned_uuid);
for each (var device in vm.config.hardware.device)
{
if (device instanceof VcVirtualDisk)
{
//System.log(device.backing.uuid);
//System.log(System.getModule("com.vmware.pscoe.library.util").replaceAll(device.backing.uuid,"-",""));
diskuuid = System.getModule("com.vmware.pscoe.library.util").replaceAll(device.backing.uuid,"-","").substring(0,31).toUpperCase();
if (diskuuid == returned_uuid.substring(0,31))
{
disk = device;
System.log(device);
}
}
}
This appears to be targeted towards Windows (PowerShell). I do have some code laying around if I can find it. The challenge with volume extensions is detecting how the existing volume/partition is configured and extending it in the same manner. Unless you know it's all going to be the same X way and you just code for that.
Your variable $driveletter = "%%driveLetter". How is this getting set? Replacing %%driveLetter with a drive letter causes a null value error on the last line.
Yes, this is geared towards Windows.
So, the script is held in a resource. I have the resource as a attribute on the workflow. Then, in a task, i pass a variable in from the user input and replace it like this:
script = scriptResource.getContentAsMimeAttachment().content;
script = script.replace("%%driveLetter",driveLetter);
I'm looking for my PS code but can't seem to locate it. Do you just need help with the PS in order to extend the filesystem?
Need some more information in that case. Can you share a full workflow with everything intact? Where are you getting a failure? Also, the driveletter variable, what is that supposed to be replaced with? Just a letter? Because if I sub that out in the PS I get a null value error.
And just a side note, the disk.EnableUUID flag has to be set on the vm in order for all this to work.