LVM: remove PV from VG

#
# Create test LV
#
for i in {1..3}; do
    truncate -s 1G disk${i}.img
    losetup /dev/loop${i} disk${i}.img
    pvcreate /dev/loop${i}
done
 
pvs
 
vgcreate vg0 /dev/loop1 /dev/loop2 /dev/loop3
 
vgs
 
lvcreate -n lv0 -l 100%FREE vg0
 
lvs
 
mkfs.ext4 /dev/vg0/lv0
 
mount /dev/vg0/lv0 /mnt/
 
df -h /mnt/
 
for i in {1..15}; do
    dd if=/dev/urandom of=/mnt/file${i} bs=1M count=100
done
 
md5sum /mnt/file? > /mnt/file.md5
 
(cd /mnt && md5sum -c file.md5)
 
 
#
# Reduce LV and remove PV from VG
#
umount /mnt/
 
#e2fsck -f -v -C 0 /dev/vg0/lv0
e2fsck -f /dev/vg0/lv0
 
resize2fs /dev/vg0/lv0 1800M
 
lvreduce -L 1900M /dev/vg0/lv0
vgs
 
vgreduce vg0 /dev/loop3
 
vgs
pvs
 
pvremove /dev/loop3
pvs
 
 
 
#
# Check filesystem
#
mount /dev/vg0/lv0 /mnt/
(cd /mnt && md5sum -c file.md5)
umount /mnt/
 
# Links
https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/VG_remove_PV.html
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/vg_remove_pv