LVM Migration
Table of Contents
This procedure is how to move data from one Physical Volume to another in a LVM configuration on a RHEL based system.
Acronyms #
Acronym | Meaning |
---|---|
PV | Pysical Volume |
LV | Logical Volume |
VG | Volume Group |
Highlevel Procedure #
- Check Current Configuration (Using Multipath/powermt)
- Check Space on Existing LUNs and VGs
- Configure/Present LUN to server
- Scan for LUN on server
- Add LUN to PV
- Extend VG to include new LUN
- Check new LUN and VG have enough space to migrate
- Migrate data from one PV to new PV
- Remove old PV from VG
- Check VG has correct LUNs
Detailed Procedure #
For the example below, it is assumed 3 LUNs will be used and 1 will be updated/swapped.
LUN Presentation #
Confirm LUN is presented to new server from the storage.
LUN Rescan #
Rescan for presented LUNs. Check how many fibre channels are on the system.
[root@server ~]# ls /sys/class/fc_host
host0 host1 host2 host3
[root@server ~]# echo "1" > /sys/class/fc_host/host0/issue_lip
[root@server ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@server ~]# echo "1" > /sys/class/fc_host/host1/issue_lip
[root@server ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@server ~]# echo "1" > /sys/class/fc_host/host2/issue_lip
[root@server ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
[root@server ~]# echo "1" > /sys/class/fc_host/host3/issue_lip
[root@server ~]# echo "- - -" > /sys/class/scsi_host/host3/scan
[root@server ~]# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
Restart Multipathd (If Used) #
Restart Multipathd when scan has been completed.
[root@server ~]# service multipathd restart
[root@server ~]# multipath -ll
Rescan Powerpath (If Used) #
Rescan powerpathd
[root@server ~]# powermt config
[root@server ~]# powermt display dev=all
Check Current LUNs #
Check the current LUNs in the VG.
[root@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpatha vg_test01 lvm2 a-- 1023.00m 0
/dev/mapper/mpathb vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathc vg_test01 lvm2 a-- 1020.00m 0
Add New Luns #
If the scan was successful add the new LUNs.
[root@server ~]# pvcreate /dev/mapper/mpathd
Check Current LUNs #
As you can see below it is added, it is not currently assigned to a VG.
[root@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpatha vg_test01 lvm2 a-- 1023.00m 0
/dev/mapper/mpathb vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathc vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathd lvm2 --- 1020.00m 1023.00m
Add PV to VG #
Add newly added PV to VG.
[root@server ~]# vgextend vg_name /dev/mapper/mpathd
Check VG #
Make sure you can see the PV
As you can see below it is added, and now it is assigned to a VG. Also you can see the new lun /dev/mapper/mpathd
has free space.
[root@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpatha vg_test01 lvm2 a-- 1023.00m 0
/dev/mapper/mpathb vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathc vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathd vg_test01 lvm2 a-- 1020.00m 1023.00m
Migrate Data #
Now to move the data from an old LUN to the new LUN
[root@server ~]# pvmove /dev/mapper/mpatha /dev/mapper/mpathd
/dev/mapper/mpatha: Moved: 0.39%
/dev/mapper/mpatha: Moved: 38.04%
/dev/mapper/mpatha: Moved: 75.69%
/dev/mapper/mpatha: Moved: 100.00%
Check VG #
Check the data has moved. You can now see the old lun /dev/mapper/mpatha
is now the one with the free space and /dev/mapper/mpathd
isn’t 100% free.
[root@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpatha vg_test01 lvm2 a-- 1020.00m 1020.00m
/dev/mapper/mpathb vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathc vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathd vg_test01 lvm2 a-- 1020.00m 0
Remove Old LUN #
Now remove the old lun from the VG. Make sure this is the LUN with 100% free.
[root@server ~]# vgreduce vg_test01 /dev/mapper/mpatha
Check VG #
Check the old LUN has been disassociated from the VG.
[root@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpatha lvm2 --- 1023.00m 1023.00m
/dev/mapper/mpathb vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathc vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathd vg_test01 lvm2 a-- 1020.00m 0
Remove Old PV #
Remove the old LUN
[root@server ~]# pvremove /dev/mapper/mpatha
Check VG #
Check the old LUN /dev/mapper/mpatha
has been removed
[root@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpathb vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathc vg_test01 lvm2 a-- 1020.00m 0
/dev/mapper/mpathd vg_test01 lvm2 a-- 1020.00m 0