Learn › RHCSA (EX200) › Local Storage
lvcreate - a hands-on Linux lab on a real virtual machine.
Carve usable storage out of a volume group with lvcreate: size by capacity with -L 1G or by exact extent count with -l 40 (the classic exam wording), name it with -n, and inspect it with lvs and lvdisplay. Follow the LV device path /dev/vgdata/lvweb (and its /dev/mapper twin), put an XFS filesystem on it with mkfs.xfs, mount it, and remove it with lvremove. Serves EX200 local-storage task 10: create and remove logical volumes.
A request lands. The web team needs one gigabyte of storage at /mnt/web, and next month they will need more without downtime. You already have a volume group named vgdata sitting there with free space in it. But a volume group is not something you can format or mount. It is a warehouse of space, not a usable drive. You cannot point mkfs at vgdata and you cannot mount it. So how do you turn that pool of space into a real drive you can format, mount, and grow?
You carve a logical volume out of it. That is the top layer of LVM and the one you touch most, and it is EX200 local-storage task 10: create a logical volume of an exact size, put a filesystem on it, and mount it. By the end of this lesson you will slice a 1 GiB LV named lvweb out of vgdata, format it XFS, mount it at /mnt/web, and know how to remove one cleanly when it is no longer needed.
The black boxes below are a practice terminal: a safe sandbox that checks the one command each step teaches. Storage work is done as root, so the prompt reads [root@servera ~]#. The outputs shown are from a real RHEL 10 machine (AlmaLinux 10.2) with two spare disks where a real LVM stack was built. UUIDs, exact rounded sizes, and the dm-N device number are live values, so yours will read differently. What stays true everywhere is the SHAPE of each command, and that is the lesson.
A logical volume (LV) is a virtual partition carved from a volume group. Recall the LVM stack from the last two lessons: a physical disk or partition becomes a physical volume (PV), one or more PVs pool into a volume group (VG), and from that pool you slice logical volumes. The LV is the piece you actually format and mount, the wall you build from the pile of bricks.
Unlike a rigid disk partition, an LV can be grown, shrunk, moved between disks, and snapshotted, much of it while still mounted. That flexibility is the whole reason LVM exists, and it is why the exam builds its storage tasks on top of it. The tool that creates one is lvcreate.
lvcreate sizes an LV in one of two ways, and the exam picks the wording deliberately. -L (capital L) means an absolute capacity: -L 1G asks for one gigabyte. -l (lowercase l) means a count of extents: -l 40 asks for exactly forty extents.
An extent is the fixed-size block LVM allocates in, and on RHEL 10 the default extent size is 4 MiB. So -l 40 is 40 x 4 MiB = 160 MiB, and -l 256 is exactly 1 GiB. The exam loves the phrase 'an LV of 50 extents' precisely because it forces you to use -l, not -L. If you reach for -L when the task says extents, your size will not match and you lose the point.
The first move is to cut the volume. The recipe is lvcreate, then the size, then -n for the name you want, then the volume group to cut it from. Read it left to right: create a logical volume of 1 gigabyte, name it lvweb, out of vgdata.
Before you run it, know what to expect: lvcreate prints a one-line confirmation that the logical volume was created. Run it:
lvcreate -L 1G -n lvweb vgdata
prompt: [root@servera ~]# answer: lvcreate -L 1G -n lvweb vgdata output: Logical volume "lvweb" created. hint: The order is lvcreate, then -L 1G for the size, then -n lvweb for the name, then the VG: lvcreate -L 1G -n lvweb vgdata
Logical volume "lvweb" created. You just sliced a 1 GiB drive out of the vgdata pool. The -L 1G set the capacity, -n lvweb named it, and the bare vgdata at the end told LVM which volume group to take the space from. Had the task said 'create an LV of exactly 256 extents' you would have typed lvcreate -l 256 -n lvweb vgdata instead, and landed the same 1 GiB by counting extents rather than naming a capacity. Same tool, two ways to say how big.
Every LVM layer has a two-tool pair: a short summary and a long detail view. For logical volumes the short one is lvs. It prints one row per LV across every volume group, with the LV name, its VG, an attribute string, and its size.
Ask for the summary and find your new volume in the list:
lvs
prompt: [root@servera ~]# answer: lvs output: LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- <13.00g swap rhel -wi-ao---- 1.00g lvweb vgdata -wi-a----- 1.00g hint: The short logical-volume summary is a single word: lvs
There is your lvweb on the bottom row: VG vgdata, LSize 1.00g, exactly the gigabyte you asked for. The two rhel rows above it are the system's own root and swap volumes, so you are seeing the whole machine's LVs at once. That Attr column is worth a glance: the a in -wi-a----- means the volume is active (usable right now), and the o on the rhel rows means open (in use, because root and swap are mounted). Your lvweb is active but not yet open, because you have not put a filesystem on it or mounted it. That is the next move. For a fuller per-LV readout you would run lvdisplay /dev/vgdata/lvweb.
The exact LSize on the rhel rows and the <13.00g figure belong to this machine's disk layout. Yours will differ. What is stable is the shape: lvs gives one row per LV with its name, VG, Attr, and LSize, and your freshly created LV appears with the size you asked for.
Before you can format an LV you have to name its device file, and LVM gives every LV two paths that point at the same block device. The friendly one is /dev/<VG>/<LV>, here /dev/vgdata/lvweb. The other is the device-mapper name, /dev/mapper/vgdata-lvweb. Both are symbolic links to the same underlying dm-N device, and either works anywhere you need a device path.
Prove they point at the same thing. List the friendly path in long form and watch it resolve:
ls -l /dev/vgdata/lvweb
prompt: [root@servera ~]# answer: ls -l /dev/vgdata/lvweb output: /dev/vgdata/lvweb -> ../dm-2 hint: Long-list the friendly device path and read the arrow: ls -l /dev/vgdata/lvweb
/dev/vgdata/lvweb -> ../dm-2. The friendly path is a symlink pointing at the real device-mapper node dm-2. So /dev/vgdata/lvweb, /dev/mapper/vgdata-lvweb, and /dev/dm-2 are three names for one drive. On the exam use whichever you remember; the /dev/<VG>/<LV> form is the easiest to type from scratch. The dm-2 number is assigned by the kernel in creation order, so on your machine it might be dm-3 or dm-4, and that is fine.
The specific dm-2 here is this machine's kernel assignment and will vary. Do not memorize the number. Memorize that /dev/<VG>/<LV> and /dev/mapper/<VG>-<LV> both resolve to whatever dm-N the kernel handed out.
A fresh LV is raw block storage: no filesystem, nothing you can copy a file onto. You give it one with mkfs.xfs, pointing at the LV's device path. XFS is RHEL 10's default filesystem. One thing to file away for the extend lesson: XFS can only grow, never shrink, so if a task ever demands shrinking you would reach for mkfs.ext4 instead. For task 10, XFS is the right default.
After formatting you create a mount point and mount the LV there: mkdir -p /mnt/web, then mount /dev/vgdata/lvweb /mnt/web. Then df -h /mnt/web proves it is a live filesystem with real free space. Run that final check:
df -h /mnt/web
prompt: [root@servera ~]# answer: df -h /mnt/web output: Filesystem Size Used Avail Use% Mounted on /dev/mapper/vgdata-lvweb 960M 51M 910M 6% /mnt/web hint: Ask df for the human-readable usage of the mount point: df -h /mnt/web
There it is, a working drive. df reports the filesystem by its device-mapper name /dev/mapper/vgdata-lvweb, mounted on /mnt/web, with room to write files. Notice the Size reads 960M, not the flat 1.0G you carved. That is not a mistake and not lost space. XFS reserves a slice of every filesystem for its own metadata, the log and allocation structures, so the usable capacity always reports a touch under the raw LV size. The web team's gigabyte is now a real, formatted, mounted filesystem. That three-step arc, lvcreate then mkfs.xfs then mount, is the entire spine of task 10.
The exact Size, Used, and Avail figures are this machine's, and the device-mapper name follows your VG and LV names. Your numbers will differ. What holds everywhere: a formatted, mounted LV shows up in df -h as /dev/mapper/<VG>-<LV> on its mount point, reporting slightly under the raw LV size because of filesystem overhead.
Scaffolding off. No command is printed this time. You have every piece you need.
A new task hands you the classic exam wording: create a logical volume named lvcache of exactly 40 extents out of the vgdata volume group. Think about which sizing flag counts extents rather than capacity (capital versus lowercase), where the -n name goes, and which volume group ends the line. Build the one lvcreate line that carves precisely 40 extents.
prompt: [root@servera ~]# answer: lvcreate -l 40 -n lvcache vgdata output: Logical volume "lvcache" created. hint: Extents means the lowercase -l with a plain count, then -n lvcache, then the VG: lvcreate -l 40 -n lvcache vgdata
lvcreate -l 40 -n lvcache vgdata. The lowercase -l 40 is the whole answer to 'exactly 40 extents': it counts extents, not gigabytes, so with the default 4 MiB extent size you get precisely 160 MiB, no rounding surprises. Had you typed capital -L 40 you would have asked for 40 megabytes and failed the check. That is the trap the exam sets every time it says 'extents', and now you know the tell: the word extents means lowercase -l.
You earned this cheat sheet. Every row is a form you just ran or built:
The one thing to burn in for the exam: the word extents means lowercase -l with a plain count, and the word capacity (like 1G or 500M) means capital -L. Read the task, match the flag, and task 10's three-step spine (lvcreate, mkfs.xfs, mount) does the rest.
Removing an LV is irreversible. lvremove /dev/vgdata/lvweb destroys every byte on it and asks a single y/n confirmation, with no undo and no recycle bin. If the LV is mounted, umount it first or the removal is refused. Read the device path twice before you press y: lvremove cannot tell a wanted volume from a mistake.
The practice terminal has shown you the top layer of LVM end to end: lvcreate -L to carve by capacity and lvcreate -l to carve by exact extent count, lvs to see what you made, the /dev/<VG>/<LV> device path and its device-mapper twin, mkfs.xfs plus mount to turn raw space into a live filesystem, and lvremove to tear one down. Every one of those you typed yourself.
The local-storage module mission is where you run these against a real RHEL 10 machine with its own spare disks. A full VM boots for you, with /dev/vdb and /dev/vdc waiting to be partitioned, pooled into a volume group, and sliced into logical volumes. The mission hands you objectives that use exactly what you practiced here: create an LV of an exact number of extents, format it, mount it, and remove one cleanly. One difference from this lesson: the mission shows no commands. You read the objective, recall the lvcreate flag or the mkfs.xfs and mount pair, and type it. That recall is what makes it stick on exam day.
Finish the other local-storage lessons, then go carve a real machine's disk into volumes of your own.
Practice Create and Remove Logical Volumes in a real Linux terminal at The Linux Camp. Progress is verified automatically as you type commands on the machine.