pvmove Command - LVM Physical Volume Move Utility
The pvmove command is a powerful utility within the Logical Volume Manager (LVM) suite in Linux. Its primary function is to move physical extents (PEs) from one physical volume (PV) to another. This is crucial for tasks such as rebalancing storage, migrating data to new disks, or freeing up space on a specific physical volume without interrupting service.
Understanding pvmove Operations
pvmove allows for flexible data migration. You can move all extents from a source PV to a destination PV, or selectively move extents associated with specific logical volumes. The command can also be used to redistribute data across available physical volumes in a volume group to optimize performance and utilization.
Key pvmove Command Examples
Here are some common use cases for the pvmove command:
Moving All Physical Extents
To move all physical extents from one physical volume (e.g., /dev/sdX) to another (e.g., /dev/sdY), you would use the following syntax:
pvmove /dev/sdX /dev/sdY
Moving Specific Logical Volumes
You can specify which logical volumes' extents to move. The --alloc anywhere option ensures that extents are allocated anywhere on the destination PV if the exact location is not specified. This example moves extents for a logical volume named vgname-lvname from /dev/sdX to /dev/sdY:
pvmove --alloc anywhere /dev/sdX:/dev/sdY /dev/mapper/vgname-lvname
Verbose Output for Monitoring
For detailed progress and information during the move operation, use the -v (verbose) flag:
pvmove -v /dev/sdX
Handling Uninitialized Physical Volumes
In scenarios where you might be dealing with physical volumes that have not been fully initialized or have skipped cluster configurations, you can use the --ignoreskippedcluster option:
pvmove --ignoreskippedcluster /dev/sdX /dev/sdY
Moving Extents from a Volume Group Device
You can also initiate a move operation for extents belonging to any device within a specific volume group to a designated device:
pvmove --alloc anywhere /dev/md0
Atomic Moves and Specific Ranges
The --atomic option ensures that the move operation is performed atomically, meaning it either completes successfully or is rolled back, preventing data corruption. You can also specify particular physical volume names and their corresponding physical extent ranges:
pvmove --atomic pvname[:pe_ranges] [destpv[:pe_ranges] [movedevice[:pe_ranges]]]
Aborting an In-Progress Operation
If you need to stop a pvmove operation that is currently running, you can use the --abort flag:
pvmove --abort