Here is a sample to show how I did to expand the VM, Ubuntu 22.04, disk which is running in the Proxmox VE without deleting the partition.

  • The host is Proxmox VE v8.0.3.
  • The guest is a Gitlab on Ubuntu 22.04.
  • The Local Disk Space of this VM is 64GB.
  • The disk is already 85% full.

I want to double the disk space to 128GB.

I did a lot of searches on Google. They all tell me to use fdisk the command to expand the disk by deleting the old partition and then creating a bigger one.

I have Gitlab installation on it and a lot of data. I want to resize the disk without losing data.

I found the solution to make it.

The first step is to shut down the VM.

The second step is to resize the disk of the VM.

Select Hardware > Hard Disks > Disk Action > Resize

Resize disk
Please be noticed that the size=128G, because I took this screenshot afterwards. Before that, it is 64GB.

Increase the size

Then enter the number of GB to tell the system the increment.

The third step is to power up the VM.

Check the disk usage.

davidyin@gitlab:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 1.1M 793M 1% /run
/dev/sda2 63G 51G 9.0G 85% /
tmpfs 3.9G 52K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 794M 4.0K 794M 1% /run/user/1000

It shows the /dev/sda2 is 63Gb. Not 128GB.

I run the command fdisk -l to check the situation.

davidyin@gitlab:~$ sudo fdisk -l
Disk /dev/sda: 128 GiB, 137438953472 bytes, 268435456 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DB918E2F-8E14-4477-BC25-D9428A901BCF

Device     Start       End   Sectors Size Type
/dev/sda1   2048      4095      2048   1M BIOS boot
/dev/sda2   4096 134215679 134211584  64G Linux filesystem
davidyin@gitlab:~$ sudo parted -l
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 (an extra 134217728 blocks) or continue with
the current setting?
Fix/Ignore? Fix
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 137GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  68.7GB  68.7GB  ext4

The command above parted -l is to fix the error of GPT.

The fourth step is more important.

Prepare the Debian 12 Live ISO.

Mount Debian 12 Live

Mount this ISO file on the VM. Boot from this live ISO.

In the Console window, I can work on the live system. Install Gparted software, then launch the Gparted.

In the GUI interface of the Gparted application, I can easily drag the bar to use the unused space until the maximum.

Sample screenshot from other site.
It is just a sample screenshot.

The last step is quite simple. Shut down the VM, and un-mount the ISO file. Boot up the VM. Done.

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *