My trusted Ubuntu server ran out of space (again), and again it was the root partition. Luckily, I chose LVM this time during installation...
First, add more space to the volume in ESXi using vSphere client. That was
Next, login to the server, and start extending...
Scan for added space
First, you need to make the server notice the extra space. In order to do
that, use this command:
echo "- - -" > /sys/class/scsi_host/host#/scan
Where host# is host0, host1, host2, depending on the number of hosts
on the machine. Use this command to find out:
Verify by calling fdisk -l, the disk should now have grown to
the given size.
Create new partition
Start fdisk, parted or cfdisk to create a new partition. For
some reason, both fdisk and parted refused to let me use all the
available space, so I ended up using cfdisk.
Use partition type 8e (Linux LVM extended).
Create a new physical partition using pvcreate (here using sda3):
Extended the logical disk
Find the name of the logical disk, and use vgextend
vgextend replicant-vg /dev/sda3
Verify by calling lvdisplay. The partition should be listed as
Expand the logical volume
Expand the logical volume (the name is root, and the size was increased by
lvextend -L+10G /dev/replicant-vg/root
Resize the logical volume to use the new space:
resize2fs -f /dev/replicant-vg/root
Check the new partition by calling df -h:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/replicant--vg-root 39G 23G 15G 62% /
Ah, lots of space again!