Linux LVM Data Migration
There are many validations that need to be done before executing the below steps/commands such as target disk compatibility with the server/server load/all target disks have the fully redundant paths/MPIO is configured as per current vendor best practice etc.
Our preferred way of doing any data migration from one set of disks to another is to mirror the disks and then break the mirror. We use lvconvert to achieve this on Linux. There are other ways to migrate the data such as pvmove which can be used in certain cases. There are many other options that may be applicable for your environment. We can help identify best option for you and automate your migrations and fast track the project. Email us at intro@yarisolutions.com to find out how.
lvconvert high level migration procedure :
Identify the volume groups you would like to migrate
Identify each LV per VG
Identify the source disks in use per LV and its size
Ask storage admins to allocate new disks for migration. Allocated space should be larger than the lv size
Map the allocated storage for each vg/lv.
use lvconvert -m1 vg/lv <target disks>
Check the mirror status using lvs -a -o name,copy_percent,devices <vg name>
Check lv details using lvs --all --segments -o +devices
Wait for copy to finish. Once 100% copy is done.
Break the mirror using lvconvert -m0 vg/lv <source disks>
Remove the <source disks> from vg using vgreduce command
Delete the disks from lvm using pvremove
Repeat the process for each vg/lv in the system that you are looking to migrate.
Delete multipathing entries
Ask storage admins to reclaim the source disks.
Clean up the server of all the dead paths/disks after reclaim.
PVMove high level migration procedure :
Identify the volume groups you would like to migrate
Identify source disks per VG using vgs -o +pv_name command.
For each VG request for target disks larger than total VG size. You can ask for same # of disks as source or any other size you like based on the new storage vendor best practice. The only requirement is that total size be larger than current size of VG.
Once storage has been allocated rescan for new disks
Identify and map which target disks were allocated for which VG.
initialize the target disks using pvcreate command
Add the target disks to VG using vgextend command
use pvmove —alloc anywhere <source disk>
vgreduce <source disk>
pvremove <source disk>
Repeat steps 8, 9 and 10 for each source disks in VG.
Repeat steps 5 through 11 for each VG
Ask storage admin to reclaim all the migrated disks
Clean up the server of all the dead paths/disks after reclaim.