Source: https://www.howtoforge.com/linux_lvm
- /dev/sdX or /dev/hdX are physical HDDs (SCSI or SATA)
- /dev/vdX are virtual HDDs (virtualization aware driver)
- /dev/sda1 would be the first partition on the /dev/sda disk
fdisk -l # list info about disks
pvdisplay # physical volume display
pvscan # another command to show physical volumes
vgdisplay # volume group display
vgscan # another command to show volume groups
lvdisplay # logical volume display
lvscan # another command to show logical volumes
lvmdiskscan # scan for block devices that may be used as physical volumes
fdisk /dev/sdX # add partition (n) delete partition (d) on /dev/sdX
pvcreate /dev/sdX1 /dev/sdY1 # initialize a block device(s) to be used as a physical volume (format)
vgcreate vg0 /dev/sdX1 /dev/sdY1 # create a volume group named vg0 across /dev/sdX1 and /dev/sdY1, will be /dev/vg0
lvcreate --name foo --size 10G vg0 # create a logical volume foo (/dev/vg0/foo) of 10G on volume group vg0
mkfs.ext4 /dev/vg0/bar # create an ext4 filesystem on logical volume bar on volume group vg0
mkdir /var/foo # create a directory to mount the filesystem to
mount /dev/vg0/bar /var/foo # mount the logical volume to the directory, create entry in /etc/fstab to survive reboot
vgrename vg0 vgnew # rename volume group vg0 to vgnew
lvrename vg0 foo bar # rename logical volume foo to bar on volume group vg0
pvremove /dev/sdX1 /dev/sdY1 # remove the physical volume created with pvcreate
vgremove vg0 # remove volume group vg0
lvremove /dev/vg0/bar # remove logical volume bar on volume group vg0
vgextend vg0 /dev/sdZ1 # add physical volume /dev/sdZ1 to the vg0 volume group
umount /var/bar # unmount filesystem before resizing
lvextend -L15G /dev/vg0/bar # resize logical volume
e2fsck -f /dev/vg0/bar # force check the filesystem
resize2fs /dev/vg0/bar # resize the filesystem on the logical volume
mount /dev/vg0/bar /var/bar # re-mount the filesystem