Linux Storage and Filesystem Administration: Complete Guide from Beginner to Advanced
Linux Storage and Filesystem Administration: Complete Guide from Beginner to Advanced
Introduction
Linux storage management is one of the most important skills for Linux System Administrators, DevOps Engineers, Cybersecurity Professionals, and Infrastructure Engineers.
Understanding how Linux manages disks, partitions, filesystems, mount points, and storage devices helps administrators manage servers efficiently and troubleshoot storage-related problems.
In this guide, we will explore Linux storage management step by step, starting with the fundamentals and progressing towards practical system administration.
By the end of this tutorial, you will understand how to identify storage devices, inspect partitions, create filesystems, mount disks, configure automatic mounting, and perform basic filesystem administration.
Chapter 1: Understanding Linux Storage
Before working with Linux storage, it is important to understand how a computer stores and organizes data.
Consider a library:
| Library Concept | Linux Storage Concept |
|---|---|
| Library building | Physical disk |
| Bookshelf | Partition |
| Library organization system | Filesystem |
| Books | Files and directories |
| Shelf location | Mount point |
A physical disk cannot normally be used as a regular filesystem until a filesystem has been created and made accessible to the operating system.
The basic storage structure looks like this:
Physical Disk
|
v
Partition
|
v
Filesystem
|
v
Mount Point
|
v
Files and DirectoriesFor example:
/dev/sda
|
+--- /dev/sda1
|
+--- /dev/sda2Here:
/dev/sdarepresents the physical storage device./dev/sda1represents the first partition./dev/sda2represents the second partition.
Note: Linux also supports filesystems directly on entire disks, logical volumes, RAID devices, and other block devices without a conventional partition table.
Chapter 2: Understanding Linux Storage Devices
Linux identifies storage devices using device names.
Two commonly encountered device types are NVMe and SATA/SCSI devices.
2.1 What is NVMe?
Example:
/dev/nvme0n1NVMe stands for Non-Volatile Memory Express.
It is a storage protocol designed for high-speed SSDs, commonly connected through PCIe.
Example partition structure:
nvme0n1
├── nvme0n1p1
├── nvme0n1p2
└── nvme0n1p3Here:
nvme0n1is the NVMe storage device.nvme0n1p1is its first partition.nvme0n1p2is its second partition.nvme0n1p3is its third partition.
2.2 What is SDA?
Example:
/dev/sdaLinux commonly uses names such as:
/dev/sda
/dev/sdb
/dev/sdc
/dev/sddThese names typically represent SCSI/SATA-style block devices.
For example:
sda = First detected device
sdb = Second detected device
sdc = Third detected deviceThe actual naming and ordering can change depending on hardware and device discovery.
2.3 Identify Storage Devices
Use:
lsblkThis command displays available block devices and their partition hierarchy.
For more detailed information:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTSThis displays:
Device name
Storage capacity
Device type
Filesystem type
Mount points
Chapter 3: Understanding Disk Partitions
A partition is a logical division of a physical storage device.
For example:
Physical Disk: /dev/sda
|
+--- /dev/sda1
|
+--- /dev/sda2
|
+--- /dev/sda3Each partition can be used for a different purpose.
Common examples include:
Operating system
User data
Application data
Backup storage
Swap space
Commands to Identify Partitions
Display all available disks and partitions:
lsblkDisplay partition table information:
sudo fdisk -lDisplay detailed partition information:
sudo parted -lThese commands help administrators understand the disk layout before performing storage operations.
Chapter 4: What is a Filesystem?
A filesystem is a method used by an operating system to organize, store, retrieve, and manage data on a storage device.
Without a filesystem, a partition is not ready for ordinary file and directory operations.
Think of a filesystem as an organizational structure that manages:
Files
Directories
Permissions
Metadata
Storage allocation
File access
Major Linux Filesystems
4.1 EXT4
EXT4 (Fourth Extended Filesystem) is one of the most widely used Linux filesystems.
Features:
Journaling support
Large file support
Good general-purpose performance
Reliable filesystem management
Suitable for desktops and servers
Example:
sudo mkfs.ext4 /dev/sdb14.2 XFS
XFS is a high-performance journaling filesystem widely used in enterprise Linux environments.
Commonly found in:
Red Hat Enterprise Linux
Enterprise servers
Large storage systems
Database environments
Example:
sudo mkfs.xfs /dev/sdb14.3 NTFS
NTFS (New Technology File System) is the standard filesystem used by modern Windows installations.
Features:
File permissions
Journaling
Large file support
Windows compatibility
Linux can access NTFS partitions using supported drivers.
4.4 FAT32
FAT32 is an older filesystem commonly used in removable storage devices.
Its major limitation is that an individual file cannot exceed 4 GB minus 1 byte.
4.5 exFAT
exFAT is commonly used for USB drives, memory cards, and external storage devices.
Advantages:
Supports files larger than 4 GB
Compatible with modern Windows and macOS systems
Supported by modern Linux distributions
Chapter 5: Identifying the Filesystem Type
Before mounting or formatting a partition, always identify its existing filesystem.
Use:
sudo blkidTo inspect a specific partition:
sudo blkid /dev/sda1Example output:
/dev/sda1: UUID="acdc32ef-ff1e-425b-aa98-07992ce10d75" TYPE="ntfs"This tells us:
Device:
/dev/sda1UUID:
acdc32ef-ff1e-425b-aa98-07992ce10d75Filesystem: NTFS
If the filesystem type is NTFS, the partition was formatted using the Windows NTFS filesystem.
Another useful command:
lsblk -fThis displays filesystem information for all detected block devices.
Chapter 6: Understanding Mounting in Linux
Unlike Windows, Linux does not normally assign separate drive letters such as C:, D:, or E:.
Instead, Linux uses a unified directory hierarchy.
Storage devices are attached to directories called mount points.
Common mount point locations include:
/mnt
/media
/data
/homeFor example, an additional storage device can be mounted at:
/data6.1 Create a Mount Point
First, create a directory:
sudo mkdir -p /dataThis creates a directory named /data.
At this stage, no additional storage has been mounted.
6.2 Mount a Partition
Example:
sudo mount /dev/sda1 /dataThis attaches the filesystem on /dev/sda1 to /data.
You can now access its files through:
cd /data
ls -lah6.3 Verify the Mount
Use:
df -hOr:
findmnt /dataTo see the mounted filesystem hierarchy:
lsblk -fImportant: Mounting an existing partition does not format it or erase its data. It makes the existing filesystem accessible through the selected directory.
Chapter 7: Understanding the df Command
The df command stands for Disk Free.
It displays filesystem storage utilization.
Command:
df -hThe -h option displays sizes in a human-readable format, such as GB and MB.
Example:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 932G 120G 812G 13% /dataExplanation:
| Column | Meaning |
|---|---|
| Filesystem | Storage device or filesystem |
| Size | Total filesystem capacity |
| Used | Used storage |
| Avail | Available storage |
| Use% | Percentage of storage used |
| Mounted on | Mount point |
Additional useful commands:
df -hTDisplays filesystem types.
df -iDisplays inode utilization.
du -sh /dataDisplays the total disk usage of the /data directory.
Chapter 8: Understanding UUID
UUID stands for Universally Unique Identifier.
A UUID is an identifier associated with a filesystem.
Example:
acdc32ef-ff1e-425b-aa98-07992ce10d75Think of it as a unique identification number for a filesystem.
Why Use UUID Instead of Device Names?
Consider:
/dev/sda1After adding or removing storage devices, Linux device names may change.
For example:
Before: /dev/sda1
After: /dev/sdb1This can cause problems when automatic mounting depends on device names.
UUID-based mounting provides a more stable way to identify filesystems.
Display UUIDs:
sudo blkidOr:
lsblk -fNote: UUIDs are designed to be unique, but they can be duplicated by cloning filesystems or manually copying identifiers. Always verify them.
Chapter 9: Understanding /etc/fstab
The /etc/fstab file controls how filesystems are mounted during system startup.
Its full name is Filesystem Table.
File location:
/etc/fstabDisplay its contents:
cat /etc/fstabExample entry:
UUID=acdc32ef-ff1e-425b-aa98-07992ce10d75 /data ext4 defaults 0 2Let's understand each field.
| Field | Meaning |
|---|---|
| UUID | Filesystem identifier |
| /data | Mount point |
| ext4 | Filesystem type |
| defaults | Default mount options |
| 0 | Dump backup flag |
| 2 | Filesystem check order |
Configure Automatic Mounting
First, obtain the filesystem UUID:
sudo blkid /dev/sda1Back up the existing configuration:
sudo cp /etc/fstab /etc/fstab.backupEdit the configuration:
sudo nano /etc/fstabAdd the correct UUID-based entry:
UUID=YOUR-UUID /data ext4 defaults 0 2Replace YOUR-UUID with the actual filesystem UUID.
Save the file.
Test the Configuration
Before rebooting, execute:
sudo mount -aIf no errors are reported, inspect the mount:
findmnt /dataThis helps identify configuration mistakes before restarting the system.
For non-critical external disks, consider options such as nofail to prevent a missing device from unnecessarily interrupting boot.
Chapter 10: Formatting a Partition
Formatting means creating a new filesystem on a storage device or partition.
For example, to create an EXT4 filesystem:
sudo mkfs.ext4 /dev/sda1The mkfs command means Make Filesystem.
Common filesystem creation commands:
Create EXT4:
sudo mkfs.ext4 /dev/sdb1Create XFS:
sudo mkfs.xfs /dev/sdb1Create FAT32:
sudo mkfs.fat -F 32 /dev/sdb1Create exFAT:
sudo mkfs.exfat /dev/sdb1Important Formatting Warning
Formatting a partition destroys its existing filesystem structures and makes existing data inaccessible. Recovery may be difficult or impossible.
Always verify the target device before formatting.
Check:
lsblk -fConfirm:
Correct physical disk
Correct partition
Existing data is backed up
Partition is not mounted
No active process is using it
Never execute a formatting command on an unknown or production storage device.
Chapter 11: Why Formatting a Mounted Partition Fails
During practical storage administration, you may encounter an error when trying to format a mounted partition.
Example:
sudo mkfs.ext4 /dev/sda1Possible error:
/dev/sda1 is mounted; will not make a filesystem here!Why Does This Happen?
Linux prevents formatting a mounted filesystem because it may be actively used by the operating system or applications.
Formatting a mounted partition can cause:
Data corruption
Filesystem damage
Application failures
Data loss
Correct Procedure
First, identify the mount point:
findmnt /dev/sda1Unmount the partition:
sudo umount /dev/sda1Check whether it is still mounted:
lsblk -fOnly after confirming the correct device is unmounted and safe to erase should you proceed with formatting.
Chapter 12: Understanding Unmounting
Unmounting detaches a filesystem from its mount point.
Command:
sudo umount /dataThis disconnects the filesystem from /data.
Verify:
findmnt /dataIf the filesystem is no longer mounted, the command will not show a mounted filesystem at that location.
What if the Device is Busy?
Sometimes Linux reports:
target is busyThis means a process may still be accessing the mounted filesystem.
Identify processes using it:
sudo fuser -vm /dataOr:
sudo lsof +f -- /dataClose applications or move active terminal sessions outside the mount point before unmounting.
Avoid forceful or lazy unmounting on production systems unless you understand the consequences.
Chapter 13: Understanding EXT4 Internals
EXT4 is more than a simple method of storing files.
It uses internal structures to manage filesystem data and metadata.
Three important concepts are:
13.1 Inodes
An inode is a filesystem data structure that stores metadata about a file.
It contains information such as:
File permissions
Owner and group
File size
Timestamps
Data block references
An inode does not normally store the filename itself. Directory entries associate filenames with inode numbers.
Think of an inode as a file's identification record.
Useful command:
ls -iThis displays inode numbers for files.
Check inode utilization:
df -i13.2 Journaling
EXT4 supports journaling.
A journal helps maintain filesystem consistency after unexpected shutdowns or system crashes.
In a simplified example:
Filesystem Operation
|
v
Journal Transaction
|
v
Commit Changes
|
v
Filesystem Metadata UpdateJournaling helps recover filesystem consistency, but it does not guarantee that every recently written file or application transaction will be recovered.
13.3 Superblock
The superblock is a critical filesystem metadata structure.
It contains information such as:
Filesystem size
Block count
Inode count
Filesystem state
Filesystem configuration
If critical filesystem metadata becomes corrupted, filesystem access and recovery can become difficult.
Chapter 14: Checking and Repairing Filesystems
Linux provides tools to inspect and repair filesystems.
For EXT4:
sudo e2fsck -f /dev/sdb1Alternatively:
sudo fsck.ext4 /dev/sdb1Important precautions:
Unmount the filesystem before running a repair operation.
Never run filesystem repair tools on a mounted read-write filesystem.
Back up important data before attempting repairs.
Review the reported errors before approving repairs.
For XFS, use:
sudo xfs_repair /dev/sdb1XFS has its own repair utility and should not be repaired using EXT4-specific tools.
Chapter 15: Linux Storage Administration Command Reference
The following commands are useful for everyday Linux storage administration.
Disk and Partition Discovery
lsblk
lsblk -f
sudo fdisk -l
sudo parted -lFilesystem Identification
sudo blkid
sudo blkid /dev/sda1Storage Utilization
df -h
df -hT
df -i
du -sh /dataMounting and Unmounting
sudo mkdir -p /data
sudo mount /dev/sda1 /data
sudo umount /data
findmntFilesystem Creation
sudo mkfs.ext4 /dev/sdb1
sudo mkfs.xfs /dev/sdb1Filesystem Checking
sudo e2fsck -f /dev/sdb1
sudo xfs_repair /dev/sdb1UUID and Persistent Mounting
sudo blkid
cat /etc/fstab
sudo mount -aChapter 16: Practical Linux Storage Administration Workflow
Here is a simplified example of how a Linux administrator would prepare an additional storage partition.
Assume that /dev/sdb1 is a new partition intended for application data.
Step 1: Identify the storage device
lsblkStep 2: Inspect the filesystem
sudo blkid /dev/sdb1Step 3: Create a mount point
sudo mkdir -p /dataStep 4: Create an EXT4 filesystem
Only if the partition is new or its existing contents have been backed up and approved for erasure:
sudo mkfs.ext4 /dev/sdb1Step 5: Identify the new UUID
sudo blkid /dev/sdb1Step 6: Mount the partition
sudo mount /dev/sdb1 /dataStep 7: Verify the storage
df -hTStep 8: Configure persistent mounting
Back up and edit /etc/fstab, then add the correct UUID-based entry:
UUID=YOUR-UUID /data ext4 defaults 0 2Step 9: Test the configuration
sudo mount -aStep 10: Verify the final configuration
lsblk -f
df -hT
findmnt /dataThis workflow demonstrates the basic process of preparing and managing Linux storage.
Chapter 17: Advanced Linux Storage Topics to Learn Next
Once you understand disks, partitions, filesystems, and mounting, you can move towards advanced Linux storage technologies.
17.1 LVM (Logical Volume Manager)
LVM provides flexible storage management by allowing administrators to combine physical storage devices into logical storage pools.
Important concepts:
Physical Volume (PV)
Volume Group (VG)
Logical Volume (LV)
17.2 RAID
RAID combines multiple physical disks to provide different levels of redundancy and performance.
Common RAID levels:
RAID 0
RAID 1
RAID 5
RAID 6
RAID 10
17.3 NFS
Network File System allows Linux systems to share directories and access remote storage over a network.
17.4 SMB
Server Message Block is commonly used for network file sharing, especially between Windows and Linux systems.
17.5 iSCSI
iSCSI allows block-level storage access over IP networks.
17.6 Docker Volumes
Docker volumes provide persistent storage for containerized applications.
17.7 Kubernetes Persistent Volumes
Kubernetes uses Persistent Volumes (PV) and Persistent Volume Claims (PVC) to manage persistent application storage.
17.8 Cloud Storage
Cloud environments provide different storage technologies, including:
Azure Managed Disks
AWS EBS
Google Persistent Disk
Cloud object storage
Understanding Linux storage fundamentals makes it easier to work with these technologies.
Conclusion
Linux storage management is a fundamental skill for anyone working in Linux administration, DevOps, Cybersecurity, SOC operations, or cloud infrastructure.
In this practical learning exercise, we explored the complete storage management process, including:
Identifying physical disks and storage devices.
Understanding disk partitions.
Identifying existing filesystem types.
Creating mount points.
Mounting and unmounting partitions.
Understanding disk utilization using
df.Identifying filesystems using UUIDs.
Configuring persistent mounting through
/etc/fstab.Creating EXT4 filesystems.
Understanding inodes, journaling, and superblocks.
Checking and repairing filesystems.
Learning about advanced storage technologies.
These concepts form the foundation of real-world Linux system administration.
The next step is to gain practical experience with LVM, RAID, NFS, and enterprise storage management.
Keep learning, keep experimenting, and build your Linux administration skills one practical task at a time.
Get new cybersecurity, ethical hacking and Linux tutorials straight to your inbox. No spam.
