Skip to content

growpart

Linux disk add space extend partition

Suppose you have LVM disk and want to grow root partition:

# lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                         8:0    0   72G  0 disk
├─sda1                      8:1    0    1G  0 part /boot/efi
├─sda2                      8:2    0    2G  0 part /boot
└─sda3                      8:3    0 58.9G  0 part
  └─ubuntu--vg-ubuntu--lv 252:0    0 58.9G  0 lvm  /
sr0                        11:0    1 1024M  0 rom

# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda3  ubuntu-vg lvm2 a--  <58.95g    0
# lvs
  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- <58.95g
  • Install growpart
    apt install cloud-guest-utils
    
  • Grow the partition
    growpart /dev/sda 3
    
  • Verify:
    lsblk
    
    You should now see sda3 at ~68.9G.
  • Resize the LVM physical volume
    pvresize /dev/sda3
    
  • Verify:
    pvs   # PFree should now show ~10G
    
  • Extend the logical volume
    lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
    
  • Grow the filesystem (online, no unmount needed)
    lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv