:Linux Storage Subsystem and File System Management

Storage Interface Technologies

Modern Linux environments interface with persistent storage through various hardware protocols. Parallel interfaces, now largely obsolete, include IDE (also known as ATA) with maximum throughput of 133MB/s, and SCSI variants reaching 320MB/s or 640MB/s. Contemporary systems predominantly employ serial connections: SATA and SAS interfaces operate at 6Gbps, while USB 2.0 provides 480MB/s transfer rates.

Parallel architectures allow multiple devices per cable channel—IDE supports two devices (master/slave), while SCSI narrow configurations accommodate seven devices and wide configurations support fifteen. Serial architectures simplify connectivity by dedicating a single device per cable.

Disk Performance Metrics

IOPS (Input/Output Operations Per Second) measures storage responsiveness. Mechanical drives performance varies by rotational speed: 5400 RPM, 7200 RPM, 10,000 RPM, or 15,000 RPM. Solid-state drives eliminate mechanical latency entirely.

Mechanical Storage Organization

Hard disk drives structure data magnetically across rotating platters. Each platter contains concentric tracks divided into sectors (typically 512-byte units). Cylinders represent aligned tracks across stacked platters, forming the geometric basis for traditional partitioning strategies.

Linux Device Abstraction

The Linux kernel exposes hardware through the file system hierarchy, treating devices as special files under /dev.

Device Categories

  • Block Devices: Enable random access with data transferred in fixed-size blocks
  • Character Devices: Provide linear, sequential access with byte-stream data transfer

Device Identification

Each device carries two numeric identifiers:

  • Major Number: Specifies the driver module required for device operation
  • Minor Number: Distinguishes individual devices sharing the same driver

The mknod utility creates device files manually:

mknod /dev/custom_device b 8 16  # Block device with major 8, minor 16
mknod -m 660 /dev/custom_char c 4 64  # Character device with specific permissions

Storage Device Naming Conventions

  • Legacy IDE: /dev/hd[a-z]
  • Modern SATA/SCSI/SAS/USB: /dev/sd[a-z]
  • Partitions append numeric suffixes: /dev/sdb1, /dev/sdc3

Note: CentOS 6 and newer uniformly identify all disk devices using the /dev/sd* pattern.

Device Reference Methods

Systems locate storage through three mechanisms:

  1. Device file path
  2. Volume label
  3. Universally Unique Identifier (UUID)

Partitioning Schemes

Master Boot Record (MBR)

MBR resides in sector zero and comprises three sections:

  • 446 bytes: Bootloader code for system initialization
  • 64 bytes: Partition table (four 16-byte entries limiting primary partitions to four)
  • 2 bytes: Validation signature (0x55AA indicates active partition table)

Partition types:

  • Primary Partitions: 1-4
  • Extended Partition: One primary partition can designate as extended, containing logical partitions
  • Logical Partitions: Numbered 5 and above within the extended container

GUID Partition Table (GPT)

Modern systems increasingly adopt GPT, overcoming MBR's limitations with support for 128+ partitions and 2TB+ volumes.

Partition Management with fdisk

Inspecting Disk Layout

fdisk -l /dev/vda           # List all partitions on virtual disk A
fdisk -l /dev/nvme0n1       # Display NVMe device partitions

Interatcive Partition Editing

fdisk /dev/vdb

Within the fdisk prompt, common operations include:

  • n: Create new partition
  • d: Delete existing partition
  • t: Alter partition type code
  • l: List known partition types
  • p: Print current partition table
  • w: Write changes and exit
  • q: Discard changes and quit
  • m: Display help menu

Critical: Changes remain in memory until explicitly saved with w. New partitions on active disks may require kernel notification.

Kernel Partition Table Rescanning

CentOS 5:

partprobe /dev/vdb

CentOS 6/7:

partx -a /dev/vdb    # Add new partitions
kpartx -af /dev/vdb  # Force partition table re-read

Alternative tools: parted, sfdisk

File System Fundamentals

Formatting Layers

Low-Level Formatting: Performed during manufacturing—creates physical sectors and tracks High-Level Formatting: Post-partitioning operation establishing the file system structure

File System Architecture

File systems divide storage into:

  • Metadata Region: Stores inode structures containing file attributes (size, permissions, ownership, timestamps, data block pointers)
  • Data Region: Holds actual file contents

Special File Types:

  • Symbolic links store target paths within data blocks
  • Device files record major/minor numbers in place of data pointers

Virtual File System Layer

VFS provides abstraction enabling Linux to support multiple file systems simultaneously:

Native Linux: ext2 (journal-less), ext3, ext4, xfs, reiserfs, btrfs
Optical Media: iso9660
Networked: nfs, cifs
Clustered: gfs2, ocfs2
Distributed: ceph (kernel-level), glusterfs, moosefs (user-space)
Cross-Platform: vfat, ntfs
Pseudo File Systems: proc, sysfs, tmpfs, hugepagefs
Unix Variants: UFS, FFS, JFS
Swap: Dedicated swap space

File System Management Toolkit

Creation Utilities

mkfs.ext4 /dev/vdb1
mkfs.xfs /dev/vdc2
mkfs.vfat /dev/sdd1

The mkfs front-end simplifies selection:

mkfs -t ext4 /dev/vdb1  # Equivalent to mkfs.ext4

ext-Specific Tool: mke2fs

mke2fs -t ext4 -b 4096 -L DATAVOL -m 1 /dev/vdb1

Key options:

  • -t: Specify file system type (ext2/3/4)
  • -b: Set block size (1024, 2048, or 4096 bytes)
  • -L: Assign volume label
  • -m: Reserve percentage for superuser
  • -i: Bytes-per-inode ratio
  • -N: Explicit inode count
  • -O: Enable/disable features

Volume Label Management

e2label /dev/vdb1              # Display current label
e2label /dev/vdb1 DATABASE     # Set new label

File System Tuning

tune2fs -l /dev/vdb1           # View superblock information
tune2fs -m 2 /dev/vdb1         # Adjust reserved blocks to 2%
tune2fs -O ^has_journal /dev/vdb1  # Disable journaling

Immutable Attribute: Block size cannot change after creation.

File System Inspection

dumpe2fs -h /dev/vdb1          # Display ext file system details

File System Repair

e2fsck -f -y /dev/vdb1         # Force check, auto-repair
fsck.ext4 -a /dev/vdb1         # Non-interactive repair

Best Practice: Run repairs on unmounted file systems to prevent corruption.

XFS Support on Legacy Systems

CentOS 6 requires explicit installation:

yum -y install xfsprogs
mkfs.xfs /dev/vde1
fsck.xfs /dev/vde1

Block Device Identification

blkid /dev/vdb1                # Show device attributes
blkid -L DATAVOL              # Find device by label
blkid -U 123e4567-e89b-12d3-a456-426614174000  # Find by UUID

Swap Space Management

Swap partitions require System ID 82 and dedicated formatting:

mkswap -L SWAPVOL /dev/vdf2
swapon /dev/vdf2               # Activate swap
swapoff /dev/vdf2              # Deactivate swap

Enable all configured swap devices:

swapon -a

Cross-Platform Compatibility

For devices shared with Windows, use VFAT:

mkfs.vfat /dev/vdg1

Mounting File Systems

Manual Mounting

mount -t ext4 -o noexec,ro /dev/vdb1 /mnt/secure

Common mount options:

  • ro/rw: Read-only or read-write access
  • sync/async: Synchronous or asynchronous I/O
  • noatime: Disable access time updates
  • nodiratime: Disable directory access time updates
  • noexec: Prevent binary execution
  • nosuid: Ignore setuid/setgid bits
  • remount: Reapply options on active mount
  • acl: Enable POSIX Access Control Lists
  • defaults: Implies rw, suid, dev, exec, auto, nouser, async

Bind Mounts

Mount directories to alternate locations:

mount --bind /var/log /mnt/logs

Loopback Mounts

Access disk images without physical media:

mount -o loop /images/install.iso /mnt/iso

Viewing Active Mounts

mount                           # Show all mounted file systems
cat /etc/mtab                   # View kernel mount table
cat /proc/mounts                # Alternative mount information source

Unmounting

umount /dev/vdb1                # Unmount by device
umount /mnt/data                # Unmount by mount point

Troubleshooting: If "device busy" occurs, identify processes:

lsof /mnt/data                  # List open files
fuser -v /mnt/data              # Show accessing processes
fuser -km /mnt/data             # Kill processes and unmount

Persistent Mount Configuration

/etc/fstab controls boot-time mounting with six colon-separated fields:

# Device         Mount Point    FS Type    Options           Dump  Fsck
UUID=abcd1234    /mnt/data      ext4       defaults,noexec   0     2
/dev/vdb2        swap           swap       defaults          0     0

Field definitions:

  1. Device: File path, LABEL, UUID, or pseudo-file system name
  2. Mount Point: Target directory (or "swap" for swap space)
  3. File System Type: ext4, xfs, swap, etc.
  4. Options: Comma-separated mount parameters
  5. Dump Frequency: 0 (never), 1 (daily), 2 (periodic)
  6. Fsck Order: 0 (skip), 1 (root first), 2 (subsequent)

Apply fstab changes without reboot:

mount -a

Storage Usage Analysis

Disk Free Space

df -h                           # Human-readable sizes
df -i                           # Inode utilization
df -T                           # Include file system types

Disk Usage

du -sh /var/log                 # Summary of directory size
du -h --max-depth=1 /home       # Per-user consumption

Practical Exercises

Exercise 1: Create and Configure ext4 File System

Step 1: Partition a 20GB disk

fdisk /dev/vdb
# Command sequence: n → p → 1 → Enter → +20G → w

Step 2: Format with custom parameters

mkfs.ext4 -b 2048 -m 2 -L DATAVOL /dev/vdb1

Step 3: Mount with restrictions

mkdir -p /srv/application
mount -o noexec,noatime /dev/vdb1 /srv/application

Step 4: Configure persistent monuting

# Add to /etc/fstab:
UUID=$(blkid -s UUID -o value /dev/vdb1)
echo "UUID=$UUID /srv/application ext4 defaults,noexec,noatime 0 2" >> /etc/fstab

Exercise 2: Establish Swap Space

Step 1: Create swap partition

fdisk /dev/vdc
# Command sequence: n → p → 2 → Enter → +2G → t → 2 → 82 → w

Step 2: Initialize and activate

mkswap -L SWAP2G /dev/vdc2
swapon /dev/vdc2

Step 3: Verify activation

swapon -s
free -h

Step 4: Make permanent

echo "/dev/vdc2 swap swap defaults 0 0" >> /etc/fstab

Exercise 3: Deploy XFS File System

# Install prerequisites (CentOS 6)
yum -y install xfsprogs

# Create partition
fdisk /dev/vdd <<EOF
n
p
1

+10G
w
EOF

# Format and mount
mkfs.xfs /dev/vdd1
mkdir /mnt/xfs_volume
mount /dev/vdd1 /mnt/xfs_volume

# Persistent configuration
xfs_uuid=$(blkid -s UUID -o value /dev/vdd1)
echo "UUID=$xfs_uuid /mnt/xfs_volume xfs defaults 0 2" >> /etc/fstab

Exercise 4: Create Symbolic Link Structure

# Create source directory structure
mkdir -p /opt/app/{config,logs,data}

# Establish symbolic links
ln -s /opt/app/config /etc/myapp
ln -s /opt/app/logs /var/log/myapp

# Verify link independence
ls -li /opt/app/config /etc/myapp  # Different inodes

Exercise 5: Monitor Disk Usage Trends

#!/bin/bash
# Daily storage report
REPORT_DIR="/var/reports/storage"
mkdir -p "$REPORT_DIR"

date_stamp=$(date +%Y%m%d)
df -h > "$REPORT_DIR/disk_usage_$date_stamp.txt"
du -sh /home/* >> "$REPORT_DIR/disk_usage_$date_stamp.txt"

# Identify top disk consumers
find /home -type f -exec du -h {} + 2>/dev/null | sort -rh | head -20 > "$REPORT_DIR/top_files_$date_stamp.txt"

Tags: Linux Storage filesystem partitioning mounting

Posted on Tue, 23 Jun 2026 17:17:52 +0000 by joopeon