Increase Disk Size on Linux – Ubuntu 16

You want to increase the size of a disk.
You’ve got a virtual machine running.
Here’s what you do:

Make the disk bigger in VMWare or whatever your hypervisor it. Note, if you make an existing disk larger you will have to scan the drives from with the OS or reboot after creating the partition. If you add a new disk, you shouldn’t have to reboot. Either way works.

Create a partition. Use cfdisk. Tons. Easier than fdisk for those requiring a visual representation and a nicer interface. See here for a bit more info: cfdisk is self-evident. You can’t really screw it up. Just use it instead of fdisk.

Or rescan the disk bus. There are a few ways, and yes this is annoyingly a big, giant hassle.
echo “- – -” > /sys/class/scsi_host/host1/scan (change the “host2” to “host3” and more numbers, then run fdisk -l or cfdisk each time to see… or just reboot if that’s acceptable.

Create a physical volume
pvcreate /dev/sda3 (whatever you saw in cfdisk)

Extend the volume group
vgdisplay (to get the volume group name and path)
vgextend /dev/tempubuntu16-vg /dev/sda3 (again, whatever you saw in cfdisk)

extend the logical volume
lvextend -l +100%FREE /dev/tempubuntu16-vg/root

Resize the logical volume
resize2fs /dev/tempubuntu16-vg/root (whatever you saw in lvdisplay)

See all your disk space
df -h

Big new winning thing I learned:


Make a Linux disk size bigger without having to reboot