3 minutes reading time (514 words)

Expand Hyper-V Linux Virtual Hard Disk (VHDX) using GParted

How to increase the disk size of a Hyper-V Linux Virtual Machine using GParted 

In this guide, we will increase the size of the Virtual Hard Disk (VHDX) using PowerShell, then use GParted (GNOME Partition Editor) to resize the disk partitions.

Check free disk space

Check free disk space using df

df -h

In this example, we will increase the size of the drive to 100GB

Expand Virtual Hard Disk using PowerShell Resize-VHD

# resize virtual hard disk
Resize-VHD -Path "D:\Virtual Hard Disks\kali-linux.vhdx" -SizeBytes 100000000000

# check virtual hard disk size
Get-VHD -Path "D:\Virtual Hard Disks\kali-linux.vhdx" 

Download GParted


Download gparted-live-1.4.0-1-amd64.iso

Boot VM from GParted ISO

Attach the GParted iso file to the Virtual Machine

Check the boot order to make sure that the DVD drive is first

Power on the VM and boot from the ISO file

Press [Enter] to boot GParted with default settings

Don't touch the keymap

Select your language

Enter 0 to continue and start GParted automatically

Expand the disk using GParted

Libparted Warning
Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space or continue with the current setting

This warning comes up because the virtual hard disk has changed in size. Click fix to allow Libparted to re-write the GPT partition table header.

First, we need to move the swap partition to the end of the disk

Select linux-swap partition
Click Resize/Move the selected partition

Change free space following to 0
Click Resize/Move

Click OK

Next, we need to resize the primary disk partition

Select the disk you want to resize e.g. /dev/sda2
Resize/Move the selected partition

Change new size value to use up all the available free space
Click Resize/Move

Apply all operations

Click Apply

Partition resizing in progress

Partition resizing completed
Click Close

GParted - Quit

Exit - Shutdown

Check free disk space after resizing the partition

Check free disk space again

df -h

Related Posts



No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Saturday, 23 September 2023
You can help support this website by buying me a coffee!
Buy Me A Coffee