TL;DR
With the disk already enlarged on the hypervisor side (qm resize 100 scsi0 +50G on Proxmox, Edit disk on VMware, your cloud console):
| |
No reboot. df -h / confirms.
Before starting
- Snapshot or backup on the hypervisor. Growing is safe; picking the wrong partition is not.
- Look at the layout:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS. It shows the partition number, whether LVM sits underneath, and which filesystem you are dealing with. - Names: virtio-blk is
/dev/vda; virtio-scsi and SATA,/dev/sda; NVMe,/dev/nvme0n1with partitionsp1,p2… (growpart /dev/nvme0n1 1). - Sometimes the space is already there: Ubuntu Server creates the LV using only part of the VG. If
vgsshows a largeVFree, jump straight tolvextend.
1. Make the kernel see the new disk
| Bus | What to do |
|---|---|
virtio-blk (vda) | Nothing: dmesg | tail shows [vda] new size: … |
virtio-scsi, SATA, IDE (sda) | echo 1 > /sys/class/block/sda/device/rescan |
| New disk (not grown) | echo "- - -" > /sys/class/scsi_host/host0/scan |
| NVMe in the cloud | Usually shows up on its own within a minute; if not, echo 1 > /sys/class/nvme/nvme0/rescan_controller |
lsblk must show the new size on the disk before moving on; otherwise growpart will say NOCHANGE.
2. growpart
| |
growpart stretches the partition to the end of the disk, moves the GPT backup header, and tells the kernel about the new table even with the partition mounted (it uses partx --update). It only works on the last partition; if a swap partition sits behind the root, remove it first (swapoff, delete it with fdisk, recreate it at the end).
Without growpart: parted /dev/sda resizepart 3 100% does the same with a confirmation prompt.
3a. LVM
| |
-r calls resize2fs or xfs_growfs depending on what lives in the LV. Without -r, do it yourself: resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv or xfs_growfs /.
3b. Without LVM
| |
Raspberry Pi and SD cards
Same script with other names (Fedora ARM image with LVM):
| |
Traps
growpart: NOCHANGE: the kernel has not seen the new size yet. Back to step 1.growpartfails in a non-English locale (it parsessfdiskoutput):LC_ALL=C growpart /dev/sda 3.GPT PMBR size mismatchinfdisk -lafter growing the disk: the GPT backup header stayed where the old disk ended.growpartmoves it; if you did it by hand,sgdisk -e /dev/sda.- The partition is not the last one. Swap or
/homebehind the root: either move those, or add a new disk and join it to the VG (pvcreate /dev/sdb && vgextend ubuntu-vg /dev/sdb), which in LVM is faster than reordering partitions. - Shrinking is another story: ext4 only unmounted; XFS never. Think about it before handing out 2 TB “just in case”.
- Windows grows from Disk Management → Extend Volume; none of this applies.
See also
- cloud-init templates on Proxmox: the host-side
qm resizelives there. - LVM: the volume group will not activate, in case step 3 gets weird.
- Move k3s data to another disk, the alternative when what fills up is one specific service.