Class 24 of 55 • File System & Storage Architecture

Linux Storage Management: Partitions, fdisk, mkfs, Mounting & LVM

Disk and storage management is one of the most critical core competencies for Linux system administrators, DevOps engineers, and computer science students. In Linux, all storage drives and partitions are represented as special block device files within the /dev directory (such as /dev/sda for SATA/SCSI drives or /dev/nvme0n1 for high-speed NVMe SSDs).

This comprehensive class guides you through the full storage lifecycle: discovering disks with lsblk and fdisk -l, creating partition tables (MBR vs GPT), formatting with modern filesystems (ext4 and XFS), persistent mounting via /etc/fstab, and mastering enterprise-grade Logical Volume Management (LVM).

Linux Storage and LVM Logical Volume Architecture Diagram

Figure 24.1: Architecture of Linux Logical Volume Management (PV → VG → LV → Mount Point).


1. Inspecting Storage Drives and Block Devices

Before partitioning any disk, you must accurately identify the attached drives, their size, existing partition layout, and mount points. The primary command for this is lsblk (list block devices):


# Display tree layout of all block devices
$ lsblk -f
NAME        FSTYPE FSVER LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                 
├─sda1      vfat   FAT32        5E21-B890                             490.5M     4% /boot/efi
├─sda2      ext4   1.0          8c1f939e-270b-4835-9cb1-805128038d10  850.2M    32% /boot
└─sda3      LVM2_m LVM2         7XfO31-xUdf-7rVb-K32w-q8pE-0M91-Nkm7B5              
  ├─vg0-root ext4  1.0          b930b8d5-19e4-4c57-a16f-c1f0e21a89cd   45.2G    48% /
  └─vg0-swap swap  1            7a59a7f3-1810-4bf2-8924-f725350c3772                [SWAP]
sdb                                                                                 # New unpartitioned 1TB disk
							

You can also inspect low-level disk geometry and existing partition tables using fdisk -l:


$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Disk model: Samsung SSD 870
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
							

2. Disk Partitioning: MBR vs GPT and fdisk

Disks require a partition table scheme before data partitions can be allocated. Modern systems utilize GPT (GUID Partition Table), while legacy systems utilize MBR (Master Boot Record):

Feature MBR (Master Boot Record) GPT (GUID Partition Table)
Maximum Disk Capacity 2.0 Terabytes (2 TB) 9.4 Zettabytes (9.4 × 1012 GB)
Partition Limit 4 Primary Partitions (or 3 Primary + 1 Extended) 128 Partitions by default (expandable)
Boot Firmware Legacy BIOS Modern UEFI (Unified Extensible Firmware)
Data Redundancy Single table at sector 0; corruption causes data loss Backup partition header stored at the end of disk with CRC32 verification

Step-by-Step: Creating a Partition with fdisk


$ sudo fdisk /dev/sdb

# Interactive menu commands:
# 'g' → Create a new empty GPT partition table
# 'n' → Add a new partition (default partition number 1)
# First sector → Press Enter (defaults to sector 2048 for optimal 4KB alignment)
# Last sector → Type +100G (creates a 100 GB partition)
# 'p' → Print partition table to review changes
# 'w' → Write changes to disk and exit

$ sudo partprobe /dev/sdb  # Instruct Linux kernel to reload partition table
							

3. Creating Filesystems with mkfs

A partition cannot store files until formatted with a filesystem structure. The mkfs (make filesystem) utility initializes the superblock, inode tables, and data blocks:


# Format partition as standard Linux ext4 filesystem
$ sudo mkfs.ext4 -L "DataDisk" /dev/sdb1

# OR format partition as high-performance enterprise XFS filesystem
$ sudo mkfs.xfs -L "AnalyticsData" /dev/sdb1
							

4. Mounting Filesystems & Persistent /etc/fstab Configuration

To access files on a storage partition, it must be attached to a directory in the Linux directory tree (the mount point):


# Step 1: Create a mount point directory
$ sudo mkdir -p /mnt/data

# Step 2: Manually mount the formatted partition
$ sudo mount /dev/sdb1 /mnt/data

# Step 3: Verify mount and check disk space
$ df -hT /mnt/data
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdb1      ext4   98G   60M   93G   1% /mnt/data
							

Configuring Persistent Auto-Mounting via /etc/fstab

Manual mounts disappear upon reboot. To make a mount permanent, add an entry to /etc/fstab. Always use the partition's unique UUID rather than volatile device names like /dev/sdb1:


# Find partition UUID
$ sudo blkid /dev/sdb1
/dev/sdb1: LABEL="DataDisk" UUID="9a174df1-807c-48be-9e8c-8f4791a5db4b" TYPE="ext4"

# Append mount configuration to /etc/fstab:
# Syntax: <UUID>  <Mount Point>  <FSType>  <Options>  <Dump>  <Pass/FSCK>
UUID=9a174df1-807c-48be-9e8c-8f4791a5db4b  /mnt/data  ext4  defaults,noatime  0  2

# TEST FSTAB WITHOUT REBOOTING (Vital step to avoid boot failure!):
$ sudo mount -a  # Returns 0 exit code if syntax is valid
							

5. Logical Volume Management (LVM) Masterclass

Traditional partitions have a severe disadvantage: their size is rigid. If /var fills up on a physical disk, resizing requires dangerous partition table edits or downtime. LVM (Logical Volume Management) provides a flexible abstraction layer between raw hardware and filesystems.

The 3 LVM Hierarchy Layers:

     1. Physical Volume (PV): The underlying raw hard drives or partitions (e.g., /dev/sdb1, /dev/sdc) initialized for LVM via pvcreate.

     2. Volume Group (VG): A storage pool combining multiple PVs together via vgcreate. Think of a VG as a giant virtual hard drive.

     3. Logical Volume (LV): Slices carved out of the Volume Group using lvcreate. These act exactly like disk partitions and can be formatted with ext4/xfs and mounted.

LVM Workflow: Create, Expand & Resize Online


# STEP 1: Initialize Physical Volume
$ sudo pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.

# STEP 2: Create a Volume Group named 'vg_storage'
$ sudo vgcreate vg_storage /dev/sdb1
  Volume group "vg_storage" successfully created.

# STEP 3: Create a 50GB Logical Volume named 'lv_projects'
$ sudo lvcreate -L 50G -n lv_projects vg_storage
  Logical volume "lv_projects" created.

# STEP 4: Format with filesystem and mount
$ sudo mkfs.ext4 /dev/vg_storage/lv_projects
$ sudo mkdir -p /projects
$ sudo mount /dev/vg_storage/lv_projects /projects

# STEP 5: RESIZE LOGICAL VOLUME LIVE (ONLINE RESIZING!)
# Add 20 GB to the logical volume and resize the filesystem simultaneously:
$ sudo lvextend -L +20G -r /dev/vg_storage/lv_projects
  Size of logical volume vg_storage/lv_projects changed from 50.00 GiB to 70.00 GiB.
  Resizing filesystem on /dev/mapper/vg_storage-lv_projects...
							

Beginner Student Lab Practice Session

Practice these essential disk management commands on your Linux terminal:


# Task 1: Check total free disk space in human-readable format
$ df -h

# Task 2: Calculate total directory storage consumption
$ du -sh /var/log/

# Task 3: Identify disk partition schemes (GPT vs DOS)
$ sudo parted -l

# Task 4: View active volume groups and free extents
$ sudo vgs

# Task 5: Display memory and swap space utilization
$ free -m
							

Frequently Asked Questions (FAQ)

MBR supports drives up to 2TB and a maximum of 4 primary partitions. GPT supports drives over 2TB (up to 9.4 Zettabytes), supports up to 128 partitions without needing extended partitions, and stores duplicate headers at the end of the disk for automatic corruption recovery.

If umount /mnt/data returns target is busy, run lsof +D /mnt/data or fuser -mv /mnt/data to view open files and process IDs. Close those processes before unmounting. For emergency detachment, use lazy unmount: sudo umount -l /mnt/data.

No. ext4 filesystems can be both expanded and shrunk (offline). XFS can be expanded live online via xfs_growfs, but by architectural design, XFS cannot be shrunk. To reduce an XFS partition, you must back up data, re-create a smaller LV, reformat, and restore.

Next Step in Your Linux Learning Path:

Now that you understand storage and filesystems, dive into the command interface in Class 25: Bourne Shell (sh) Architecture & Scripting Fundamentals.

Continue to Class 25: Bourne Shell (sh) → Previous: ← Class 23: FHS Hierarchy | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!