pvmove should be used to move the physical volume extents from the old SAN to the new SAN. It is a common misconception that migrations of this sort should be done by manually creating and manipulating mirrors. This is incorrect and exposes one to risk. pvmove was designed to facilitate this functionality and is much safer than attempting to use mirrors manually. A pvmove can be safely aborted should problems arise. In contrast, a problem that springs from manipulating the mirrors may result in downtime and require diagnosing and repairing the LVM stack.
The steps would generally be:
- Attach the new LUN to the system.
- Create a new Physical Volume on the new LUN and use vgextend to add it to the existing Volume Group.
- Use pvmove to move the source PVs to the destination PV. The pvmove option “–atomic” , where present, ensures additional safety throughout the process.
- Once the pvmove completes, use vgreduce to remove the old PV, which should now be empty.
- Decommission the old LUN from the server.
pvmove Command Examples
1. To move allocated PEs on to one or more other physical volumes:
2. To abort any pvmove inprogress:
# pvmove --abort
3. To run the pvmove in background:
# pvmove -b # pvmove --background
The output of lvs -a -o +devices will show the progress of a backgrounded pvmove in the Copy% column.
You may also run pvmove -iX at any time, where X is an interval in seconds to report the progress. For example, pvmove -i5 will report progress every 5 seconds. You can cancel this progress report and re-start it at any time.
4. To report the progress:
# pvmove -i 1 # pvmove --interval 1
5. To move only the extents belonging to LV from particular PV:
# pvmove -n LV00 # pvmove -n LV00
6. To auto backup the PV:
# pvmove -A y # pvmove --autobackup y
7. To see the pvmove help:
# pvmove --help
8. To test the pvmove:
# pvmove -t # pvmove --test
9. To set to verbose mode:
# pvmove --verbose
If pvmove gets interrupted for any reason (e.g. the machine crashes) then run pvmove again without any PhysicalVolume arguments to restart any moves that were in progress from the last checkpoint. The same information is also given in man page for pvmove.
If pvmove failed with the below error:
lvm pvmove /dev/mapper/mpathm Skipping locked LV testlv All data on source PV skipped. It contains locked, hidden or non-top level LVs only. No data to move for testvg(volume group)
Check if any other pvmove command is being run simultaneuously. Only 1 pvmove operation can be performed on the lv. No multiple pvmove can be formed simultaneously. Use below command to check the status of the pvmove command:
# pvmove -i1 /dev/mapper/mpathd: Moved: 5.16% /dev/mapper/mpathd: Moved: 10.91% /dev/mapper/mpathd: Moved: 16.07% /dev/mapper/mpathd: Moved: 21.03% /dev/mapper/mpathd: Moved: 26.98%