Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Migrate and remove an LVM disk with pvmove

By updated

Improve this page

pvmove moves data from one LVM disk to another online, without unmounting or interrupting the service. It is the command that lets you remove a disk from a Volume Group, replace one that is weakening, or migrate storage to newer hardware, with no downtime. This guide shows how to add a disk, move its extents with pvmove, then remove it cleanly with vgreduce and pvremove. For intermediate Linux administrators, on Debian/Ubuntu and RHEL/AlmaLinux. All outputs come from a real test on AlmaLinux 10 (LVM 2.03.36).

What you will learn

  • Add a disk to a Volume Group with vgextend
  • Move data from one disk to another, online, with pvmove
  • Remove a disk cleanly (vgreduce then pvremove)
  • Replace a failing disk
  • Grow a PV after extending a virtual disk (pvresize)

Prerequisites

An LVM stack in place (see the LVM guide) and a second disk available to receive the moved data. The Volume Group must have enough free space on the other PVs to take the migrated extents.

Add a disk to a Volume Group

When a Volume Group runs short of space, you add a disk to it. You initialise the PV, then aggregate it with vgextend:

Terminal window
sudo pvcreate /dev/sdc
sudo vgextend vg_data /dev/sdc

The VG now has the sum of both disks. It is also the first step to replace a disk: you add the new one before emptying the old one.

Move a volume between disks with pvmove

pvmove copies the physical extents of a disk to the other PVs of the Volume Group, online. The service keeps reading and writing during the operation. Let's start from a VG on two disks, the first of which carries a 1 GiB volume:

Terminal window
sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sdb vg_data lvm2 a-- <2.00g 1020.00m
/dev/sdc vg_data lvm2 a-- <2.00g <2.00g

The /dev/sdb disk is in use (only 1020 MiB free out of 2 GiB), /dev/sdc is empty. You empty /dev/sdb into the rest of the VG:

Terminal window
sudo pvmove /dev/sdb
/dev/sdb: Moved: 5.86%
/dev/sdb: Moved: 100.00%

The command shows its progress up to 100%, while the volume stays mounted. The data has migrated, and pvs confirms the swap: /dev/sdb is now empty, /dev/sdc carries the volume.

PV VG Fmt Attr PSize PFree
/dev/sdb vg_data lvm2 a-- <2.00g <2.00g
/dev/sdc vg_data lvm2 a-- <2.00g 1020.00m

pvmove /dev/sdb spreads the extents over all available PVs of the group. To target a specific disk, add the destination: pvmove /dev/sdb /dev/sdc. To move only a range of extents: pvmove /dev/sdb:1000-1999. And pvmove -b runs the operation in the background.

Remove a disk cleanly

Once the disk is empty, you remove it from the Volume Group then wipe its LVM label, in this order:

  1. Empty the disk (if not already done):

    Terminal window
    sudo pvmove /dev/sdb
  2. Take the PV out of the Volume Group:

    Terminal window
    sudo vgreduce vg_data /dev/sdb
    Removed "/dev/sdb" from volume group "vg_data"
  3. Wipe the LVM label from the disk, which can then be unplugged:

    Terminal window
    sudo pvremove /dev/sdb
    Labels on physical volume "/dev/sdb" successfully wiped.

The order matters. Run on a PV still member of the VG, pvremove refuses with "PV /dev/sdb is used by VG vg_data so please use vgreduce first" and would only go through with --force twice (-ff), which would corrupt the VG. Always remove from the VG first, with vgreduce.

Replace a failing disk

To replace a disk that is weakening but still works, you combine the steps: add the new one, migrate onto it, remove the old one.

Terminal window
sudo vgextend vg_data /dev/sdNEW # 1. add the new disk
sudo pvmove /dev/sdOLD /dev/sdNEW # 2. migrate the data to the new one
sudo vgreduce vg_data /dev/sdOLD # 3. take the old one out of the VG
sudo pvremove /dev/sdOLD # 4. wipe its label

Grow a PV after extending the disk

When you grow a virtual disk (VM) or an underlying partition, LVM does not see the new space until you tell it. pvresize updates the PV:

Terminal window
sudo pvresize /dev/sdb
Physical volume "/dev/sdb" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized

The added space then becomes allocatable by the Volume Group, ready for an lvextend. It is the natural companion of pvmove when migrating to a bigger disk.

Caution: pvmove is slow and intensive

Moving a volume online has a cost the command does not show: every extent is read then rewritten while applications keep working. On a disk of several hundred gigabytes, the migration can last hours, and the server runs slower for all that time.

Troubleshooting

LVM migration commands almost always refuse with an explicit message, which names the forgotten step. Read it before looking further: in most cases, you just need to follow the order vgextend, pvmove, vgreduce, pvremove again.

SymptomLikely causeFix
pvmove: No extents available for allocation.not enough free space on the other PVsadd a disk (vgextend) before migrating
vgreduce: Physical volume "/dev/sdb" still in useextents are still allocated on itrun pvmove first to empty it
pvremove: PV /dev/sdb is used by VG vg_data so please use vgreduce first.PV still a member of the VGvgreduce before pvremove
Refusing activation of partial LVa disk of the VG has disappearedplug it back, otherwise vgreduce --removemissing --force and restore
Migration interrupted by a rebootnormal, pvmove can resumerun pvmove again without arguments
Space of a grown disk invisiblePV not updatedpvresize /dev/sdX

Key points

  • pvmove moves a disk's extents to the other PVs of the VG, online.
  • Target a destination (pvmove /dev/sdb /dev/sdc) or a range (pvmove /dev/sdb:1000-1999).
  • Remove a disk: pvmove then vgreduce then pvremove, in this order.
  • Replace a live disk: vgextend (new) → pvmove → vgreduce → pvremove (old).
  • Dead disk: vgreduce --removemissing --force deletes the affected volumes, then restore from a backup.
  • pvmove is slow, I/O intensive but resumable (run it again without arguments). Back up first.

Knowledge check

Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

FAQ: frequently asked questions about pvmove and LVM disk management

These answers cover the questions that come up most about pvmove: online migration, removing a disk and the case of a dead disk.