網頁

2013年5月18日 星期六

CentOS 6.3 --- Replace bad or old disk by LVM Command Line Interface

When the system is online for a long time, maybe one day it will suffer some problem as some disks crash or phase out so that need to replace the old disk with the new one. If the replaced disk is configured by LVM and exists a lot of data, how to do it?

If there is no enough free physical extents (PV) in the volume group, we have to add a new disk (as /dev/sdd) and its size need to be large than the replaced disk. In the moment, we also need to know which disk (as /dev/sdb1) need to be replaced or view /var/log/messages to find out the bad disk.
ScreenHunter_04
After done it, we have to make this new disk to be available with LVM by using pvcreate /dev/sdd commandScreenHunter_05To verify the status of the new physical volume by using pvdisplay /dev/sdd commandScreenHunter_06To realize which volume group the bad or old disk ( /dev/sdb1) belongs to by using pvdisplay /dev/sdb1 commandScreenHunter_07To add the new disk ( /dev/sdd) to the volume group drbdVG00 by using vgextend drbdVG00 /dev/sdd command
ScreenHunter_08To realize which logical volume the volume group drbdVG00 belong to by using lvdisplay commandScreenHunter_09ScreenHunter_10To move physical extents in active volume group drbdVG00 from /dev/sdb1 to /dev/sdd by using pvmove –n drbdVG00 /dev/sdb1 /dev/sdd commandScreenHunter_11To remove bad or old disk from the volume group by using vgreduce drbdVG00 /dev/sdb1 commandScreenHunter_12Finally, please shutdown the system next to remove the bad or old disk (# 1) and boot it. The data still exist in LVM disk as before.ScreenHunter_04
Reference :
(# 1)  When remove the bad or old SCSI disk but never change disk order (that the new disk ID also is the same as before)ScreenHunter_01ScreenHunter_02          all disk order will be changed but LVM function is normal.ScreenHunter_03
          When remove the bad or old SCSI disk and change disk order (that new disk ID is the same as the old one)ScreenHunter_05        the bad or old disk just is replaced with the new disk and LVM function is normal as well.
ScreenHunter_06
Since 2010 Design by Davidwa
©Copyright Davidwa Inc. All rights reserved.