What LVM is and what it’s for

LVM - logical volume manager. It lets you combine several physical disks into one logical device and treat that as a single disk.

Looks roughly like this:
lvm

To create a volume group on disks that aren’t mounted to the filesystem root, first zero them out:

dd if=/dev/zero of=/dev/sdd bs=512 count=1  
dd if=/dev/zero of=/dev/sde bs=512 count=1

Then create the physical volumes:

pvcreate /dev/sdd  
pvcreate /dev/sde

Create the volume group:

vgcreate vg_storage /dev/sdd

Add another disk to it (basically extending the volume group):

vgextend vg_storage /dev/sde

Create a logical volume:

lvcreate -L 1G -n lv_var_www_html vg_storage

If you undersized it, add more:

lvextend -L +19.99G /dev/mapper/vg_storage-lv_var_www_html  
resize2fs /dev/mapper/vg_storage-lv_var_www_html

Make sure the new volume was created:

ls -la /dev/mapper/

or

lvdisplay

Create a filesystem on it:

mkfs -t ext4 /dev/mapper/vg_storage-lv_var_www_html

Edit /etc/fstab:

/dev/mapper/vg_storage-lv_var_www_html /var/www/html ext4 defaults 0 0

Before mounting, create the mount point:

mkdir -p /var/www/html

Mount it:

mount -a

You can grow a logical volume on the fly:

lvextend -L +19.99G /dev/mapper/vg_storage-lv_var_www_html  
resize2fs /dev/mapper/vg_storage-lv_var_www_html

You’re supposed to unmount the volume first, but it’s always worked fine for me without that.

Just in case:

umount /dev/mapper/vg_storage-lv_var_www_html

Wrapping up:

LVM lets you combine physical disks (pv — physical volume) into a single pool or storage space (vg — volume group), which you can then split into partitions (lv — logical volume).

lvm_logo

Drew on these sites: