LVM Solutions: How to change a faulty hard drive in Redhat/Centos Linux on production server ?
Today we will look at an interesting article how to change a faulty drive on our Linux server deployed in production.
There are two approaches to achieve this:
First Approach
1. Create a PV with new drive.
2. Extend VG to include this new PV.
3. Move the physical extents from old drive to new drive by pvmove command.
4. Reduce vg and remove the old PV.
Second Approach
1. Create a new PV with new drive.
2. Add this PV in mirror to existing drives/PVs.
3. Remove the faulty drive PV once sync is completed.
I. Steps involved in first Approach
## 1. First lets create a new physical volume # pvcreate /dev/sdb ## 2. Extend VG with new PV # vgextend vg0 /dev/sdb ## 3. Move old PV data to new PV # pvmove /dev/sda /dev/sdb ## 4. Reduce VG to remove the old fault drive. # vgreduce vg0 /dev/sda ## 5. Remove old physical volume. # pvremove /dev/sda
II. Steps involved in second approach.
## 1. Create physical volume from new disk. # pvcreate /dev/sdb ## 2. Attach this new PV in RAID 1 mirror with LV which has faulty disk. # lvconvert -m1 /dev/myvg/lv0 /dev/sdb //// Wait for sync to complete ## 3. Once sync, is completed. Remove old disk from LV. # lvconvert -m0 vg0/lv0 /dev/sda ## 4. In the end, remove the PV. # pvremove /dev/sda