11.4 Create and Delete Logical Volumes

Key Takeaways

  • Create LVs with lvcreate -n NAME -L Size VGNAME (or -l extents/%FREE); list with lvs and lvdisplay; remove with lvremove after closing use.
  • Device access paths are /dev/VG/LV and /dev/mapper/VG-LV (hyphen escaping rules); these are the block devices you format and mount.
  • Deleting an LV is destructive to its data—unmount, swapoff, or stop services first; confirm the exact LV name before lvremove.
  • lvcreate allocates from VG free space (VFree); insufficient free extents is the most common create failure.
  • LV existence persists across reboot when the VG activates; mounting still requires filesystem creation and fstab/systemd configuration in related objectives.
Last updated: August 2026

11.4 Create and Delete Logical Volumes

Quick Answer: From free space in a VG, create an LV with lvcreate -n data -L 2G research. Verify with lvs. The block device appears as /dev/research/data and /dev/mapper/research-data. Delete with lvremove research/data only after unmounting or otherwise releasing the device. EX200 grades correct name, size, and VG, then later objectives may add filesystems and mounts.

Official skill and stack position

Under Configure local storage, you must create and delete logical volumes. The LV is the allocatable chunk that usually becomes:

  • an XFS/ext4/VFAT filesystem, or
  • swap, or
  • occasionally a raw device for an application.

Layers again:

Disk → GPT partition → PV → VG → LV → mkfs/mkswap → mount/swapon → fstab

This section owns lvcreate / lvremove / lvs. Do not skip verification of the device node under /dev/mapper.

Create logical volumes: lvcreate

Size in absolute units

sudo lvcreate -n data -L 2G research
sudo lvcreate -n logs -L 512M research
sudo lvcreate --name shared --size 10G research
FlagPurpose
-n / --nameLV name
-L / --sizeHuman size (G, M, T)
final argVolume group name

Size in extents or free percentage

sudo lvcreate -n bulk -l 100%FREE research
sudo lvcreate -n half -l 50%FREE research
sudo lvcreate -n pevol -l 256 research      # 256 extents

100%FREE is popular when the task says “use all remaining space in the VG.”

Verify

sudo lvs
sudo lvs research/data
sudo lvdisplay research/data
ls -l /dev/research/data /dev/mapper/research-data
lsblk

Example lvs:

  LV   VG       Attr       LSize
  data research -wi-a----- 2.00g

Attr includes open flags when mounted (o appears when LV is in use). Size should match the request within extent rounding.

Device naming: /dev/mapper and /dev/VG/LV

After activation (normal default):

PathNotes
/dev/research/dataFriendly symlink path
/dev/mapper/research-dataDevice-mapper node (VG and LV joined by -)

If VG or LV names contain hyphens, LVM doubles them in the mapper name. Example: VG my-vg + LV my-lv/dev/mapper/my--vg-my--lv. Prefer simple names on EX200.

Use these paths for mkfs, mount, mkswap, and blkid—not the underlying /dev/sdb1 PV (unless you intentionally bypass LVM).

sudo mkfs.xfs /dev/research/data
# or
sudo mkfs.xfs /dev/mapper/research-data

(Filesystem creation is the next chapter’s deep focus; shown here so you know which device to format.)

Delete logical volumes: lvremove

sudo umount /dev/research/data     # if mounted
sudo swapoff /dev/research/swaplv   # if swap
sudo lvremove research/data
# confirm prompt: y
sudo lvremove -y research/old      # non-interactive when you are sure

Syntax accepts vgname/lvname:

sudo lvremove research/data

Destructive: all filesystem data on that LV is gone when removed (absent advanced recovery). Triple-check name with lvs before -y.

If lvremove says the LV is open:

findmnt /dev/research/data
sudo lsof /dev/research/data
sudo umount -R /mount/point
sudo lvremove research/data

Free space failures and partial sizes

sudo vgs research
# VFree 1.00g
sudo lvcreate -n big -L 50G research
# Insufficient free space

Remedies:

  1. Smaller -L / use -l 100%FREE
  2. vgextend with another PV first
  3. lvremove unused LVs to free space
sudo vgextend research /dev/sdc1
sudo lvcreate -n big -L 50G research

Root VG caution (non-destructive mindset)

Production-like exam systems already have LVs such as root and swap on VG rhel/rl:

sudo lvs
lsblk /
  • Do not lvremove root or swap LVs.
  • Creating an additional LV on the system VG is OK when free space exists and the task says so.
  • Prefer a dedicated VG when the task gives a spare disk and a new VG name—keeps mistakes off /.

Thin pools, stripes, mirrors (awareness only)

# Advanced forms exist:
# lvcreate --type raid1 ...
# lvcreate -T ... thin pool

EX200 study points emphasize standard linear LVs. Master -n, -L/-l, lvremove, and lvs before exploring RAID/thin options. Only use advanced types if a task explicitly requires them.

End-to-end exam scenarios

Scenario A — Create named LV with fixed size

Task: In VG research, create LV data of size 2G.

sudo vgs research
sudo lvcreate -n data -L 2G research
sudo lvs research/data
ls -l /dev/mapper/research-data

Scenario B — Consume remaining free space

Task: Create LV bulk using all free space in research.

sudo lvcreate -n bulk -l 100%FREE research
sudo lvs
sudo vgs   # VFree should be ~0

Scenario C — Delete an LV

Task: Remove LV olddata from VG research.

findmnt | grep olddata || true
sudo umount /dev/research/olddata 2>/dev/null || true
sudo lvremove -y research/olddata
sudo lvs research

Scenario D — Full stack preview (know where LV skill ends)

Many multi-step items chain:

sudo parted /dev/sdb --script mklabel gpt mkpart primary 1MiB 100%
sudo parted /dev/sdb set 1 lvm on
sudo pvcreate /dev/sdb1
sudo vgcreate research /dev/sdb1
sudo lvcreate -n data -L 2G research
# later objectives:
# mkfs.xfs /dev/research/data
# mount + /etc/fstab by UUID

If the item only says create the LV, stop after lvs succeeds. If it says create and mount XFS, continue—but still use the LV device, not the PV.

Persistence, activation, and reboot

  • LV metadata lives in the VG on the PVs → survives reboot.
  • On boot, LVM activates VGs/LVs; /dev/mapper/* nodes reappear.
  • Mounts do not automatically return without fstab or mount units—separate objective (mount by UUID/label).
  • After reboot in practice: sudo lvs, ls /dev/mapper, then check mounts if configured.
sudo lvs -a
sudo dmsetup ls

Verification checklist for graders (and you)

  1. Name exact: lvs shows LV and VG.
  2. Size correct (extent rounding within reason).
  3. Device node exists: /dev/VG/LV or /dev/mapper/VG-LV.
  4. After delete: LV absent from lvs; space returned to vgs VFree.
  5. Did not remove or shrink critical system LVs unless tasked.

Common traps

  1. lvcreate with PV path as last argument — last argument is VG name, not /dev/sdb1.
  2. Formatting the PV (mkfs /dev/sdb1) instead of the LV — destroys LVM structure.
  3. Wrong mapper spelling — remember vg-lv pattern.
  4. lvremove while mounted — unmount first.
  5. Assuming create mounts the volume — it only creates a block device.
  6. Using rm /dev/mapper/... — never; use lvremove.
  7. 100%FREE twice — second LV fails; free is already gone.
  8. Ignoring exact case/spelling of LV names in the exam text.

How this links to “add storage non-destructively”

Later objectives emphasize adding space without destroying existing data: vgextend + lvextend + grow filesystem. This section’s lvcreate builds new volumes; lvremove destroys them. Do not use lvremove as a shortcut to “fix” a filesystem problem on a volume that should have been grown or remounted.

Section checkpoint

You should allocate LVs with lvcreate using -L or -l (including %FREE), verify with lvs and /dev/mapper paths, remove LVs safely with lvremove after releasing mounts/swap, respect free space and system LVs, and leave persistent LVM metadata ready for reboot and for filesystem objectives that follow. Together with GPT partitions, PVs, and VGs, this completes the core LVM construction path for EX200 local storage.

Test Your Knowledge

Which command creates a 2 GiB logical volume named data in volume group research?

A
B
C
D
Test Your Knowledge

After creating LV data in VG research, which path is a correct device-mapper style block device for mkfs?

A
B
C
D
Test Your Knowledge

lvcreate fails with insufficient free space. Which action directly addresses the LVM free-space problem?

A
B
C
D
Test Your Knowledge

Before lvremove research/olddata, what must you ensure?

A
B
C
D