Have an LVM device left on your system from a drive that was removed before pvremove was run?
1 | $ sudo dmsetup remove /dev/mapper/removed-device |
A Project Blog
Have an LVM device left on your system from a drive that was removed before pvremove was run?
1 | $ sudo dmsetup remove /dev/mapper/removed-device |
LVM allows you to hot add devices to expand volume space. It also allows you to hot remove devices, as long as there are enough free extents in the volume group (vgdisplay) to move data around. Here I’m going to replace a 400 GB drive (sdg) with a 750 GB one (sdh) from logical volume “backup” on volume group “disks”. It does not matter how many hard drives are in the volume group, and the filesystem can stay mounted.
1 | $ sudo pvcreate /dev/sdh1 |
1 | $ sudo vgextend disks /dev/sdh1 |
1 | $ sudo pvmove -v /dev/sdg1 |
1 | $ sudo vgreduce disks /dev/sdg1 |
1 | $ sudo lvextend -l+83463 /dev/disks/backup |
1 2 | $ sudo resize2fs /dev/disks/backup $ sudo xfs_growfs /dev/disks/backup |
This guide shows how to add a drive to an existing LVM volume.
# dd if=/dev/zero of=/dev/hdd bs=1024k count=1
# pvcreate /dev/hdd
# sudo vgdisplay -A
— Volume group —
VG Name disks
System ID
Format lvm2
Metadata Areas 7
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 7
Act PV 7
VG Size 859.70 GB
PE Size 4.00 MB
Total PE 220084
Alloc PE / Size 220084 / 859.70 GB
Free PE / Size 0 / 0
VG UUID N4TcI6-DIRS-3edy-FAa0-tdUL-MTSX-bs2lJE
# sudo vgextend disks /dev/hdd
# sudo vgdisplay -A
— Volume group —
-snip-
VG Size 1.11 TB
PE Size 4.00 MB
Total PE 291625
Alloc PE / Size 220084 / 859.70 GB
Free PE / Size 71541 / 279.46 GB
# sudo lvextend -l+71541 /dev/disks/backup
Extending logical volume backup to 1.11 TB
Logical volume backup successfully resized
# sudo vgdisplay -A
— Volume group —
-snip-
VG Size 1.11 TB
PE Size 4.00 MB
Total PE 291625
Alloc PE / Size 291625 / 1.11 TB
Free PE / Size 0 / 0
# sudo xfs_growfs /backup