Technotes

Technotes for future me

Logical Volume Management

Logical Volume Management

pvcreate /dev/sdb
vgextend vg00 /dev/sdc
vgcreate vg01 /dev/mapper/mpathb
lvresize -r -L+2G /dev/mapper/vg00-blaataap
lvextend -l +100%FREE /dev/mapper/vg01-blaataap
resize2fs /dev/mapper/vg00-blaataap
xfs_growfs /dev/mapper/vg00-blaataap
lvcreate -l 100%FREE -n blaataap vg01
lvcreate -L4G -n blaataap vg00
mkfs.ext3 /dev/mapper/vg00-blaataap

If you made the mistake to extend the OS disk:

fdisk /dev/sda

remove partition 2 (/dev/sda2) add new partition (check start sector) change change a partition’s system id write

reboot
pvresize
xfs_grow

done!

Mounting LVM Partitions

lvdisplay                   # To lookup partition name
mount /dev/vg0/vol1 /mnt

Resizing Volumes

lvresize -L 50G /dev/volgrp/<name>
resize2fs /dev/vda
xfs_growfs /dev/vda

Adding Disks to Existing Volume

Via: LVM - Add another disk

# Setup partition with (use parted for >2TB)
(parted) mklabel gpt       # only when >2TB
(parted) mkpart primary lvm 0 4T    # setup disk full size (e.g. 4TB)

pvcreate /dev/sdb1       # Create physical LVM disk
vgextend vg01 /dev/sdb1      # Add to volume group
vgextend -L +4t /dev/mapper/vg01-lvdata  # Extend your volume 
resize2fs /dev/mapper/vg01-lvdata   # Auto-resize file system
Last updated on 31 Jan 2021
Published on 11 Dec 2019
Edit on GitHub