Linux Tutorial — Part 11: Disk Management & Storage

By Suraj Ahir December 25, 2025 6 min read

Linux — Cron & Automation
Linux — Cron & Automation
← Part 10 Linux Tutorial · Part 11 of 12 Part 12 →

Understanding disk management in Linux is critical for operations work. Running out of disk space crashes applications. Incorrectly mounted storage loses data. Poor disk organization creates performance problems. This part covers everything from checking disk usage to mounting volumes — skills used constantly in server administration.

Checking Disk Usage

Disk Space Commands
df -h                          # Disk space by filesystem (human readable)
df -h /                        # Root filesystem specifically
df -i                          # Inode usage (sometimes the real bottleneck)
du -sh /var/log/               # Size of a directory
du -sh /var/* | sort -h        # All /var subdirs sorted by size
du -ah /home/suraj | sort -rh | head -20  # 20 largest items in home

Finding What's Using Disk Space

Disk Space Investigation
# Find large files
find / -type f -size +500M 2>/dev/null

# Find large directories
du -h --max-depth=1 / 2>/dev/null | sort -rh | head -10

# Find old log files
find /var/log -name "*.log" -mtime +30

# Check for deleted files still held open (common in production!)
lsof | grep deleted | head -20

Block Devices and Partitions

Storage Inspection
lsblk                          # List block devices in tree form
lsblk -f                       # Include filesystem types
fdisk -l                       # Partition details (requires root)
blkid                          # Block device UUIDs and types
cat /proc/partitions            # Kernel's view of partitions

Mounting Filesystems

Mount Commands
mount                                      # Show all mounted filesystems
mount /dev/sdb1 /mnt/data                 # Mount device to directory
mount -t ext4 /dev/sdb1 /mnt/data         # Specify filesystem type
umount /mnt/data                          # Unmount
umount -l /mnt/data                       # Lazy unmount (when busy)

# Permanent mounts in /etc/fstab
# UUID=abc123  /mnt/data  ext4  defaults  0  2

Creating Filesystems

Format Partitions
mkfs.ext4 /dev/sdb1            # Format as ext4
mkfs.xfs /dev/sdc1             # Format as XFS (better for large files)
mkfs.vfat /dev/sdd1            # Format as FAT32 (for USB drives)

Log Management and Rotation

Managing Logs
journalctl --disk-usage                    # How much space logs use
sudo journalctl --vacuum-size=1G           # Reduce journal to 1GB
sudo journalctl --vacuum-time=2weeks       # Delete logs older than 2 weeks

# logrotate configuration
cat /etc/logrotate.conf
ls /etc/logrotate.d/                       # App-specific configs
sudo logrotate -f /etc/logrotate.conf     # Force rotation now

Disk Performance

Performance Testing
iostat -x 1                    # Disk I/O statistics every second
iotop                          # Interactive disk I/O by process
dd if=/dev/zero of=/tmp/test bs=1M count=1000  # Write speed test
hdparm -Tt /dev/sda            # Read speed (cached and buffered)

In Part 12, the final part, we bring everything together and build a complete system administration checklist — a practical reference for managing Linux servers in production.

LVM — Logical Volume Manager

LVM provides an abstraction layer between physical disks and filesystems, enabling features impossible with traditional partitioning: resizing volumes while in use, combining multiple disks into one logical volume, and taking snapshots. Physical Volumes (PVs) are the underlying disks — pvcreate /dev/sdb. Volume Groups (VGs) pool physical volumes — vgcreate data_vg /dev/sdb. Logical Volumes (LVs) are created from VGs and used as actual block devices — lvcreate -L 20G -n data_lv data_vg. To extend a running volume: lvextend -L +10G /dev/data_vg/data_lv then resize2fs /dev/data_vg/data_lv to expand the filesystem. In cloud environments where disk size needs change over time, LVM understanding directly applies to managing EBS volumes on AWS or persistent disks on GCP.

Filesystem Types and When to Use Each

Linux supports multiple filesystem types, each with different characteristics. ext4 is the standard default for most Linux installations — reliable, well-tested, and supported everywhere. XFS is preferred for large files and high-performance workloads — it is the default on RHEL/CentOS 7+. Btrfs offers advanced features including snapshots, checksumming, and built-in RAID, though it is less mature than ext4 for production use. tmpfs is a memory-based filesystem used for /tmp and /run — fast but does not survive reboots. Understanding filesystem selection matters when setting up servers, NAS systems, or containers where performance and feature requirements differ.

Practice Exercise

Explore your system's storage: use lsblk to see the block device tree, df -hT to see all filesystems with their types and usage, sudo fdisk -l for detailed partition information, and sudo blkid to see filesystem UUIDs. Generate a 100MB test file with dd if=/dev/zero of=/tmp/testfile bs=1M count=100, check usage change with df -h, then remove it and verify space recovered. Also examine /etc/fstab to understand how filesystems are configured for automatic mounting at boot.

Linux in Your Daily Engineering Practice

Linux command-line proficiency is not something you learn once and then stop improving. It is a skill that deepens continuously as you encounter new tools, new use cases, and new problems to solve. The engineers who are most effective at the command line did not become that way by reading comprehensive guides — they became that way by spending years solving real problems at the terminal, gradually accumulating a toolkit of commands, aliases, scripts, and muscle memory. The best approach is to use Linux for real work as much as possible, to look up better ways to do things you already do, and to make note of efficient patterns you observe in others' work. Over time, the terminal becomes faster than any GUI for the tasks you do repeatedly.

Putting It All Together

Every topic in technology and finance rewards the learner who goes beyond surface understanding to build genuine fluency. Fluency comes from repeated exposure, application in varied contexts, and reflection on what worked and what did not. The concepts discussed here are starting points — each one opens into a deeper field of study that could occupy years of focused learning. The most effective approach is not to try to master everything at once, but to pick the areas most relevant to your current goals, go deep there, and then expand. Depth in a few areas is more valuable than shallow familiarity with many. Build on what you know, stay curious about what you do not, and keep the practice of learning as a consistent daily habit rather than an occasional burst of effort.

The questions that make learning stick: How does this connect to what I already know? Where would I actually use this? What would happen if I tried to explain this to someone who knows nothing about it? What are the edge cases and exceptions? What is still unclear? Asking these questions transforms passive reading into active learning, and active learning is what builds the kind of understanding that is still accessible years later when you need it under real conditions.

Disclaimer: Educational content only. Practice is required for real skill development.