Skip to main content

Expand Linux Virtual Machine Disk Partition using GParted in Proxmox

How to Expand a Virtual Hard Disk in Proxmox

In this example, we are increasing the size of a hard disk for a Debian Linux virtual machine running on Proxmox

Running the df command shows that the primary partition /dev/sda1 is 100% used and has run out of space


Expand the Virtual Hard Disk in Proxmox

Hardware - select Hard Disk - Resize disk

image.png

Increase the size of the disk, e.g. add 10GB

image.png


Download GParted

https://gparted.org/download.php

Attach GParted ISO to Virtual Machine

Hardware - select CD/DVD drive - Edit

image.png

Attach the GParted ISO

image.png


Boot VM into GParted

Start the VM and connect to the console
Press ESC for the Boot Menu

image.png

Enter to boot from DVD/CD

image.png

GParted Live (Default settings)

image.png

Dont touch keymap

image.png

Select language

image.png

Enter 0 to continue and start GParted

image.png


Resize Linux disk partition

The 10GB free space has been allocated at the end of the disk after the swap partition.
Because we can't move or resize the swap partition, we will need to delete and re-create it.

The Linux swap partition only contains temporary data, so there is minimal risk in removing it.

image.png

Delete the swap partition

Make a note of the file system type and size of the swap partition before deleting it

Select the swap partition - Partition - Delete

image.png

Select the /dev/sda2 extended partition and delete it as well

image.png

Apply all operations

image.png

Resize the primary partition

Select the primary partition /dev/sda1
Partition - Resize/Move

image.png

Change the new size and free space following to leave 1GB for the swap partition that we need to re-create

image.png

Apply all operations

 


 

 

Create new extended partition

Select the free space at the end of the drive
Partition - New

image.png

New size 1024
Create as extended partition

image.png

Apply all operations

Create swap partition

Select the free space in the newly created extended partition /dev/sda2

Partition - New

image.png

New size 1023
File system: linux-swap

image.png

Apply all operations

Swap partition has been re-created at the end of the disk, and the primary partition /dev/sda1 has been expanded

image.png

Exit GParted and shutdown VM


Error: Timed out waiting for device /dev/disk/by-uuid. 
Dependency failed for swap

image.png

To fix this, we will need to find the UUID (Unique ID) of the swap partition and update /etc/fstab
Check if the swap partition is mounted by running the swapon --show command

In this example, the swap partition isn't mounted

image.png

Find the UUID of the swap partition using blkid

sudo blkid

image.png

Edit /etc/fstab
sudo nano /etc/fstab

Replace the UUID for the swap partition in fstab with the ID you got from running blkid!

image.png

Edit /etc/initramfs-tools/conf.d/resume
sudo nano /etc/initramfs-tools/conf.d/resume

Replace the UUID with the ID you got from running blkid!

Run sudo update-initramfs -u

Restart the VM

Running swapon --show again shows that the swap partition has now been mounted

image.png

Done!

this are my private notes!

https://techlabs.blog/categories/debian-linux/expand-linux-virtual-machine-disk-partition-using-gparted

https://lists.debian.org/debian-user/2017/09/msg00866.html