RED HAT ENTERPRISE LINUX
Non-Destructive Storage
Expansion
Add new partitions and logical volumes, and swap to a system non-destructively
CIS126RH | RHEL System Administration 1
Mesa Community College
Production servers must grow their storage capacity without downtime. Adding a partition to a disk that already has data, extending an LVM volume group and logical volume while filesystems are mounted, and increasing swap space on a live system are all operations that must leave existing data completely intact. This module integrates the partition, LVM, swap, and fstab skills from previous modules into a complete non-destructive expansion workflow tested on the RHCSA exam.
Learning Objectives
-
Add a new partition to a disk with existing partitions —
Use
partedto create a new partition in free space on a disk that already has data partitions, without touching existing partitions - Extend an LVM volume group and logical volume online — Add a new physical volume to an existing VG and extend a logical volume and its filesystem while it remains mounted
-
Add swap space non-destructively —
Create a new swap partition or LVM swap volume, activate it, and make it
persistent in
/etc/fstab - Verify all changes persist after reboot — Confirm that new mounts, extended filesystems, and swap are all correctly configured in fstab and survive a system restart
What "Non-Destructive" Means
Every storage expansion operation on a running system must preserve all existing data. "Non-destructive" imposes specific constraints on each operation.
| Operation | Non-destructive requirement | What would be destructive |
|---|---|---|
| Add a partition | Only use free space on the disk; do not resize or delete existing partitions | Repartitioning the disk from scratch; shrinking an existing partition |
| Extend an LV | Add space to the LV and grow the filesystem online; existing data is preserved | Shrinking the LV below the used space; removing the LV |
| Add swap | Create additional swap on free space; do not modify existing swap | Removing existing swap while in use; reformatting an active partition as swap |
| Persistent mounts | Add new fstab entries without modifying existing lines | Deleting or changing existing fstab entries for mounted filesystems |
Adding a Partition to a Disk with Existing Data
The disk must have free (unpartitioned) space. Verify the layout first, then create a new partition in the available space.
# Step 1: Inspect the current partition layout
$ sudo parted /dev/sdb print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 20.0GB
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 5369MB 5368MB xfs primary
← 14.6 GB free after partition 1
# Step 2: Create a new partition in the free space
$ sudo parted /dev/sdb
(parted) mkpart primary xfs 5369MB 10737MB # 5 GB partition
(parted) print
Number Start End Size File system Name
1 1049kB 5369MB 5368MB xfs primary ← untouched
2 5369MB 10737MB 5368MB xfs primary ← new
(parted) quit
# Step 3: Update the kernel's view
$ sudo partprobe /dev/sdb
$ lsblk /dev/sdb
The new partition must start at or after the end of the last existing partition. Read the End value from the parted print output and use it as the start of the new partition to guarantee no overlap.
Format and Mount the New Partition
After creating the partition and updating the kernel, format and mount it, then add the persistent fstab entry using UUID.
# Format the new partition (existing partition is NOT touched)
$ sudo mkfs.xfs /dev/sdb2
meta-data=/dev/sdb2 isize=512 agcount=4...
# Get the UUID of the new filesystem
$ sudo blkid /dev/sdb2
/dev/sdb2: UUID="mnp012-qr34-st56-uv78-wx901234yzab" TYPE="xfs"
# Create the mount point
$ sudo mkdir -p /newdata
# Add the persistent fstab entry
$ echo "UUID=mnp012-qr34-st56-uv78-wx901234yzab /newdata xfs defaults 0 2" | \
sudo tee -a /etc/fstab
# Mount and verify
$ sudo mount -a
$ df -h /newdata
# Verify the existing partition is still intact
$ ls /existingdata # existing data is untouched
Extending an LVM Volume Group Online
Adding capacity to an existing LVM setup is a live, non-disruptive operation. The volume group, logical volume, and filesystem all grow while mounted.
# Step 1: Confirm current state — VG is nearly full
$ sudo vgs
VG #PV #LV Attr VSize VFree
datavg 1 1 wz--n- <10.00g 500.00m
# Step 2: Prepare new storage (partition + PV)
$ sudo parted --script /dev/sdc mklabel gpt mkpart primary 1MiB 100%
$ sudo partprobe /dev/sdc
$ sudo pvcreate /dev/sdc1
# Step 3: Add the PV to the existing VG
$ sudo vgextend datavg /dev/sdc1
Volume group "datavg" successfully extended
# Step 4: Extend the LV and grow the filesystem at once
$ sudo lvextend -L +8G -r /dev/datavg/data
Size of logical volume datavg/data changed to 10.00 GiB
Filesystem on /dev/datavg/data resized successfully
# Step 5: Verify — LV and filesystem both grew
$ sudo lvs datavg/data
$ df -h /data
Adding a New LV to an Existing VG
If the VG has free space, a new logical volume can be created immediately without adding any new physical storage.
# Check available free space in the VG
$ sudo vgs
VG #PV #LV Attr VSize VFree
datavg 2 1 wz--n- <20.00g <10.00g ← 10 GB free
# Create a new LV from the VG's free space
$ sudo lvcreate -L 5G -n logs datavg
Logical volume "logs" created.
# Format, mount, add to fstab
$ sudo mkfs.xfs /dev/datavg/logs
$ sudo mkdir -p /logs
$ sudo blkid /dev/datavg/logs
# Add UUID entry to /etc/fstab
$ sudo mount -a
$ df -h /logs
# Confirm existing LV is still intact and mounted
$ df -h /data
$ sudo lvs
A new logical volume only uses free extents from the VG pool — it cannot overlap with existing LVs. Existing LVs, their filesystems, and their data are completely unaffected by lvcreate.
Adding Swap: Partition Method
When free disk space is available, a new swap partition is the simplest way to add swap capacity without affecting existing partitions.
# Step 1: Check current swap
$ free -h
total used free shared
Swap: 2.0Gi 512Mi 1.5Gi
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda2 partition 2G 512M -2
# Step 2: Create a new partition for swap
$ sudo parted --script /dev/sdb mkpart primary linux-swap 10737MB 12785MB
$ sudo partprobe /dev/sdb
# Step 3: Format as swap
$ sudo mkswap /dev/sdb3
Setting up swapspace version 1, size = 2 GiB
# Step 4: Activate immediately
$ sudo swapon /dev/sdb3
# Step 5: Add persistent fstab entry using UUID
$ sudo blkid /dev/sdb3
/dev/sdb3: UUID="xyz789-ab01-cd23-ef45-gh6789ijklmn" TYPE="swap"
$ echo "UUID=xyz789-ab01-cd23-ef45-gh6789ijklmn none swap defaults 0 0" | \
sudo tee -a /etc/fstab
# Step 6: Verify
$ swapon --show
Adding Swap: LVM Method
Creating swap as a logical volume uses existing VG free space and is the preferred method when the system already uses LVM.
# Step 1: Confirm VG has free space
$ sudo vgs
VG VSize VFree
datavg <20.00g <5.00g
# Step 2: Create a swap LV from VG free space
$ sudo lvcreate -L 2G -n swap2 datavg
Logical volume "swap2" created.
# Step 3: Format as swap
$ sudo mkswap /dev/datavg/swap2
Setting up swapspace version 1, size = 2 GiB
# Step 4: Activate immediately
$ sudo swapon /dev/datavg/swap2
# Step 5: Add persistent fstab entry (LVM path is stable)
$ echo "/dev/datavg/swap2 none swap defaults 0 0" | \
sudo tee -a /etc/fstab
# Step 6: Verify — existing swap and new swap both active
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda2 partition 2G 512M -2
/dev/mapper/datavg-swap2 partition 2G 0B -3
Checking and Managing Swap
Several commands provide visibility into current swap usage and configuration.
# Show all swap devices with size, usage, and priority
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda2 partition 2G 256M -2
/dev/datavg/swap2 partition 2G 0B -3
# Show swap summary alongside RAM
$ free -h
total used free
Mem: 7.6Gi 2.1Gi 5.5Gi
Swap: 4.0Gi 256Mi 3.7Gi ← 4 GiB total (2+2)
# Deactivate a specific swap device (e.g. before removal)
$ sudo swapoff /dev/datavg/swap2
# Activate all swap listed in /etc/fstab
$ sudo swapon -a
# Set higher priority for a swap device (used first)
$ sudo swapon -p 10 /dev/datavg/swap2
# In fstab, use: /dev/datavg/swap2 none swap defaults,pri=10 0 0
The Non-Destructive Expansion Checklist
Before and after every storage expansion, follow this checklist to confirm that existing data and mounts are intact.
-
Before any changes — record the baseline
lsblk,df -h,swapon --show,sudo pvs,sudo vgs,sudo lvs -
Identify available free space
Parted: gap after last partition. LVM: VFree in vgs output. Disk: unpartitioned space shown in lsblk. -
Make changes using only the identified free space
New partition starts where the last one ended. New PV/LV uses VG free space, not existing allocations. -
After changes — verify both old and new
Existing mounts still accessible:ls /existingmount
Existing swap still active:swapon --show
New mount working:df -h /newmount -
Make persistent — add fstab entries
Test withsudo mount -aandfindmnt --verify
Complete Scenario: Add Storage to a Live Server
A server with /dev/sdb (10 GB, has one 5 GB XFS partition at
/data) needs a second 3 GB data partition and 1 GB more swap.
All without touching the existing /data filesystem.
Part A: New data partition
$ sudo parted /dev/sdb print # confirm free space starts at 5369MB
$ sudo parted --script /dev/sdb mkpart primary xfs 5369MB 8590MB
$ sudo partprobe /dev/sdb
$ sudo mkfs.xfs /dev/sdb2
# blkid → add UUID to fstab → mount -a → df -h /data2
Part B: New swap partition
$ sudo parted --script /dev/sdb mkpart primary linux-swap 8590MB 9663MB
$ sudo partprobe /dev/sdb
$ sudo mkswap /dev/sdb3
$ sudo swapon /dev/sdb3
# blkid → add UUID swap entry to fstab
Verification
$ ls /data # existing partition untouched
$ df -h /data2 # new data partition working
$ swapon --show # both old and new swap active
Complete Scenario: Expand LVM Storage Online
A server's /dev/datavg/data LV mounted at /data
is 80% full. A new 10 GB disk has been added. Expand without downtime.
# 1. Baseline
$ df -h /data # record current size and usage
$ ls /data # confirm existing data is present
# 2. Prepare new disk as PV
$ sudo parted --script /dev/sdc mklabel gpt mkpart primary 1MiB 100%
$ sudo partprobe /dev/sdc
$ sudo pvcreate /dev/sdc1
# 3. Add PV to existing VG
$ sudo vgextend datavg /dev/sdc1
# 4. Extend LV and filesystem (all online)
$ sudo lvextend -l +100%FREE -r /dev/datavg/data
# 5. Verify — existing data intact, filesystem is larger
$ ls /data # original files still present
$ df -h /data # size has increased
$ sudo lvs # LV shows new size
$ sudo vgs # VFree should be ~0 (used all free space)
Making All Changes Persistent
New mounts and swap must be in /etc/fstab to survive reboots.
Extended LV filesystems survive automatically — the LV size is stored in LVM metadata.
# View the current fstab to avoid duplicate entries
$ cat /etc/fstab
# Add new partition mount (UUID from blkid)
UUID=mnp012-qr34-st56... /data2 xfs defaults 0 2
# Add new swap partition (UUID from blkid)
UUID=xyz789-ab01-cd23... none swap defaults 0 0
# Add new LVM swap (device path is stable for LVM)
/dev/datavg/swap2 none swap defaults 0 0
# Test all new entries without rebooting
$ sudo mount -a
$ sudo swapon -a
# Verify all mounts and swap are active
$ findmnt --verify
$ df -h
$ swapon --show
# IMPORTANT: Do NOT need to add entry for extended LV
# The existing fstab entry already references /dev/datavg/data
# LVM metadata stores the new size — it persists automatically
Quick Reference: Non-Destructive Expansion
| Task | Commands (in order) |
|---|---|
| Add partition to existing disk | parted print → parted mkpart → partprobe → mkfs → blkid → edit fstab → mount -a |
| Extend LV on existing VG (if VG has free space) | vgs → lvextend -L +SIZE -r /dev/VG/LV |
| Add disk to LVM and extend LV | parted mkpart → partprobe → pvcreate → vgextend → lvextend -r |
| Add new LV to existing VG | vgs → lvcreate -L -n → mkfs → blkid → edit fstab → mount -a |
| Add swap partition | parted mkpart primary linux-swap → partprobe → mkswap → swapon → blkid → edit fstab |
| Add LVM swap | lvcreate -L -n → mkswap → swapon → edit fstab |
After completing any expansion task on the exam, verify that existing mounts
still work (ls /existingmount, df -h) and that the
new storage is accessible and persistent (findmnt --verify).
Common Mistakes
| Mistake | What goes wrong | Correct approach |
|---|---|---|
| Starting a new partition before the end of the previous one | Overlapping partition — destroys the existing partition and its data | Read the End value from parted print and use it as the new partition's Start |
Running mkfs on the wrong device |
Existing filesystem on /dev/sdb1 is overwritten |
Confirm the device with lsblk before every mkfs |
| Extending an LV but not the filesystem | LV is larger but df shows the old size |
Always use lvextend -r to grow both LV and filesystem |
Adding a new swap fstab entry but not testing with swapon -a |
New swap appears in fstab but is not active until the next reboot | Run sudo swapon /dev/device immediately and add the fstab entry |
| Adding a fstab entry for the extended LV's mount point | Duplicate fstab entry causes a mount error at boot | The existing fstab entry already covers the extended LV — do not add a second |
Not running partprobe after partitioning |
pvcreate or mkfs fails: device not found |
Always run sudo partprobe /dev/DISK after any partitioning changes |
Knowledge Check
Answer these before moving to the next slide.
- A disk has one partition ending at 5369 MB on a 20 GB disk. Write the parted command to add a 3 GB partition starting immediately after the existing one.
- What does "non-destructive" mean in the context of adding a partition to a disk that already has data?
- An LV
/dev/datavg/datamounted at/dataneeds 8 GB more space. The VG has 10 GB free. Write the single command to extend the LV and grow the XFS filesystem simultaneously. - You have added a new swap partition at
/dev/sdb3and runmkswap. What two things must you do to make the swap (a) active now and (b) persistent across reboots? - After extending an LV, do you need to add a new fstab entry for the extended filesystem? Explain why or why not.
- List the three commands to verify, after all changes, that existing data is still intact and the new storage is working.
Knowledge Check — Answers
sudo parted --script /dev/sdb mkpart primary xfs 5369MB 8438MB
Start: 5369 MB (immediately after the existing partition's end). End: 5369 + 3072 ≈ 8438 MB (approximately 3 GB).- Non-destructive means the new partition is created only in free (unpartitioned) space on the disk. The existing partition's start sector, end sector, and all data within it remain completely unchanged. The operation is additive — it adds a new partition without modifying, resizing, or deleting any existing partition.
sudo lvextend -L +8G -r /dev/datavg/data
The-rflag automatically runsxfs_growfson the mounted XFS filesystem after extending the LV, growing both in one step.- (a) Active now:
sudo swapon /dev/sdb3
(b) Persistent: addUUID=... none swap defaults 0 0(using the UUID fromblkid /dev/sdb3) to/etc/fstab. - No, a new fstab entry is not needed. The existing fstab entry still references the
same LV (e.g.
/dev/datavg/dataor its UUID). LVM metadata stores the LV's new size persistently — on the next boot, the LV activates at its new size and the filesystem mounts at that larger size using the existing fstab entry. - Any three of:
ls /existingmount(existing data intact),df -h(all filesystems and sizes visible),df -h /newmount(new mount accessible),swapon --show(all swap active including new),findmnt --verify(fstab syntax valid),sudo lvs(LV sizes).
Key Takeaways
-
Always inspect the current layout before making any changes.
Use
lsblk,parted print,pvs,vgs, andswapon --showto record the baseline. New partitions start where old ones end. New LVs use only VG free space. - Non-destructive means additive — free space only, no modification of existing. New partitions use unpartitioned gaps. New LVs use unallocated VG extents. New swap is additional, not a replacement. Verify existing data after every change.
-
Use
lvextend -rto extend an LV and its filesystem in one step. The-rflag detects the filesystem type and runs the correct grow tool. The existing fstab entry survives — do not add a new one for an extended LV. -
New mounts and swap need fstab entries; extended LVs do not.
New partition mounts: UUID= in fstab. New swap: UUID= or device path with type swap.
Extended LV: existing fstab entry is sufficient — LVM metadata stores the new size.
Test everything with
mount -aandfindmnt --verify.
Graded Lab
- Run
lsblk,df -h, andswapon --showto record the baseline. Identify any disks with free (unpartitioned) space and any VGs with free extents. - On a disk with free space after its last partition, add a new 2 GiB partition.
Run
partprobe, format with XFS, add a UUID-based fstab entry, and mount. Verify the previous partition's data is untouched. - If a VG with free extents exists, create a new 1 GiB logical volume named
labextra. Format with XFS, add a UUID fstab entry, and mount at/labextra. Verify withdf -handsudo lvs. - Add 512 MiB of swap non-destructively: either a new swap partition on free disk
space or a new LVM swap volume. Activate it and confirm both old and new swap
are active with
swapon --show. Add the persistent fstab entry. - Run
findmnt --verifyto confirm all fstab entries are valid. Runsudo mount -aandsudo swapon -ato ensure all entries are activated. - Reboot the system. After rebooting, run
df -h,swapon --show, and check that all new mounts are present and the original data is still intact.
"Add new partitions and logical volumes, and swap to a system non-destructively." Inspect first. Use free space only. Verify existing data survived. Make persistent with fstab. Test without rebooting. Confirm after reboot.