How to migrate storage between disks using pvmove on Linux

Linux

1. Begin by pvcreate'ing the new disk. This is the disk from the new storage array to which we want to migrate.

# pvcreate /dev/mapper/mpathY

2. Now, add this disk into the data_vg Volume Group:

# vgextend data_vg /dev/mapper/mpathY

Make sure there are free extents on the new disk before running pvmove.

3. Begin the migration from the /dev/mapper/mpathX PV to the new /dev/mapper/mpathY PV.

# pvmove -b /dev/mapper/mpathX /dev/mapper/mpathY

This will take time to complete depending on the size. The -b option in the command above runs the pvmove command in the background.

4. Periodically, you can check the progress of the migration. Make sure you are looking at the "Copy%" column for the LV and VG that you are working with.

# lvs -a -o+devices

When the migration is completely finished, the "Copy%" column will no longer show a value for the LV and VG that you are working with.

You may also run pvmove -iX, where X is an interval in seconds to report the progress. For example, pvmove -i5 will report progress every 5 seconds.

5. Now, you can safely remove the original PV from the VG.

# vgreduce oracleprod /dev/mapper/mpathX
# pvremove /dev/mapper/mpathX