Add new partitions, logical volumes, and swap non-destructively

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:

  1. Adding partitions
  2. Adding logical volumes (LVs)
  3. 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 fdisk or parted.
      Example with fdisk: sudo fdisk /dev/sdb Then:
      • n β†’ create new partition
      • p β†’ primary (or e for extended)
      • Assign size (e.g., +10G)
      • w β†’ write changes
  • Format the new partition: sudo mkfs.ext4 /dev/sdb1
  • Mount the partition: sudo mkdir /data
    sudo mount /dev/sdb1 /data Add it to /etc/fstab to 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:

  1. Check existing volume groups: vgdisplay
  2. Check free space in VG: vgs
  3. Create a new logical volume: lvcreate -L 10G -n lv_data vg1
    • -L 10G β†’ size
    • -n lv_data β†’ LV name
    • vg1 β†’ target VG
  4. Format the LV: mkfs.ext4 /dev/vg1/lv_data
  5. Mount the LV: mkdir /mnt/data
    mount /dev/vg1/lv_data /mnt/data
  6. Add to /etc/fstab for 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

  1. Create a swap file: sudo fallocate -l 2G /swapfile Or: sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
  2. Set permissions: sudo chmod 600 /swapfile
  3. Make it swap: sudo mkswap /swapfile
  4. Enable swap: sudo swapon /swapfile
  5. Add to /etc/fstab to 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

  1. Always check disk and LV free space before adding new storage.
  2. Backup important data – even though it’s non-destructive, mistakes can happen.
  3. Update /etc/fstab for persistent mounts.
  4. Use descriptive names for partitions, LVs, and mount points to avoid confusion.
  5. Verify with df -h or lsblk after changes.

Exam Summary Checklist

TaskCommand / Notes
List disks & partitionslsblk, fdisk -l
Create new partitionfdisk /dev/sdx β†’ n β†’ size β†’ w
Format partitionmkfs.ext4 /dev/sdx1
Mount partitionmount /dev/sdx1 /mountpoint
Create LVlvcreate -L 10G -n lvname vgname
Format LVmkfs.ext4 /dev/vgname/lvname
Mount LVmount /dev/vgname/lvname /mountpoint
Create swap filefallocate -l 2G /swapfile
Enable swapswapon /swapfile
Persistent mount/swapEdit /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.

Buy Me a Coffee