Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / VMWare / How to Increase Virtual Machine Disk Size in VMware

June 8, 2023 VMWare

How to Increase Virtual Machine Disk Size in VMware

The main advantage of virtual machines is the flexibility to allocate additional resources to VMs when you need them. If you run out of free space on a virtual hard disk, you can extend it quickly and easily. This article describes how to resize a virtual machine disk in VMware ESXi and then extend the partition in Windows or Ubuntu guest OS without stopping or rebooting the virtual machine.

Contents:
  • Increase the Size of VM Disk (VMDK) in VMware
  • Extend a Partition in a Windows Virtual Machine
  • How to Extend Partition in Linux Virtual Machine?

When it comes to increasing the size of a VMware virtual machine’s hard disk, there are some limitations to consider:

  • You cannot increase the disk if the VM has snapshots. All snapshots must be removed;
  • Only disks connected via virtual SCSI or NVMe controller can be expanded online (if the virtual disk is connected via IDE controller, the virtual machine must be shut down first);
  • The extending option is not supported for Linked Clone VMs (on Vmware Horizont);
  • If you see a warning in the VM panel that says ‘Virtual Machine disks consolidation is needed’, you need to consolidate VM disks;
  • The online extension of virtual machine disks (without shutting down the VM) is only possible if the VMware Tools are installed in the guest operating system. If VMTools is not installed, an error occurs after changing the virtual disk size:
    Operation failed
    Task name
    Reconfigure virtual machine
    The attempted operation cannot be performed in the current state (Powered on).

Cannot increase VMDK size on VMware: The attempted operation cannot be performed in the current state

The process of increasing a virtual machine’s disk size takes two steps:

  1. First, you need to increase the VMDK file size in the VM settings on vCenter/ESXi;
  2. Then extend the disk partition in the guest OS (we will take a separate look at how to extend the hard drive on both Windows and Linux).

Increase the Size of VM Disk (VMDK) in VMware

For example, you have a virtual machine with a single virtual hard disk file (vmdk) of 40GB, and you plan to increase this virtual disk size to 50GB.

  1. Connect to your vCenter server or a standalone ESXi host using the vSphere Web Client;
  2. Find the virtual machine and open its settings (Actions -> Edit Settings); Edit VMware VM settings
  3. Find the virtual disk you want to extend. In this example, the VM has only one Hard Disk 1 with a size of 40 GB. Specify the new disk size in this field and save the settings. Note that the maximum disk size available for this type of datastore (VMFS, NFS, vSAN) is specified in the Maximum size field; Expand a Virtual Hard Disk in VMware ESXi
Make sure that your VMFS datastore has enough free space. If required, you can increase the size of the VMFS datastore in VMWare ESXi/vCenter.

You can also use the VMware PowerCLI module cmdlets to increase the size of the virtual machine VMDK disk. Install the PowerCLI module on your computer (you can even install the PowerShell module on a Linux host) and connect to your vCenter/ESXi:

Connect-VIServer hostname

Run the following command to expand the virtual disk:

Get-HardDisk VMTest1 | where {$_.Name -eq "hard disk 1"} | Set-HardDisk -CapacityGB 50 -ResizeGuestPartition -Confirm:$false

PowerShel: expand virtual disk size in VMware

Then you can use the Invoke-VMScript cmdlet to extend a partition in the guest operating system:

Invoke-VMScript -VM VMTest1 -ScriptText "echo select vol c > c:\diskpart.txt && echo extend >> c:\diskpart.txt && diskpart.exe /s c:\diskpart.txt" -GuestUser $guestUser -GuestPassword $guestPass -ScriptType BAT

Earlier, we showed an example of how to use the Invoke-VMScript to automatically install Windows updates in VMware VM templates.

Don’t forget to terminate the PowerShell management session once you’re done:

Disconnect-VIserver -Confirm:$false

Now that you have increased the virtual disk size in the VMware console, you need to extend the partition in the guest OS

Extend a Partition in a Windows Virtual Machine

You must start the Disk Management console (Computer Management-> Storage-> Disk Management) and run the Rescan Disk command for the guest Windows OS to see the additional space.

Rescan disks in Windows

Next, select the partition you want to extend and click Extend Volume. Extend system volume in windows

Specify how many MB of unallocated space you want to add to the selected Windows partition (in the field Select the amount of space in MB).

Set new volume size in Windows

Now click Next -> Finish and check if your C drive has been successfully extended.
check new system drive size

When extending a system partition (C:\ drive), you may find that it is followed by a Windows Recovery Environment partition instead of unallocated space. In this case, the Extend Volume option will not be available in the Disk Manager (greyed out). Extend volume greyed out in Windows Disk Management

In that case, you won’t be able to extend your C: drive unless you delete or move the Recovery partition to the end of the drive. We have described this procedure in the article Extend Volume option is grayed out in Windows.

Windows XP and Windows Server 2003 don’t support the online extension of the system C: volume. You can use Dell’s ExtPart tool to expand the system partition without rebooting.

To extend the system partition in Windows 2003/XP, copy the tool to the guest operating system and run it with the following parameters:

extpart.exe c: 1020

, where c: is the name of the volume you want to extend, and 1020 is the size (in MB) you want to extend the disk by.

extpart.exe tool

You can also extend the offline VM disc partition in other ways:

  • Boot your virtual machine from any LiveCD (for example, GParted), and increase the partition;
  • Connect a virtual VMDK file to another VM and extend the partition on that machine;
  • Use the VMware vCenter Converter tool to reconfigure the volume size.

How to Extend Partition in Linux Virtual Machine?

Now let’s look at how to expand the disk partition if you have a Linux family guest operating system installed in your virtual machine.

The first thing to do is to make sure that Linux sees the new disk size. To start a rescan, run the command:

$ echo 1>/sys/class/block/sdd/device/rescan

Use the cfdisk tool to show the available virtual hard disk space:

$ sudo cfdisk

This example shows that the /dev/sda drive has 2 GB of free space. Select the partition you want to extend (which is /dev/sda3 in this example) and chose Resize from the bottom menu.

cfdisk - check free space

Then click Write to apply the changes to the partition.

increase partition

In my case, I need to extend the partition in an Ubuntu 22.04 LTS virtual machine. By default, this version of Ubuntu is installed on LVM volume:

$ sudo lsblk

lsblk shows LVM volume

Before you can extend an LVM volume, you need to increase the physical volume (PV):

$ sudo pvresize /dev/sda3

Once that’s done, you can extend the logical volume (we’ll use all the free space available):

$ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

lvextend LVM on Ubuntu VM

The next step is extending the file system:

$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Check free disk space in Linux:

$ df -h

check partioi size in ubutu

If you do not have LVM volumes, you can use the parted tool to extend partitions in Linux:

$ sudo parted

Let’s check how much unallocated space you have on the disk:

print free

As you can see, Free Space = 2149MB

parted - check free space

To extend the /dev/sda3 partition, run:

resizepart 3

Specify a new partition size (in this example, we need to specify the End size from the Free Space block):

End? [21.5GB]? 23.6G

parted extend Linux partition

Then exit the parted:

quit

All that remains is to grow an ext4/3/2 file system.

$ sudo resize2fs /dev/sda3

This article describes how to increase the size of a virtual hard disk in a VMware vSphere environment with a Windows and Linux guest operating system. In a separate article, we have explained how to reduce (shrink) the size of a virtual hard disk on VMware.

0 comment
1
Facebook Twitter Google + Pinterest
previous post
Find Out Which Process is Listening on a Specific Port on Windows
next post
Send from Alias (SMTP Proxy Address) in Exchange Online (Microsoft 365)

Related Reading

Reset Root Password in VMware ESXi

October 12, 2023

How to Fix ‘An Operating System Wasn’t Found’...

July 14, 2023

Unmounting an NFS Datastore from VMware ESXi

April 21, 2023

How to Install Free VMware Hypervisor (ESXi)

January 24, 2023

Using VMware Converter for P2V Migration (Physical to...

October 19, 2022

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Adding Drivers into VMWare ESXi Installation Image
  • How to Fix ‘An Operating System Wasn’t Found’ Error on Windows
  • How to Access VMFS Datastore from Linux, Windows, or ESXi
  • Recovering a Deleted VMFS Datastore on VMware ESXi/vSphere
  • Using iPerf to Test Network Speed and Bandwidth
  • Windows Cannot Find the Microsoft Software License Terms
  • Updating VMware ESXi Host from the Command Line
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top