artemnet
Contributor
Contributor

How to extend vmdk for a multiple vms?

Jump to solution

Hello!

I have a 300+ vm`s on vsphere5.1 and i need to extend system drive on all of them. Have any ideas how to do it with powercli? Thanks.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You could try something like this.

It will increase the vmdk size by 20%. Note that the VM needs to be powered off for this.

Get-VM | 
Where {$_.PowerState -eq "PoweredOff"} |
Get-HardDisk -Name "Hard disk 1" |
Set-HardDisk -CapacityGB ([int]($_.CapacityGB * 0.2)) -Confirm:$false -HelperVM $vm

You can find another example in Need a powercli script to increase Harddisk1 of VMs in a folder by 20GB, can someone give a script..


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

View solution in original post

0 Kudos
10 Replies
LucD
Leadership
Leadership

There are other factors that could influence the method to be used.

See 1.  Re: Grow a VMs disk via PowerCLI


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

0 Kudos
artemnet
Contributor
Contributor

At this step I don't need resize partition inside guest. I have problem with grow up vmdk files for a list of vms and how to grow up only vmdk with the windows system directory

0 Kudos
LucD
Leadership
Leadership

The Set-Harddisk cmdlet can be used to extend a VMDK.

Can your VMs have multiple harddisks ?

Any specific guest OS on these VMs ?


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

0 Kudos
artemnet
Contributor
Contributor

Yes, some of vms have more than one vmdk and no, nothing special inside guests, only windows

0 Kudos
LucD
Leadership
Leadership

There is no foolproof method to link a guest OS partition to a VMDK file.

Is there only 1 guest partition on a VMDK ?

Is the system partition always on "Hard disk 1" ?


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

0 Kudos
artemnet
Contributor
Contributor

yes, system partition is always on hd1 and only one partition inside this vmdk.

0 Kudos
LucD
Leadership
Leadership

You could try something like this.

It will increase the vmdk size by 20%. Note that the VM needs to be powered off for this.

Get-VM | 
Where {$_.PowerState -eq "PoweredOff"} |
Get-HardDisk -Name "Hard disk 1" |
Set-HardDisk -CapacityGB ([int]($_.CapacityGB * 0.2)) -Confirm:$false -HelperVM $vm

You can find another example in Need a powercli script to increase Harddisk1 of VMs in a folder by 20GB, can someone give a script..


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

0 Kudos
artemnet
Contributor
Contributor

Thank you

0 Kudos
artemnet
Contributor
Contributor

can you explain why i need keeping my vms in powered off state while this script is running? if i can do this task from gui without power off vm why i cant do this way via powercli?

0 Kudos
LucD
Leadership
Leadership

That is a requirement to use the HelperVM afaik.

An alternative is to use diskpart inside the guest OS.

See for example  5.  Re: Grow a VMs disk via PowerCLI


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

0 Kudos