12.2 Add Partitions, Logical Volumes, and Swap Non-Destructively
Key Takeaways
- Non-destructive means add capacity without wiping existing partitions, volume groups, logical volumes, or file systems that already hold data.
- New partitions go into free space (or new disks) with parted/gdisk-style tools; new LVs consume free extents in a VG after any new PVs are extended into the group.
- Swap is created with mkswap on a partition, LV, or file, activated with swapon, and made persistent with a swap line in /etc/fstab (prefer UUID=).
- Always re-check existing mounts and LVM layout (lsblk, findmnt, vgs/lvs/pvs) before writing a new partition table or lvcreate so you do not overwrite live storage.
- Exam success is added usable storage or active swap still present after reboot—pair creation with fstab (and mounts from 12.1) when persistence is required.
12.2 Add Partitions, Logical Volumes, and Swap Non-Destructively
Quick Answer: Add storage—do not wipe what already works. Create new partitions in free space, new LVs in VG free PE, and swap with
mkswap+swapon+ fstabUUID=. Verify withlsblk,lvs/vgs,swapon --show, andmount -a. Destroying existing data fails both the system and the objective.
Official skill
Under Configure local storage, EX200 expects you to add new partitions and logical volumes, and swap to a system non-destructively. The key word is non-destructively: grow the system’s usable storage without deleting or reformatting volumes that already contain required data.
Related skills you already use:
- GPT partitioning, PV/VG/LV create/delete (prior chapter)
- Mount by UUID/label (Section 12.1)
- Later: extend existing logical volumes and grow file systems (separate objective—do not confuse “add new LV” with “extend this LV and xfs_growfs”)
This section focuses on adding capacity and adding swap safely.
What “non-destructive” means on the exam
| Allowed (additive) | Destructive (avoid unless the task explicitly deletes) |
|---|---|
| Create a new partition in free space on a disk | mkfs on a partition that already holds production data |
Add a new disk as a new PV and vgextend | vgremove / lvremove of in-use volumes “to start clean” |
lvcreate a new LV from free extents | Recreating a whole partition table that overlaps existing partitions |
mkswap on a new partition/LV reserved for swap | Using wipefs/dd on the wrong device |
| Append fstab lines | Deleting unrelated fstab mounts that already work |
If a disk already has / or /home partitions, you do not rebuild the entire table from scratch. You inspect free space and add beside existing partitions.
Always inventory first
lsblk -f
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
findmnt
sudo pvs; sudo vgs; sudo lvs
cat /etc/fstab
free -h
swapon --show
Sketch what is already mounted and which VGs have free space (VFree in vgs). Only then plan the new partition, LV, or swap device.
Adding partitions non-destructively
New free space on an existing disk
- Confirm free space:
lsblk,sudo parted /dev/sdb print free(orgdisk/fdiskprint). - Create a new partition only in the free region—do not delete partition 1 to “make room” if it still holds data.
- Write the table, run
partprobeor re-read as needed (udevadm settle, reboot only if the kernel will not re-read—prefer non-reboot methods first). - Optionally
mkfsonly on the new partition if the task wants a data FS (ormkswapif it is swap). - Persist mounts with UUID fstab (12.1).
sudo parted /dev/sdb print free
# Example: create a new primary partition in free space (sizes/names are task-specific)
sudo parted -s /dev/sdb mkpart primary xfs 20GiB 40GiB
sudo partprobe /dev/sdb
lsblk /dev/sdb
# New node might be /dev/sdb2 — confirm before mkfs
sudo mkfs.xfs /dev/sdb2
blkid /dev/sdb2
GPT vs legacy: RHEL 10 labs commonly use GPT. Match tools to the disk label already in use. Do not convert tables casually.
Entire new disk
A new unused disk (no existing partitions/data required by the system) can be partitioned from scratch on that disk only—still non-destructive relative to other disks. Never initialize the wrong disk (/dev/sda vs /dev/sdb).
lsblk
# Triple-check the device name before parted/mkfs
Adding logical volumes non-destructively
Non-destructive LVM addition usually means one of:
lvcreatea new LV in a VG that still has free physical extents.- Add a new PV (
pvcreateon a new partition/disk) →vgextendan existing VG →lvcreate(or later extend an LV).
sudo vgs
# VG has free space? create new LV only:
sudo lvcreate -n lvdata -L 5G vgapp
sudo mkfs.xfs /dev/vgapp/lvdata
blkid /dev/vgapp/lvdata
sudo mkdir -p /data
# fstab UUID=... /data xfs defaults 0 0
sudo mount -a
findmnt /data
When the VG is full, extend the VG first without removing old PVs:
# New partition /dev/sdc1 dedicated as PV (created in free space / new disk)
sudo pvcreate /dev/sdc1
sudo vgextend vgapp /dev/sdc1
sudo vgs
sudo lvcreate -n lvlogs -L 2G vgapp
Do not vgremove vgapp just because you want another LV. Do not lvremove the root LV to free space. Free space comes from unused PE or new PVs.
lvcreate sizing reminders
sudo lvcreate -L 10G -n lv1 vg1 # exact size
sudo lvcreate -l 100%FREE -n lv2 vg1 # consume remaining PE (careful: leaves no free PE)
sudo lvcreate -l 50%FREE -n lv3 vg1
Prefer exact sizes from the task (5G, 512M). Using 100%FREE is fine when the task says “use all remaining space,” but it blocks later additive LVs until you add more PV space.
Adding swap non-destructively
Swap can be a partition, a logical volume, or less often a swap file. EX200 commonly uses a partition or LV. Steps:
- Create the partition or LV without destroying other volumes.
mkswapinitialize swap signature.swaponactivate immediately./etc/fstabentry for boot persistence (UUID preferred).- Verify with
swapon --showandfree -h.
Swap on a new partition
# After creating /dev/sdb3 as type linux-swap (or generic partition for swap)
sudo mkswap /dev/sdb3
blkid /dev/sdb3
# UUID="...." TYPE="swap"
sudo swapon /dev/sdb3
swapon --show
free -h
Swap on a new LV
sudo lvcreate -n swapvol -L 1G vg0
sudo mkswap /dev/vg0/swapvol
blkid /dev/vg0/swapvol
sudo swapon /dev/vg0/swapvol
swapon --show
fstab for swap
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx none swap defaults 0 0
Also acceptable in many systems:
UUID=... swap swap defaults 0 0
Field meaning: type is swap; mount point is conventionally none or swap; dump and pass are 0 0 (never run fsck on swap as a normal FS).
Activate all fstab swap devices:
sudo swapon -a
swapon --show
Swap file (awareness)
sudo fallocate -l 1G /swapfile
# or dd if fallocate unsuitable on some FS
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# fstab: /swapfile none swap defaults 0 0
Prefer partition/LV when the task says “partition” or “logical volume.” Swap files are non-destructive to disks but still consume file-system space—do not place them carelessly on tiny root filesystems without reading the task.
Disable swap (only when needed)
sudo swapoff /dev/sdb3
sudo swapoff -a
Do not swapoff production swap during the exam unless you are resizing/replacing that swap device carefully.
Combining add + persistent mount
A full “add data storage” story often chains objectives:
new partition or LV → mkfs → UUID fstab mount (12.1) → mount -a → findmnt
new swap device → mkswap → UUID fstab swap → swapon -a → swapon --show
Non-destructive discipline applies at every step: only format new devices.
End-to-end exam scenarios
Scenario A — New 2G data LV, mounted at /data
sudo vgs
sudo lvcreate -n data -L 2G vgstorage
sudo mkfs.xfs /dev/vgstorage/data
UUID=$(blkid -s UUID -o value /dev/vgstorage/data)
sudo mkdir -p /data
echo "UUID=${UUID} /data xfs defaults 0 0" | sudo tee -a /etc/fstab
sudo mount -a
findmnt /data
(Editing fstab with vim is equally valid—avoid duplicate lines.)
Scenario B — Add 512M swap LV that survives reboot
sudo lvcreate -n swap1 -L 512M vg0
sudo mkswap /dev/vg0/swap1
UUID=$(blkid -s UUID -o value /dev/vg0/swap1)
echo "UUID=${UUID} none swap defaults 0 0" | sudo tee -a /etc/fstab
sudo swapon -a
swapon --show
free -h
Scenario C — New disk becomes PV; new LV without touching old LVs
lsblk
sudo parted -s /dev/sdd mklabel gpt mkpart primary 1MiB 100%
sudo pvcreate /dev/sdd1
sudo vgextend vgapp /dev/sdd1
sudo lvcreate -n newapp -L 10G vgapp
# old LVs unchanged — verify:
sudo lvs
findmnt
Scenario D — Free space partition for swap only
sudo parted /dev/sdb print free
# create partition in free space, type suitable for linux swap if your tool sets codes
sudo mkswap /dev/sdb2
sudo swapon /dev/sdb2
# fstab UUID line
sudo swapon -a
Verification checklist (use before leaving the station)
| Goal | Check |
|---|---|
| New partition exists | lsblk, parted print |
| New LV exists | lvs, /dev/vg/lv path |
| Existing data still mounted | findmnt, application paths |
| Data FS persistent | fstab UUID + mount -a + findmnt |
| Swap active now | swapon --show, free -h |
| Swap at boot | fstab swap line + swapon -a clean |
| VG still healthy | vgs, pvs without missing PVs |
Optional reboot in practice labs confirms persistence; on timed exams, mount -a / swapon -a plus correct fstab is the standard pre-reboot proof.
Common traps
mkfson the wrong device — erases existing data; alwayslsblk/blkidfirst.- Deleting partitions to recreate the disk when free space existed for an additive partition.
lvremoveof the wrong LV to “free space” instead of adding a PV.mkswapwithout fstab — swap works until reboot, then vanishes.- fstab device path for swap that renames after reboot—use UUID=.
- Forgetting
swaponafter mkswap—free -hstill shows old swap. - Duplicate UUIDs if you clone disks without re-making swap/FS UUIDs—regenerate with
mkswap/xfs_admin -Uonly on the clone you intend to change. - Using 100%FREE for one LV when the task also requires a second new LV—plan sizes first.
- Confusing this objective with LV extend —
lvextend+xfs_growfsgrows an existing FS;lvcreateadds a new volume. Read the task verb: add vs extend. - Wiping
/etc/fstabwhile appending—back up or edit carefully so root still mounts.
Ordering relative to other chapters
| Step | Objective family |
|---|---|
| Create partitions / PVs / VGs / LVs fundamentals | Storage partitions & LVM chapter |
| Add more of them without destroying existing layout | This section |
| Mount by UUID/label | 12.1 |
| Create/use ext4/XFS/VFAT, unmount | File systems chapter |
| Extend existing LV and grow FS | Extend logical volumes objective |
Section checkpoint
You should inventory the system first, add partitions only in free space, add LVs with lvcreate (and vgextend when needed) without removing live volumes, build swap with mkswap/swapon/fstab UUID lines, verify with lsblk, lvs/vgs, findmnt, and swapon --show, and never run destructive format/remove commands on devices that already hold required data. That is the EX200 meaning of adding partitions, logical volumes, and swap non-destructively.
Which sequence correctly activates a new swap logical volume for the current session and for future boots?
A VG still has free extents and /home is mounted from an existing LV. You need another 3G volume for /data without losing /home. What is the non-destructive approach?
After mkswap /dev/sdb2, which command shows that swap is active on that device right now?
You need a new partition for swap on a disk that already has a data partition with important files. Which action is non-destructive?