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
Increase the size of the disk, e.g. add 10GB
Download GParted
https://gparted.org/download.php
Attach GParted ISO to Virtual Machine
Hardware - select CD/DVD drive - Edit
Attach the GParted ISO
Boot VM into GParted
Start the VM and connect to the console
Press ESC for the Boot Menu
Enter to boot from DVD/CD
GParted Live (Default settings)
Dont touch keymap
Select language
Enter 0 to continue and start GParted
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.
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
Select the /dev/sda2 extended partition and delete it as well
Apply all operations
Resize the primary partition
Select the primary partition /dev/sda1
Partition - Resize/Move
Change the new size and free space following to leave 1GB for the swap partition that we need to re-create
Apply all operations
Create new extended partition
Select the free space at the end of the drive
Partition - New
New size 1024
Create as extended partition
Apply all operations
Create swap partition
Select the free space in the newly created extended partition /dev/sda2
Partition - New
New size 1023
File system: linux-swap
Apply all operations
Swap partition has been re-created at the end of the disk, and the primary partition /dev/sda1 has been expanded
Exit GParted and shutdown VM
Error: Timed out waiting for device /dev/disk/by-uuid.
Dependency failed for swap
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
Find the UUID of the swap partition using blkid
sudo blkid
Edit /etc/fstab
sudo nano /etc/fstab
Replace the UUID for the swap partition in fstab with the ID you got from running blkid!
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
Done!
this are my private notes!
https://lists.debian.org/debian-user/2017/09/msg00866.html