centostricks

Just another WordPress.com site

Replace a faulty disk from Volume Group


This commands are run on CentOS EL 6.0

Replace a faulty disk from Volume Group

Here /dev/sdb has an hardware issue and its been found to be a faulty Disk.

Step 1: Let us scan to find any data available on the faulty disk, Here we find that 120MB is consumed and data is available

[root@localhost ~]# pvscan
PV /dev/sdc    VG VG_01           lvm2 [1020.00 MiB / 1020.00 MiB free]
PV /dev/sdb    VG VG_00           lvm2 [1020.00 MiB / 120.00 MiB free]
PV /dev/sda2   VG VolGroup        lvm2 [12.51 GiB / 0    free]
PV /dev/sdd                       lvm2 [1.00 GiB]
Total: 4 [15.50 GiB] / in use: 3 [14.50 GiB] / in no VG: 1 [1.00 GiB]

Step 2 : Check the LV and PV mapping  :  /dev/VG_00/song is mapped to /dev/sdb

[root@localhost ~]# pvdisplay -m /dev/sdb
— Physical volume —
PV Name               /dev/sdb
VG Name               VG_00
PV Size               1.00 GiB / not usable 4.00 MiB
Allocatable           yes
PE Size               4.00 MiB
Total PE              255
Free PE               30
Allocated PE          225
PV UUID               9oE3Rn-8obQ-8wwn-Samq-tM1N-VVaM-o1qf5W

— Physical Segments —
Physical extent 0 to 224:
Logical volume    /dev/VG_00/song
Logical extents    0 to 224
Physical extent 225 to 254:
FREE

[root@localhost ~]# lvdisplay -m /dev/VG_00/song
— Logical volume —
LV Name                /dev/VG_00/song
VG Name                VG_00
LV UUID                09CVS7-y162-Y8pp-IUXH-v67C-Pw7a-auFCKj
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                900.00 MiB
Current LE             225
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:2

— Segments —
Logical extent 0 to 224:
Type        linear
Physical volume    /dev/sdb
Physical extents    0 to 224

Step 3: Check the status of current LV

[root@localhost ~]# lvscan
ACTIVE            ‘/dev/VG_00/song’ [900.00 MiB] inherit
ACTIVE            ‘/dev/VolGroup/lv_root’ [10.54 GiB] inherit
ACTIVE            ‘/dev/VolGroup/lv_swap’ [1.97 GiB] inherit

Step 4 : Adding a New PV to VG to move the data from faulty PV to this NEW PV( IN our case /dev/sdb is found faulty)

[root@localhost ~]# vgextend VG_00 /dev/sd
sda   sda1  sda2  sdb   sdc   sdd
[root@localhost ~]# vgextend VG_00 /dev/sdd
Volume group “VG_00” successfully extended

Step 5 : Moving all its extents from /dev/sdb to free extents in VG_00, in our case we have only one pv /dev/sdd which is newly added. So all the extents are moved to /dev/sdd

[root@localhost ~]# pvmove /dev/sdb
/dev/sdb: Moved: 12.9%
/dev/sdb: Moved: 100.0%
[root@localhost ~]#
[root@localhost ~]#

Step 6 : Check for the changes, All the extents from /dev/sdb is moved to /dev/sdd..

[root@localhost ~]# pvscan
PV /dev/sdc    VG VG_01      lvm2 [1020.00 MiB / 1020.00 MiB free]
PV /dev/sdb    VG VG_00      lvm2 [1020.00 MiB / 1020.00 MiB free]
PV /dev/sdd    VG VG_00      lvm2 [1020.00 MiB / 120.00 MiB free]
PV /dev/sda2   VG VolGroup   lvm2 [12.51 GiB / 0    free]
Total: 4 [15.50 GiB] / in use: 4 [15.50 GiB] / in no VG: 0 [0   ]

Step 7: Still our LV is active and all data is intact. nothing is lost🙂

[root@localhost ~]# lvscan
ACTIVE            ‘/dev/VG_00/song’ [900.00 MiB] inherit
ACTIVE            ‘/dev/VolGroup/lv_root’ [10.54 GiB] inherit
ACTIVE            ‘/dev/VolGroup/lv_swap’ [1.97 GiB] inherit
[root@localhost ~]# cd /striped/
[root@localhost striped]# ls
aa  lost+found  test
[root@localhost striped]# cat aa
dnandsandlandtesteinggg
[root@localhost striped]# cd

Step 8 : Now we are removing the faulty DISK (PV) /dev/sdb from Volume group VG_00

[root@localhost ~]# vgreduce VG_00 /dev/sdb
Removed “/dev/sdb” from volume group “VG_00”

Step 9: OUR Faulty Disk /dev/sdb is free from all VG and ready to be removed from System

[root@localhost ~]# pvscan
PV /dev/sdd    VG VG_00           lvm2 [1020.00 MiB / 120.00 MiB free]
PV /dev/sdc    VG VG_01           lvm2 [1020.00 MiB / 1020.00 MiB free]
PV /dev/sda2   VG VolGroup        lvm2 [12.51 GiB / 0    free]
PV /dev/sdb                       lvm2 [1.00 GiB]
Total: 4 [15.50 GiB] / in use: 3 [14.50 GiB] / in no VG: 1 [1.00 GiB]
[root@localhost ~]# cd /striped/
[root@localhost striped]# ls
aa  lost+found  test
[root@localhost striped]# cat aa
dnandsandlandtesteinggg

Now Our LV /dev/VG_00/song is using the extents from /dev/sdd.

[root@localhost ~]# lvdisplay -m /dev/VG_00/song
— Logical volume —
LV Name                /dev/VG_00/song
VG Name                VG_00
LV UUID                09CVS7-y162-Y8pp-IUXH-v67C-Pw7a-auFCKj
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                900.00 MiB
Current LE             225
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:2

— Segments —
Logical extent 0 to 224:
Type        linear
Physical volume    /dev/sdd
Physical extents    0 to 224

ALL THE BEST !!! . We did all this steps. without unmounting the filesystem or taking the system Down !!! Good Luck !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: