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 (
vgreducethenpvremove) - 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:
sudo pvcreate /dev/sdcsudo vgextend vg_data /dev/sdcThe 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:
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.00gThe /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:
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.00mpvmove /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:
-
Empty the disk (if not already done):
Terminal window sudo pvmove /dev/sdb -
Take the PV out of the Volume Group:
Terminal window sudo vgreduce vg_data /dev/sdbRemoved "/dev/sdb" from volume group "vg_data" -
Wipe the LVM label from the disk, which can then be unplugged:
Terminal window sudo pvremove /dev/sdbLabels 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.
sudo vgextend vg_data /dev/sdNEW # 1. add the new disksudo pvmove /dev/sdOLD /dev/sdNEW # 2. migrate the data to the new onesudo vgreduce vg_data /dev/sdOLD # 3. take the old one out of the VGsudo pvremove /dev/sdOLD # 4. wipe its labelGrow 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:
sudo pvresize /dev/sdb Physical volume "/dev/sdb" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resizedThe 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.
| Symptom | Likely cause | Fix |
|---|---|---|
pvmove: No extents available for allocation. | not enough free space on the other PVs | add a disk (vgextend) before migrating |
vgreduce: Physical volume "/dev/sdb" still in use | extents are still allocated on it | run 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 VG | vgreduce before pvremove |
| Refusing activation of partial LV | a disk of the VG has disappeared | plug it back, otherwise vgreduce --removemissing --force and restore |
| Migration interrupted by a reboot | normal, pvmove can resume | run pvmove again without arguments |
| Space of a grown disk invisible | PV not updated | pvresize /dev/sdX |
Key points
pvmovemoves 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:
pvmovethenvgreducethenpvremove, in this order. - Replace a live disk:
vgextend(new) →pvmove→vgreduce→pvremove(old). - Dead disk:
vgreduce --removemissing --forcedeletes the affected volumes, then restore from a backup. pvmoveis 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
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
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Software RAID on Linux with mdadm
A new full quiz with random questions
Work again only on the questions you missed
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.
pvmove moves the physical extents of a disk (PV) to the other PVs of the Volume Group, online, while the service keeps running. You use it to empty a disk before removing it, replace a disk that is weakening, or migrate storage to newer hardware, all with no downtime. The basic syntax is pvmove /dev/sdX, with the option to target a destination (pvmove /dev/sdX /dev/sdY) or a range of extents.sudo pvmove /dev/sdb # 1. empty the disk into the other PVs
sudo vgreduce vg_data /dev/sdb # 2. take the PV out of the Volume Group
sudo pvremove /dev/sdb # 3. wipe the LVM label
The order matters: running pvremove before vgreduce is refused and would require --force twice (-ff), which is not advised. You always take the PV out of the VG first, then wipe its label.pvmove works online: applications keep reading and writing to the volume while the data migrates. On the other hand, the operation copies blocks one by one: it is slow and very I/O intensive, which degrades performance for its duration. You therefore run it off-peak. It writes checkpoints, so it is resumable after a reboot: run pvmove again without arguments.sudo vgextend vg_data /dev/sdNEW
sudo pvmove /dev/sdOLD /dev/sdNEW
sudo vgreduce vg_data /dev/sdOLD
sudo pvremove /dev/sdOLD
If the disk is already dead, pvmove can no longer read its extents: you must force the removal with vgreduce --removemissing --force vg_data, which deletes the volumes that had extents on that disk, then recreate them and restore them from a backup. Hence the value of acting before the failure.pvmove writes checkpoints as the migration goes, so it survives an interruption (crash, reboot). To resume the operation where it stopped, simply run:sudo pvmove
without any argument. To cancel a migration in progress, use pvmove --abort. This robustness is what makes pvmove safe even on volumes of several hundred GiB.