pvmove Command in Linux


The pvmove command in Linux moves the physical extents from one physical volume to another. Physical extents (PEs) are fixed-size storage units within a physical volume (PV) in LVM. They form the building blocks of logical volumes (LVs) and can be moved or reallocated as needed.

If pvmove is interrupted for any reason, running it again without any PV arguments restarts any operations that were in progress from the last checkpoint. Alternatively, the abort option can be used at any time to terminate the operation. The final location of logical volumes after an abort depends on whether the atomic option was used.

Table of Contents

Here is a comprehensive guide to the options available with the pvmove command −

Syntax of pvmove Command

The syntax of the pvmove command in Linux is as follows −

pvmove [options] [source_pv] [dest_pv]

In the above syntax, the [options] field is used to specify the flags/options to modify the command’s behavior. The [source_pv] is used to specify the PV with data to move (if omitted, all eligible data is moved), and [dest_pv] is used to specify the target PV (if omitted, LVM selects automatically).

pvmove Command Options

The options of the pvmove command are listed below −

Flags Options Description
--abort Abort an ongoing pvmove operation.
--alloc [policy] Set allocation policy (contiguous, cling, normal).
--atomic Ensure all or none of the LVs are moved.
-A [y|n] --autobackup [y|n] Enable or disable automatic metadata backup.
-b --background Run pvmove in the background.
--commandprofile [String] Specify a command profile for configuration.
--config [String] Override lvm.conf settings.
-d --debug Set debug level (1-6 for increasing verbosity).
--devices [PV] Specify devices to use, can be repeated or comma-separated.
--devicesfile [String] Use a specific device file for LVM.
--driverloaded [y|n] Disable device-mapper usage for testing/debugging.
-h --help Display help text.
-I [Number] --interval [Number] Report progress at regular intervals.
--journal [String] Record command information in the systemd journal.
--lockopt [String] Pass options to lvmlockd.
--longhelp Display extended help text.
-n [String] --name [String] Move only extents belonging to a specific LV.
--nohints Ignore hint files when locating devices.
--nolocking Disable locking mechanism.
--noudevsync Disable udev synchronization.
--profile [String] Alias for --commandprofile or --metadataprofile.
-q --quiet Suppress output and log messages.
--reportformat [basic|json] Set output format (basic or JSON).
-t --test Run in test mode without modifying metadata.
-v --verbose Increase verbosity (1-4 levels).
--version Display version information.
-y --yes Automatically confirm prompts with yes.

Examples of pvmove Command in Linux

In this section, the usage of pvmove command will be discussed with examples −

  • Move Physical Extents from a Physical Volume (PV)
  • Move Physical Extents to a Specific Physical Volume (PV)
  • Running pvmove Command in Background
  • Aborting the pvmove Command Operation
  • Using pvmove Command with Atomic Mode
  • Displaying Progress at Regular Intervals
  • Moving Extents to Named Logical Volumes (LVs)
  • Displaying Usage Help

Move Physical Extents from a Physical Volume (PV)

To move physical extents (PEs) from a physical volume (PV) to other available physical volumes in the same volume group (VG).

sudo pvmove /dev/vda3

To check the free physical extents on all PVs, use the following command −

sudo vgdisplay
pvmove Command in Linux1

Move Physical Extents to a Specific Physical Volume (PV)

To move physical extents (PE) from a specific volume to other physical volumes, use the pvmove command in the following way −

sudo pvmove /dev/vda2 /dev/vda3

Note that the /dev/vda2 /dev/vda3 should be a part of the same VG.

Running pvmove Command in Background

To run the pvmove command in the background, use the -b or --background option −

sudo pvmove -b /dev/vda3

Aborting the pvmove Command Operation

To abort the ongoing pvmove command process, use the --abort option −

sudo pvmove --abort /dev/vda3

The abort operation stops the move, leaving partially moved extents in place unless --atomic is used.

Using pvmove Command with Atomic Mode

In the normal operation of the pvmove command, some data may move, leaving LVs split across PVs. The --atomic applies per LV, ensuring that each LV is fully moved or not moved at all, but not necessarily all LVs together. If the process is interrupted (manual abort), no data is partially moved; either the entire operation succeeds, or it fails without changes.

sudo pvmove --atomic /dev/vda2 /dev/vda3

Displaying Progress at Regular Intervals

To display the pvmove command progress at regular intervals, use the -i or --interval option −

sudo pvmove -b -i 10 /dev/vda2 /dev/vda3

The above command runs the process in the background (-b), and reports progress every 10 seconds.

Moving Extents to Named Logical Volumes (LVs)

Move physical extents to a specific LV using the -n or --name option.

sudo pvmove -n ubuntu-lv /dev/vda3

To display the LV name, use the following command −

sudo lvs
pvmove Command in Linux2

Displaying Usage Help

To display usage help of the pvmove command, use the -h or --help option −

pvmove -h

To display the detailed help, use the --longhelp option −

pvmove --longhelp

Conclusion

The pvmove command in Linux moves physical extents between physical volumes within a volume group. It helps manage logical volume storage by reallocating extents as needed. If interrupted, the pvmove command resumes from the last checkpoint when run again, or the process can be aborted using the --abort option. Various options allow for background execution, atomic moves, allocation policies, and progress reporting.

Advertisements