Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

vgcreate

Create a volume group from one or more physical volumes (vgcreate), or delete a volume group (vgremove).

Level
RHCSA exam
Group
LVM
Needs root
Yes
Package
lvm2
Also called
vgremove

What it does

vgcreate NAME PV... joins PVs into a storage pool. Devices that are not PVs yet are initialized automatically. The extent size (-s, default 4 MiB) is the unit in which space is given to LVs; it is fixed for the life of the VG.

vgremove deletes a VG (and asks to remove its LVs).

How to write it

vgcreate [OPTION]... VG_NAME PV...
vgremove [OPTION]... VG_NAME...

Options 28

Most used

vgcreate

-s, --physicalextentsize SIZE
Extent size, like 8M or 16M (default 4M).
-l, --maxlogicalvolumes N
Maximum number of LVs.
-p, --maxphysicalvolumes N
Maximum number of PVs.
--addtag TAG
Add a tag.
--alloc POLICY
Allocation policy: normal, contiguous, cling, anywhere …
-A, --autobackup y|n
Back up the metadata after the change (default y).
--setautoactivation y|n
Activate at boot automatically.
--vgmetadatacopies all|unmanaged|N
Metadata copies in the VG.
--metadatasize SIZE, --pvmetadatacopies N, --dataalignment SIZE, --dataalignmentoffset SIZE, --labelsector N, -Z, --zero y|n
Settings for PVs that are created on the fly.
-M, --metadatatype lvm2
Metadata format.
--metadataprofile STRING
Metadata profile.
--systemid STRING
Set the system ID (owner host).
--shared, --locktype sanlock|dlm|none, -c, --clustered y|n
Shared VGs for clusters.
-f, --force
Force.
--reportformat basic|json
Output format.

vgremove

-f, --force
Remove the LVs without asking (twice: more force).
--noudevsync
Do not wait for udev.

Common LVM options

-t, --test
Test only; change nothing.
-v, --verbose
More output (repeat for more).
-q, --quiet
Less output.
-y, --yes
Answer yes to questions.
-d, --debug
Debug output.
--config STRING
Override lvm.conf settings for this command only.
--commandprofile STRING, --profile STRING
Use a configuration profile.
--devices PV, --devicesfile STRING
Limit the devices LVM looks at.
--driverloaded y|n, --nolocking, --lockopt STRING, --nohints, --journal STRING
Special and debug settings.
-h, --help, --longhelp
Show help.
--version
Show the version.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Create a VG

    vgcreate vgdata /dev/vdb1 /dev/vdc
      Volume group "vgdata" successfully created

    Two PVs in one pool.

  2. 2With an extent size of 8 MiB

    vgcreate -s 8M vgfiles /dev/vdc1

    Exam tasks often name the extent size.

  3. 3Check it

    vgs vgdata; vgdisplay vgdata | grep -E 'PE Size|Total PE|Free'

    PE Size, total and free extents.

  4. 4Directly on a new disk

    vgcreate vgbackup /dev/vdd

    vgcreate makes the PV for you.

  5. 5Test first

    vgcreate -t vgtest /dev/vde

    Nothing changes.

  6. 6Remove a VG

    vgremove vgtest

    Asks for every active LV. Remove fstab lines first!

  7. 7Remove with all LVs at once

    vgremove -f vgtest

    No questions — be sure.

  8. 8Rename a VG

    vgrename vgdata vgprod

    Update fstab and other configs that use the old name.

  9. 9Tag a VG

    vgcreate --addtag prod vgweb /dev/vdf

    Select VGs by tag in scripts (@prod).

  10. 10Metadata backup after changes

    ls /etc/lvm/backup/

    LVM writes a backup of each VG here automatically.

Exit codes

0 :: Done. 5 :: Error.