VMware Cloud Community
Robszar55
Contributor
Contributor
Jump to solution

expand guest disk

Set-HardDisk -HardDisk $Disk -CapacityGB $extendedCapacityTo -GuestCredential $guestCred -Confirm:$false

the disk is extended but not in the guest OS, am I missing something?  The $guestCred is a domain admin and I can login to the VM with the creds fine

0 Kudos
1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

Hello, Robszar55-

I would say that the guest partition is not resized due to the way that you are using the Set-HardDisk cmdlet.  While you are using basically Example 2 from the help for Set-HardDisk, and that example clearly states that "The command also extends the disk on the guest OS", it looks like that the example is missing the -ResizeGuestPartition parameter.

By default, Set-HardDisk will not try to resize the guest partition.  Adding the -ResizeGuestPartition parameter is what has the cmdlet call the guest-OS-specific script file that resides in the vSphere PowerCLI installation on your machine.  So, like:

Set-HardDisk -HardDisk $Disk -CapacityGB $extendedCapacityTo -ResizeGuestPartition -GuestCredential $guestCred -Confirm:$false

This assumes a couple of things:

0)  that the hard disk with the partition that you are wanting to resize is not the system drive

1)  that the partition that you want to resize is the last partition on the hard disk

If those are incorrect assumptions, it is just a matter of specifying some additional parameters to the Set-HardDisk call (and possibly doing the partition resize while the VM is powered off).

But, if those two assumptions are true, give the code above a shot.

View solution in original post

0 Kudos
3 Replies
mattboren
Expert
Expert
Jump to solution

Hello, Robszar55-

I would say that the guest partition is not resized due to the way that you are using the Set-HardDisk cmdlet.  While you are using basically Example 2 from the help for Set-HardDisk, and that example clearly states that "The command also extends the disk on the guest OS", it looks like that the example is missing the -ResizeGuestPartition parameter.

By default, Set-HardDisk will not try to resize the guest partition.  Adding the -ResizeGuestPartition parameter is what has the cmdlet call the guest-OS-specific script file that resides in the vSphere PowerCLI installation on your machine.  So, like:

Set-HardDisk -HardDisk $Disk -CapacityGB $extendedCapacityTo -ResizeGuestPartition -GuestCredential $guestCred -Confirm:$false

This assumes a couple of things:

0)  that the hard disk with the partition that you are wanting to resize is not the system drive

1)  that the partition that you want to resize is the last partition on the hard disk

If those are incorrect assumptions, it is just a matter of specifying some additional parameters to the Set-HardDisk call (and possibly doing the partition resize while the VM is powered off).

But, if those two assumptions are true, give the code above a shot.

0 Kudos
Robszar55
Contributor
Contributor
Jump to solution

thanks for the quick reply, so I can't expand the system disk?  I need to shut it down first?  do you know the correct parameters for this case?

0 Kudos
mattboren
Expert
Expert
Jump to solution

Hello again-

Yes, you are welcome.

As for expanding the system disk, the docs say that it is possible, with the assistance of a "helper" VM.  So, to do this, one would need:

0)  a helper VM with a supported Guest OS for partition operations

1)  to shut down both the target VM (with the partition to resize) and the helper VM

Then, the command with the additional parameters would be like:

## both the target VM with the disk for the partition resize and the "helper" VM must be powered off beforehand
Set-HardDisk -HardDisk $Disk -CapacityGB $extendedCapacityTo -ResizeGuestPartition -GuestCredential $guestCred -Confirm:$false -HelperVM $myHelperVM

If the partition to resize is not the last one on the disk, you would add the -Partition parameter as well, with the corresponding value for the parameter to resize.  This goes through a series of operations to put the virtual disk on the helper VM, power up said VM, etc.  Roughly:

0)  resize the virtual hard disk on the target VM

1)  reconfigure the target VM, detaching the target disk from it

2)  reconfigure the helper VM, adding the target disk to it

3)  power on the helper VM

4)  try to resize the partition on the target disk via the helper VM

5)  shutdown the helper VM

6)  reconfigure the helper VM, detaching the target disk from it

7)  reconfigure the target VM, adding the target disk back to it

I have not heard many reports of success with this, though -- would like to hear how it does for you.

0 Kudos