Migrating the Logical Volume Data

Migrating the LV Data From one PV to Another.

There might be a situation where the PV might be failing and it is required to be replaced, In such case, we need to move or migrate the data from such PV to other and  isolate the PV.

For demonstration, In our care the PV (i.e /dev/sde5) has been failed. We need to replaces and add a new PV (i.e /dev/sde6).

Previously article we have seen how to create, removing  extended logical volume groups, refer below links.

Managing Logical Volumes in Linux
Extending Logical Volume
Reducing Logical Volume
Creating Striped Volumes

Migrating the Logical Volume Data

The Steps to migrate the PV are:

1.) Check the data of failing PV.

Access the mount point of the of the failing PV and check the data in it.

[root@server1 ~]# cd /Impdata/
[root@server1 Impdata]# ls
Impdatafile1   Impdatafile2  Impdatafile4  Impdatafile6  Impdatafile8  lost+found
Impdatafile10  Impdatafile3  Impdatafile5  Impdatafile7  Impdatafile9
[root@server1 Impdata]#

2.) Verify the size of the PV.

Using pvs or pvdisplay command verify the size of the PV.

[root@server1 Impdata]# pvs /dev/sde5
  PV         VG        Fmt  Attr PSize PFree   
  /dev/sde5  itcare-vg lvm2 a--  2.00g 1020.00m
[root@server1 Impdata]#  pvdisplay /dev/sde5
  --- Physical volume ---
  PV Name               /dev/sde5
  VG Name               itcare-vg
  PV Size               2.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              511
  Free PE               255
  Allocated PE          256
  PV UUID               ccUgnt-N7XK-sa9C-DdVb-gu5l-ddeQ-I9HhVx
[root@server1 Impdata]# 

3.) Unmount the file system.

Unmount the file system on that PV.

#umount <Mount Point>

[root@server1 ~]# umount /Impdata/
[root@server1 ~]#

4.) Add the new Physical Volume.

Add new PV which should be of the same size or higher than that of the replacing PV to Volume group.In our case the size of the failing PV is around 2GB, so we need to add a PV whose size is at least 2GB or more.In our case, I have created another partition from fdisk (i.e /dev/sde6) with the size of 2GB.

[root@server1 ~]# pvs /dev/sde6
  PV         VG   Fmt  Attr PSize PFree
  /dev/sde6       lvm2 ---  2.00g 2.00g
[root@server1 ~]# vgextend itcare-vg /dev/sde6
  Volume group "itcare-vg" successfully extended
[root@server1 ~]#

Extend the VG with the new PV Partition.

5.) Migrate the PVs contents to the new PV.

#pvmove <old PV> <New PV>

[root@server1 ~]# pvmove /dev/sde5 /dev/sde6
  /dev/sde5: Moved: 0.0%
  /dev/sde5: Moved: 78.5%
  /dev/sde5: Moved: 100.0%
[root@server1 ~]#

6.) Remount the LV and Verify the data.

Remount the PV, access the mount point and verify the data in it.

[root@server1 ~]# mount -a
[root@server1 ~]# cd /Impdata/
[root@server1 Impdata]# ls
Impdatafile1   Impdatafile2  Impdatafile4  Impdatafile6  Impdatafile8  lost+found
Impdatafile10  Impdatafile3  Impdatafile5  Impdatafile7  Impdatafile9
[root@server1 Impdata]#

7.) Remove the faulty PV from Volume Group.

Lets remove the faulty PV from the volume group.

#vgreduce <VG Name> <PV Name>

[root@server1 Impdata]# vgreduce itcare-vg /dev/sde5
  Removed "/dev/sde5" from volume group "itcare-vg"
[root@server1 Impdata]#

If everything worked properly, you should remove the faulty PV.!!!

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz