<

How to Increase VMWare Hard Disk Size?

Published on
6,967 Points
3,867 Views
1 Endorsement
Last Modified:
How to Increase VMWare Hard Disk Size?
(Taken from my web log: http://blog.mrt-web.com)

I've been playing with virtual machines and testing some odd things that can not be easily tested on a real computer, suddenly I come across to a situation that my virtual machine's hard disk size needed to be increased.

It is one simple command! You just need to go where you installed VMWare WorkStation, there is a file named: vmware-vdiskmanager.exe

You just need to open a command window and run:


vmware-vdiskmanager.exe -x sizeGB virtualDiskFile.vmdk


That's all.
1
Comment
2 Comments
 
LVL 3

Expert Comment

by:Virtalicious
Some considerations worthy of mention here is that if this is the system disk or a MFT Based disk then you will still need to increase the partition sizes to enable the extra space for usability.

Partition Magic / Diskpart / Easus Partition Manager
for example.

If the disk is dynamic then you can extend the volume however this is not a solution viable on boot disks.

If you do not have any of the above and you want to do it for free, you can download vmconverter and do a V2V conversion and resize the disks in the advanced settings for the hard disks.  These geometric changes will get transferred over into the FAT/MFT Tables and you can just convert and go with no additional steps.

-V
0
 
LVL 2

Expert Comment

by:itnifl
I see this is WorkStation that is used here, but just adding some  info about vSphere if it has any value:

In VMWare Sphere, after expanding the disk via the vSphere Client on the virtual machine, you can expan the disk inside the operating system with extpart.exe if the operatig system is Windows 2003(any version):
http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=R64398

This goes for system partitions, dynamic disks, or basic disks.

If you are dealing with a Windows 2008 or Windows 2012 server, you simply use disk manager that comes standard with the operating system and expand the partition in need by right clicking it and choose expand/extend. If any error occurs, or you are not seeing the newly available disk space, rightclick diskmanager and choose to rescan to see if that resolves the problem.

If you are automating extending  of disk drives in a large vSphere environment, you can use the following powershell script function that needs PowerCli installed where it is run from:

function ExtendVMWareDisk {
	param([Parameter(Mandatory=$True)] [string] $vCenterHost, 
		[Parameter(Mandatory=$True)] [string] $vCenterUser, 
		[Parameter(Mandatory=$True)] [string] $vCenterPass,		
		[Parameter(Mandatory=$True)] [string] $localUser,
		[Parameter(Mandatory=$True)] [string] $localPassword,
		[Parameter(Mandatory=$True)] [string] $vmname,
		[Parameter(Mandatory=$True)] [int] $diskNo,
		[Parameter(Mandatory=$True)] [int] $sizeGB
	)
	
	if(-not (Get-PSSnapin VMware.VimAutomation.Core 2> $NULL)) { 
		if ($host.Name -eq "ConsoleHost") {Write-Host -ForeGroundColor Yellow "Adding VMWare Snapin"}
		Add-PSSnapin VMware.VimAutomation.Core 
	}
	
	function ConnectVIServer([string]$vCenterHost, [string]$vCenterUser, [string]$vCenterPass) {
		#The Following is compatible with version 5.1 of powercli: 
		if ($host.Name -eq "ConsoleHost") {Write-Host -ForeGroundColor Yellow "Connecting to vCenter: $vCenterHost"}
		Set-PowerCLIConfiguration -DefaultVIServerMode Single -InvalidCertificateAction Ignore -WebOperationTimeoutSeconds -1 -confirm:$false
		Connect-VIServer -Server $vCenterHost -User $vCenterUser -Password $vCenterPass
	}

	ConnectVIServer $vCenterHost $vCenterUser $vCenterPass
	
	if ($host.Name -eq "ConsoleHost") {Write-Host -ForeGroundColor Yellow "Creating local logon credentials.."}
	$password = ConvertTo-SecureString -String $localPassword -AsPlainText -Force
	$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $localUser, $password
	
	$props = @{
		errorID = 0;
    }
	$diskName = "Hard disk {0}" -f $diskNo
	if ($host.Name -eq "ConsoleHost") {Write-Host -ForeGroundColor Yellow "Extending '$diskName' to $sizeGB GB on '$vmname'"}
	try {
		if($sizeGB -gt (Get-HardDisk $vmname | where {$_.Name -eq $diskName}).CapacityGB) {
			Get-HardDisk $vmname | where {$_.Name -eq $diskName} | Set-HardDisk -CapacityGB $sizeGB -ResizeGuestPartition -GuestCredential $credentials -Confirm:$false
		}	
	} catch {
		$props["errorID"] = 1;
		$props.Add("failedItem", $_.Exception.ItemName);
		$props.Add("errorMessage", @("ERROR: 1 Could not extend '$diskName' to $sizeGB GB on '$vmname': " + $_.Exception.Message));
		return $props
	}
	return $props
}

Open in new window

0

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Join & Write a Comment

Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…
Teach the user how to use configure the vCenter Server storage filters Open vSphere Web Client:  Navigate to vCenter Server Advanced Settings: Add the four vCenter Server storage filters: Review the advanced settings: Modify the values of the four v…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month