System and processes

The pvremove command

Wipes the LVM label from a physical volume so the disk stops being one.

Syntax

sudo pvremove <dispositivo...>Try it in the terminal →

Most useful options

-f, --forceSkips confirmations and checks. Repeated (-ff) it removes a PV that still belongs to a group: use it only when you know no data is at stake
-y, --yesDoes not ask and answers yes. With a PV in a group, -y alone is not enough: -ff is needed
-t, --testTest mode: does not update the metadata and returns success anyway
-q, --quietSuppresses output and log messages. Repeated (-qq) it also answers no to prompts
--reportformat basic|jsonChanges the output to JSON

Copy-ready examples

$ pvschecks which PVs exist and which group each one belongs to before deleting anything.
$ sudo pvremove /dev/sdcwipes the label of a disk that no longer belongs to any group. Destructive: the disk stops being a PV for LVM.

Example output

Labels on physical volume "/dev/sdc" successfully wiped.
$ sudo pvremove /dev/sdc1 /dev/sddwipes the label of several PVs in one command. Same warning as above.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
PV /dev/sdc is used by VG datos so please use vgreduce first.The disk belongs to the datos group. pvremove does not remove a PV that is still inside a group without -ff.Take it out of the group with vgreduce datos /dev/sdc. If the group holds data, move it first with pvmove.
Please enter a physical volume pathYou ran pvremove without naming any device.Name the device, for example: sudo pvremove /dev/sdc.

Typical mistakes

  • With a PV in a group, -f or -y on their own are not enough: -ff is needed. With -ff -y the wipe happens without asking.
  • pvremove wipes the LVM label from the device, not necessarily the rest of the data on it.
  • Without -ff, pvremove refuses a PV that belongs to a group, just like pvcreate, and the message names the group.
  • Before wiping, check the VG column with pvs: if a group appears, take the disk out of it first.

Differences from similar commands

  • pvcreate: does the opposite: prepares a disk as a PV.
  • vgreduce: takes a PV out of its group. The manual says the normal route is to use it instead of pvremove.
  • lvremove: removes logical volumes. pvremove works on the physical disk, not on its volumes.

FAQ

What exactly does pvremove do?

It wipes the LVM label from the device, so LVM stops recognising it as a PV. After that the disk can be reused for something else.

When does pvremove fail?

When the PV still belongs to a group without -ff, or when it cannot wipe the label. In the second case «Failed to wipe existing label(s)» appears next to the device.

Do I need to remove the PV from its group first?

Normally yes, with vgreduce. pvremove -ff exists for exceptional cases, and the manual says vgreduce is the usual route.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course