VMware Cloud Community
artemnet
Contributor
Contributor
Jump to solution

How to extend vmdk for a multiple vms?

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
artemnet
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
artemnet
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
artemnet
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
artemnet
Contributor
Contributor
Jump to solution

Thank you

Reply
0 Kudos
artemnet
Contributor
Contributor
Jump to solution

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?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos