Extending a volume in linux
If you need to add a new drive to (and extend) the LVM setup:
1) Make sure the drive is free of partitions. Install the drive and power up.
2) Find out what the machine is calling the new drive. This will be something in the sd[a-z] range, and is not predictable - you'll need to check before moving on. For the purposes of this post, we'll say that it's called 'sdc'.
3) Create a physical volume on the new disk:
sudo pvcreate /dev/sdc
--- if you only need to extend an existing volume you can start here ---
4) We need to know what the existing volume-groupe and volume names are:
sudo vgdisplay
should return something that starts with 'VG Name vgpool', where 'vgpool' is the string we need.
5) To extend the volume group to include our new device:
sudo vgextend vgpool /dev/sdc1
6) Extend the logical volume by adding 20GB to the volume - note that we can access the volume at /dev/mapper/<volume-group-name>/<volume-name>
sudo lvextend -L+20G /dev/mapper/vgpool-lvrepo
** if you don't know how much disk you have left on any physical device, run this:
sudo hdparm -I /dev/sdc | grep GB
7) You also need to extend the filesystem, and you can't do it while the volume is mounted:
sudo umount /dev/mapper/vgpool-lvrepo
8) You need to run fsck before resizing a filesystem:
sudo e2fsck -f /dev/mapper/vgpool-lvrepo
9) Now you can resize the filesystem:
sudo resize2fs /dev/mapper/vgpool-lvrepo
6) And remount:
sudo mount /dev/mapper/vgpool-lvrepo /mountlocation