System and processes

The vgextend command

Adds one or more physical volumes to a volume group to increase its space.

Syntax

sudo vgextend [opciones] <grupo> <dispositivo...>Try it in the terminal →

Most useful options

-tTest mode: runs the command without writing metadata. It can produce odd messages in multi-step operations.
-yDoes not ask for confirmation and always answers yes. Use it only in scripts you have tested before.
-fSkips checks and protections. Use it with extreme caution.
-A y|nAutomatic backup of the metadata after the change. Leaving it enabled is strongly advised.
--restoremissingAdds back a PV that was missing and has reappeared, for example after a transient failure. It does not reinitialize it.
-vShows more detail about the process. It can be repeated from 1 to 4 times.

Copy-ready examples

$ sudo vgslists the existing groups and confirms the name before extending.
$ sudo vgextend -t datos /dev/sdcsimulates the extension without writing metadata. Run this test first.
$ sudo vgextend datos /dev/sdcadds /dev/sdc to the datos group. If the disk is not a PV yet, vgextend initializes it.
$ sudo vgextend datos /dev/sdc /dev/sddadds two disks in a single step.
$ sudo vgextend --restoremissing datos /dev/sdcreturns a PV that was missing to the group, without reinitializing it.

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

Common errors

MessageCauseFix
Volume group "datos" not foundNo group has that name, or the disk that holds it does not show up on this machine.List the groups with sudo vgs and use the exact name.
Physical volume '/dev/sdc' is already in volume group 'otro'The device is already a PV of another group. A PV can belong to only one group at a time.Check which group it belongs to with sudo pvs /dev/sdc. If it is already part of the group you want, there is no need to add it.

Typical mistakes

  • vgextend does not create groups: the group must already exist. For a new one use vgcreate.
  • You do not need pvcreate first: if the disk is not a PV, vgextend prepares it.
  • Adding space to the group does not grow any volume. For that, use lvextend.

Differences from similar commands

  • vgcreate: creates a new group from one or more PVs. vgextend only enlarges a group that already exists.
  • lvextend: enlarges a logical volume inside the group. vgextend enlarges the group, not the volumes.
  • pvcreate: prepares a disk as a PV without adding it to any group. vgextend can do it too, but only for the group you name.

Security

By default vgextend wipes the first 4 sectors of a disk when it initializes it (the -Z option). If the disk holds a partition table or a filesystem, it is lost. Check the device with lsblk before adding it.

FAQ

What does vgextend do?

It adds one or more PVs to an existing volume group. The new space becomes available to the logical volumes in the group.

Do I need pvcreate first?

No. If the disk is not a PV yet, vgextend initializes it. You can run pvcreate beforehand if you want to prepare the disk separately.

How do I remove a disk I added?

With vgreduce. First check with pvs that the PV is not holding data in use.

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