5. Configure Local Storage
πRed Hat Certified System Administrator (RHCSA β EX200)
In IT systems, sometimes you need to increase storage or add space without losing your existing data. This is called non-destructive storage management. It is critical for servers, virtual machines, or network devices that must remain online while storage changes.
This topic has three main areas:
- Adding partitions
- Adding logical volumes (LVs)
- Adding swap space
1. Adding New Partitions Non-Destructively
A partition is a section of a hard disk (or SSD) that the OS treats as separate storage. Non-destructive partitioning means creating or resizing partitions without deleting existing data.
Key points for the exam:
- Identify free space:
Before adding a partition, check available disk space using: lsblk
fdisk -l This shows disks, partitions, and free/unallocated space. - Create a new partition:
- Use
fdiskorparted.
Example withfdisk: sudo fdisk /dev/sdb Then:nβ create new partitionpβ primary (orefor extended)- Assign size (e.g.,
+10G) wβ write changes
- Use
- Format the new partition: sudo mkfs.ext4 /dev/sdb1
- Mount the partition: sudo mkdir /data
sudo mount /dev/sdb1 /data Add it to/etc/fstabto mount at boot: /dev/sdb1 /data ext4 defaults 0 0
Exam tip: You do not destroy existing partitions or files on other parts of the disk. Only new partitions are created in free space.
2. Adding Logical Volumes (LVs) Non-Destructively
A Logical Volume (LV) is part of a Volume Group (VG), which itself is made from Physical Volumes (PVs). LVM (Logical Volume Manager) allows you to:
- Resize storage dynamically
- Combine multiple disks
- Add new storage without touching existing data
Steps to add new LV:
- Check existing volume groups: vgdisplay
- Check free space in VG: vgs
- Create a new logical volume: lvcreate -L 10G -n lv_data vg1
-L 10Gβ size-n lv_dataβ LV namevg1β target VG
- Format the LV: mkfs.ext4 /dev/vg1/lv_data
- Mount the LV: mkdir /mnt/data
mount /dev/vg1/lv_data /mnt/data - Add to
/etc/fstabfor persistence: /dev/vg1/lv_data /mnt/data ext4 defaults 0 0
Non-destructive benefit:
Existing LVs and files stay intact. You just allocate new space from the available free PVs.
3. Adding Swap Non-Destructively
Swap space is virtual memory used when RAM is full. You can add swap without affecting existing data by:
Option A: Using a Swap File
- Create a swap file: sudo fallocate -l 2G /swapfile Or: sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
- Set permissions: sudo chmod 600 /swapfile
- Make it swap: sudo mkswap /swapfile
- Enable swap: sudo swapon /swapfile
- Add to
/etc/fstabto make permanent: /swapfile swap swap defaults 0 0
Option B: Using a Swap Partition
- Create a new partition (as in step 1)
- Format as swap: mkswap /dev/sdb2
- Activate it: swapon /dev/sdb2
- Add to
/etc/fstab: /dev/sdb2 swap swap defaults 0 0
Key exam point: Swap can be added without touching existing partitions or files, making it safe for running systems.
Best Practices for Non-Destructive Storage Changes
- Always check disk and LV free space before adding new storage.
- Backup important data β even though itβs non-destructive, mistakes can happen.
- Update
/etc/fstabfor persistent mounts. - Use descriptive names for partitions, LVs, and mount points to avoid confusion.
- Verify with
df -horlsblkafter changes.
Exam Summary Checklist
| Task | Command / Notes |
|---|---|
| List disks & partitions | lsblk, fdisk -l |
| Create new partition | fdisk /dev/sdx β n β size β w |
| Format partition | mkfs.ext4 /dev/sdx1 |
| Mount partition | mount /dev/sdx1 /mountpoint |
| Create LV | lvcreate -L 10G -n lvname vgname |
| Format LV | mkfs.ext4 /dev/vgname/lvname |
| Mount LV | mount /dev/vgname/lvname /mountpoint |
| Create swap file | fallocate -l 2G /swapfile |
| Enable swap | swapon /swapfile |
| Persistent mount/swap | Edit /etc/fstab |
β Tip for non-IT students: Think of partition, LV, or swap as separate βstorage containersβ on your server. Non-destructive means you can add a new container without spilling or deleting anything in the old containers.
