| Tested on | Ubuntu 25.04 (Plucky Puffin) |
|---|---|
| Package | lvm2lvm2 |
| Applies to | Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Oracle Linux, CentOS Stream, Fedora, Arch Linux, SUSE, openSUSE, Alpine |
| Privilege | sudo or root |
| Man page | vgcreate(8) |
| Scope | vgcreate groups one or more physical volumes into a volume group — the storage pool from which logical volumes are allocated. It can initialize PVs automatically if they are not already labeled. |
| Related guides | vgextend vgs |
vgcreate — quick reference
Create volume groups
Combine initialized physical volumes into a named pool. Extents from all PVs become free space for lvcreate.
| When to use | Command |
|---|---|
| Create a VG from one PV | sudo vgcreate myvg /dev/sdX1 |
| Create a VG from multiple PVs | sudo vgcreate myvg /dev/sdX1 /dev/sdY1 |
| Let vgcreate initialize raw devices (calls pvcreate) | sudo vgcreate myvg /dev/sdX |
| Set physical extent size (default 4 MiB) | sudo vgcreate -s 8M myvg /dev/sdX1 |
| Set allocation policy at creation | sudo vgcreate --alloc contiguous myvg /dev/sdX1 |
| Cap how many LVs the VG may hold | sudo vgcreate -l 4 myvg /dev/sdX1 |
| Cap how many PVs may join the VG | sudo vgcreate -p 2 myvg /dev/sdX1 |
| Control metadata copy count on large VGs | sudo vgcreate --vgmetadatacopies 2 myvg /dev/sdX1 |
Inspect and extend
| When to use | Command |
|---|---|
| List volume groups | sudo vgs |
| Long VG details | sudo vgdisplay myvg |
| Add a PV to an existing VG | sudo vgextend myvg /dev/sdZ1 |
| Remove an empty VG | sudo vgremove myvg |
Help and version
| When to use | Command |
|---|---|
| Show built-in usage | vgcreate --help |
| Show LVM version | lvm version |
vgcreate — command syntax
Synopsis from vgcreate --help on Ubuntu 25.04 (LVM 2.03.27):
vgcreate VG_new PV ...
[ -s|--physicalextentsize Size[m|UNIT] ]
[ -l|--maxlogicalvolumes Number ]
[ -p|--maxphysicalvolumes Number ]
[ -f|--force ]
[ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ]
[ --vgmetadatacopies all|unmanaged|Number ]
[ COMMON_OPTIONS ]vgcreate writes VG metadata on the PVs you list. Default extent size is 4 MiB. Needs sudo.
vgcreate — command examples
Essential Create a volume group from one PV
Standard first step after pvcreate on a lab loop device.
fallocate -l 256M /tmp/lvm-lab-a.img
LOOP_A=$(sudo losetup -fP --show /tmp/lvm-lab-a.img)
sudo pvcreate $LOOP_A
sudo vgcreate labvg $LOOP_A
sudo vgs labvgSample output:
Volume group "labvg" successfully created.
VG #PV #LV #SN Attr VSize VFree
labvg 1 0 0 wz--n- 252.00m 252.00mVSize is slightly less than 256 MiB because LVM reserves metadata space on the PV.
Essential Create a VG spanning two PVs
Stripe and mirror LVs need enough PVs in the VG — start with two loop PVs.
fallocate -l 256M /tmp/lvm-lab-{a,b}.img
LOOP_A=$(sudo losetup -fP --show /tmp/lvm-lab-a.img)
LOOP_B=$(sudo losetup -fP --show /tmp/lvm-lab-b.img)
sudo pvcreate $LOOP_A $LOOP_B
sudo vgcreate labvg $LOOP_A $LOOP_B
sudo vgs labvgSample output:
Volume group "labvg" successfully created.
VG #PV #LV #SN Attr VSize VFree
labvg 2 0 0 wz--n- 504.00m 504.00mEssential Remove a lab VG cleanly
Always remove LVs before the VG, then PVs, then loop devices.
sudo lvremove -f labvg
sudo vgremove -f labvg
sudo pvremove -f $LOOP_A $LOOP_B
sudo losetup -d $LOOP_A $LOOP_B
rm -f /tmp/lvm-lab-*.imgSample output:
Volume group "labvg" successfully removed.
Labels on physical volume "/dev/loop24" successfully wiped.Common Set physical extent size with -s
Extent size is fixed at VG creation. Use a power-of-two size (for example 8 MiB) when aligning to RAID stripes.
sudo vgremove -f labvg
sudo pvcreate -ff -y $LOOP_A
sudo vgcreate -s 8M labvg $LOOP_A
sudo vgs -o vg_name,vg_extent_size labvgSample output:
Volume group "labvg" successfully created.
VG VSize VFree Ext
labvg 248.00m 248.00m 8.00mCommon Set allocation policy with --alloc
contiguous keeps LV extents adjacent on one PV when possible — useful for legacy workloads that required contiguous layouts.
sudo vgremove -f labvg
sudo pvcreate -ff -y $LOOP_A
sudo vgcreate --alloc contiguous labvg $LOOP_A
sudo vgdisplay labvg | grep -i allocSample output:
Volume group "labvg" successfully created.
Alloc contiguousChange policy later with lvchange or vgchange.
Common vgcreate without prior pvcreate
If the device has no LVM label, vgcreate initializes it as a PV automatically.
fallocate -l 128M /tmp/lvm-lab-d.img
LOOP_D=$(sudo losetup -fP --show /tmp/lvm-lab-d.img)
sudo vgcreate autovg $LOOP_D
sudo pvs $LOOP_DSample output:
Volume group "autovg" successfully created.
PV VG Fmt Attr PSize PFree
/dev/loop27 autovg lvm2 a-- 124.00m 124.00mpvs shows the PV already attached to autovg.
Advanced Limit logical volume count with -l
-l 1 allows only one LV in the VG — handy for embedded appliances or testing quota errors.
sudo vgremove -f labvg
sudo pvcreate -ff -y $LOOP_A $LOOP_B
sudo vgcreate -l 1 labvg $LOOP_A
sudo lvcreate -L 32M -n onlylv labvg
sudo lvcreate -L 16M -n secondlv labvgSample output:
Volume group "labvg" successfully created.
Logical volume "onlylv" created.
Maximum number of logical volumes (1) reached in volume group labvgThe second lvcreate fails while the limit is in effect.
vgcreate — when to use / when not
| Use vgcreate when | Use something else when |
|---|---|
|
|
vgcreate vs vgextend
| vgcreate | vgextend | |
|---|---|---|
| When | Brand-new VG name | Add PV to existing VG |
| PV state | New or uninitialized devices | Usually a new free PV |
| Metadata | Creates VG UUID | Grows existing pool |
vgcreate — interview corner
What is a volume group?
A volume group is the middle layer of LVM. It pools extents from one or more PVs so you can carve out logical volumes without caring which physical disk holds each block.
vgcreate assigns a name and UUID to that pool.
A strong answer is:
"A volume group is LVM's storage pool — vgcreate groups PVs so lvcreate can allocate logical volumes from shared free extents."
Can you change VG extent size after vgcreate?
No. -s / --physicalextentsize is fixed at creation. To change it you must create a new VG and migrate LVs (or restore from backup).
Default on Ubuntu is 4 MiB extents.
A strong answer is:
"Extent size is chosen at vgcreate time only — I pick it up front if I need alignment with RAID stripe width."
Must you run pvcreate before vgcreate?
Not always. vgcreate initializes devices that are not yet PVs. Many admins still run pvcreate first so pvs shows free PVs before grouping.
A strong answer is:
"vgcreate can pvcreate for me, but I often label PVs explicitly for clarity in pvs output."
What does vgcreate -l do?
-l / --maxlogicalvolumes caps how many LVs the VG may contain — a safety or licensing limit, not the size of any single LV.
A strong answer is:
"-l sets a maximum LV count for the volume group — useful for appliances or to test quota handling."
Name two VG allocation policies.
normal is the default (sensible placement rules). contiguous tries to keep LV extents adjacent; cling keeps stripes off the same PV; anywhere is more permissive.
Set at creation with --alloc or later with vgchange.
A strong answer is:
"normal is default; contiguous packs extents together; I set --alloc at vgcreate when a workload still expects contiguous LVs."
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Can't create volume group / PV in use |
PV already in another VG | vgs, pvs, use a different disk |
Invalid extent size |
Not a power of 2 or too small | Use 4M, 8M, 16M, … |
Volume group name already exists |
Duplicate VG name | Pick a unique name or vgremove the old lab VG |
Second lvcreate fails after -l 1 |
LV limit reached | vgchange -l 0 VG or recreate VG without cap |
unknown option |
Flag missing on host | vgcreate --help on target distro |
