Table of Contents

Back to Tech Documentation


Storage Expansion via Proxmox

Every time I have to do this, I have to google the guide, and I'm tired of that, so I did it here. The main source I like is this: How to enlarge an EXT4 or LVM disk on an Ubuntu Proxmox VM and also this Resize Ubuntu VM disk

Promxox Side

In Promxox, go to the VM, click “Hardware”, select the disk, click the “Disk Action” menu at the top, and choose “Resize.” Configure how much space you want to add, and click OK.

VM Side

Do “lsblk” to make sure you know the path of the drive you are expanding ( usually /dev/sda ). Take note of the actual partition of the Logical Volume (sda3 here)

  # lsblk
  NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  sda                         8:0    0  161G  0 disk 
    sda1                      8:1    0    1M  0 part 
    sda2                      8:2    0    2G  0 part /boot
    sda3                      8:3    0  159G  0 part 
      ubuntu--vg-ubuntu--lv 253:0    0 63.5G  0 lvm  /
  sr0                        11:0    1 1024M  0 rom  

Do “parted /dev/sda” (changing the drive path if it needs to be different)

When parted starts, type “print” which will bring up a 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 146800640 blocks) or continue with the current setting?” Make sure to Fix by typing “Fix” and hitting Enter.

You will see some output after this, listing multiple drives. We're specifically looking for an LVM partition, which will not be bios_grub or ext4. Here is an example:

  (parted) print                                                            
  Model: QEMU QEMU HARDDISK (scsi)
  Disk /dev/sda: 173GB
  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  2150MB  2147MB  ext4
   3      2150MB  139GB   136GB

You need to do “resizepart” for the correct partition, in this case, it's “resizepart 3”. When prompted to confirm, type “100%” to ensure you're using all space, then hit Enter.

Finally enter “quit” to exit parted.

  fdisk -l                                        # Check the free space on the disk
  growpart /dev/sda 3                             # Now, grow the partition
  pvdisplay                                       # Display information about the physical drive
  pvresize /dev/sda3                              # Instruct LVM that the disk size has changed
  pvdisplay                                       # Confirm the physical drive layout has changed
  lvdisplay                                       # View the logical volume, and confirm the LV name for the next step
  lvextend -l +100%FREE /dev/ubuntu_vg/ubuntu_lv  # Resize the logical volume
  lvdisplay                                       # Confirm the logical volume is bigger
  resize2fs /dev/mapper/ubuntu_vg-ubuntu_lv              # Resize the actual filesystem
  fdisk -l                                        # Confirm the new drive size

Back to Tech Documentation