~/snippets/proxmox-increase-disk-size-for-a-vm
Published on

Increasing Disk Size for a ProxMox VM

362 words2 min read

ProxMox UI

  • Change the Hard Disk size (Hardware => Hard Disk => Resize Disk => Add additional disk required => Resize disk)

On the VM

  • Find the partition that has had its disk size increased

This tells me it's /dev/sda3 I need to focus on, as I increased the disk from 30G -> 60G.

sudo fdisk -l /dev/sda | grep ^/dev

GPT PMBR size mismatch (62914559 != 125829119) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
/dev/sda1     2048     4095     2048   1M BIOS boot
/dev/sda2     4096  2101247  2097152   1G Linux filesystem
/dev/sda3  2101248 62914526 60813279  29G Linux filesystem
  • Run parted on dev/sda
sudo parted /dev/sda
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print
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 62914560 blocks) or continue with the current setting?

Fix/Ignore? F
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 64.4GB
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  1076MB  1074MB  ext4
 3      1076MB  32.2GB  31.1GB

(parted) resizepart 3 100%
(parted) quit
  • Check the new partition table
sudo fdisk -l /dev/sda | grep ^/dev
/dev/sda1     2048      4095      2048   1M BIOS boot
/dev/sda2     4096   2101247   2097152   1G Linux filesystem
/dev/sda3  2101248 125829086 123727839  59G Linux filesystem
  • Run pvresize on the disk
sudo pvresize /dev/sda3
  • Run df -h to get the correct volume

This tells me the volume I need is /dev/mapper/ubuntu--vg-ubuntu--lv

ubuntu@ubuntu-20-downloads:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              394M  1.8M  392M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   29G   28G     0 100% /
  • Run lvextend on the volume
sudo lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  • Run df -h and ensure the drive has increased in space