Date: 2021feb8
OS: Linux
Q. Linux: Add a new disk to a LVM
A.
Take a look
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 29.5G 0 part /
└─sda3 8:3 0 90G 0 part
└─MYVOL 253:0 0 189.9G 0 lvm /stuff
sdb 8:16 0 16G 0 disk
└─sdb1 8:17 0 16G 0 part /mnt/resource
sdc 8:32 0 100G 0 disk
└─sdc1 8:33 0 100G 0 part
└─MYVOL 253:0 0 189.9G 0 lvm /stuff
sdd 8:48 0 128G 0 disk
This shows us the new disk is /dev/sdd since it has nothing hanging off it.
Use pvcreate to make a logical volume
# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created.
Extend your volume group with that logical volume
# vgextend MYVOL /dev/sdd
Volume group "MYVOL" successfully extended
See what's up
# vgdisplay MYVOL
--- Volume group ---
VG Name MYVOL
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <317.99 GiB
PE Size 4.00 MiB
Total PE 81405
Alloc PE / Size 48614 / <189.90 GiB
Free PE / Size 32791 / <128.09 GiB
VG UUID HH6gWu-4bk9-5gRR-o850-J6gJ-ryiD-DdTZM1
And note the "Free PE", use that number below
Extend your volume group
# lvextend -l +32791 /dev/mapper/MYVOL
Size of logical volume MYVOL changed from <189.90 GiB (48614 extents) to <317.99 GiB (81405 extents).
Logical volume MYVOL successfully resized.
Finally, resize
# resize2fs /dev/mapper/MYVOL
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/MYVOL is mounted on /stuff; on-line resizing required
old_desc_blocks = 24, new_desc_blocks = 40
The filesystem on /dev/mapper/MYVOL is now 83358720 blocks long.
Check with df
df -h /dev/mapper/MYVOL
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/MYVOL 313G 142G 157G 48% /stuff