🎯 Learning Objectives
- Understand Linux storage architecture[cite: 21].
- Identify Linux storage devices[cite: 21].
- Learn MBR and GPT partition tables[cite: 21].
- Compare common Linux filesystems[cite: 21].
- Use storage inspection commands[cite: 21].
Why Storage Administration Matters
Storage is where Linux permanently stores operating systems, applications, databases, configuration files and user data[cite: 21]. Every Linux administrator should know how to inspect, manage and troubleshoot storage safely[cite: 21].
🏢 Production Insight
Enterprise servers often use SAN, NAS, cloud block storage or virtual disks[cite: 21]. Administrators are responsible for safely configuring, mounting and expanding these storage resources[cite: 21].
Linux Storage Architecture
Application
│
Filesystem
│
Logical Volume (Optional)
│
Partition
│
Physical Disk
| Layer | Description |
|---|---|
| Physical Disk | Storage hardware[cite: 21] |
| Partition | Logical disk division[cite: 21] |
| Filesystem | Organizes stored data[cite: 21] |
| Application | Reads and writes data[cite: 21] |
Linux Device Naming
/dev/sda
/dev/sdb
/dev/nvme0n1
/dev/mapper/vgdata-lvdata
| Device | Description |
|---|---|
| /dev/sda | First SATA/SCSI disk[cite: 21] |
| /dev/sdb | Second disk[cite: 21] |
| /dev/nvme0n1 | NVMe SSD[cite: 21] |
| /dev/mapper/* | LVM logical volume[cite: 21] |
Storage Inspection Commands
lsblk
blkid
fdisk -l
parted -l
cat /proc/partitions
Partition Tables
| Feature | MBR | GPT |
|---|---|---|
| Disk Size | ~2 TB[cite: 21] | >2 TB[cite: 21] |
| Primary Partitions | 4[cite: 21] | 128+[cite: 21] |
| Recommended | No[cite: 21] | Yes[cite: 21] |
Common Linux Filesystems
| Filesystem | Typical Usage |
|---|---|
| ext4 | General-purpose Linux[cite: 21] |
| XFS | Enterprise servers[cite: 21] |
| Btrfs | Snapshots & advanced features[cite: 21] |
| FAT32 | USB drives[cite: 21] |
| NTFS | Windows compatibility[cite: 21] |
Hands-on Practice
- Run
lsblk[cite: 21]. - Run
blkid[cite: 21]. - Display partition tables using
fdisk -l[cite: 21]. - Inspect storage using
parted -l[cite: 21]. - Review
/proc/partitions[cite: 21].
⚠ Common Mistakes
- Formatting the wrong disk[cite: 21].
- Confusing disks with partitions[cite: 21].
- Ignoring UUIDs[cite: 21].
- Assuming device names never change[cite: 21].
Part 1 Summary
You learned Linux storage architecture, device naming, partition tables, filesystems and essential storage inspection commands[cite: 21]. Part 2 covers partitions, filesystems, mounting and /etc/fstab[cite: 21].
Why Partition Disks?
Partitioning divides a physical disk into logical sections[cite: 21]. Each partition can contain its own filesystem and can be dedicated for operating systems, applications, databases or backups[cite: 21].
🏢 Enterprise Insight
Production Linux servers usually separate /, /boot, /var, /home, database and application storage[cite: 21].
Disk Layout
Physical Disk (/dev/sdb)
│
├── Partition 1 (ext4)
├── Partition 2 (XFS)
└── Partition 3 (LVM PV)
Partition Types
| Type | Description |
|---|---|
| Primary | Main partition[cite: 21] |
| Extended | Container for logical partitions (MBR)[cite: 21] |
| Logical | Partitions inside extended partition[cite: 21] |
| GPT | Modern partition format supporting very large disks[cite: 21] |
MBR vs GPT
| Feature | MBR | GPT |
|---|---|---|
| Maximum Disk Size | 2 TB[cite: 21] | 8 ZB[cite: 21] |
| Partitions | 4 Primary[cite: 21] | 128+[cite: 21] |
| Recommended | No[cite: 21] | Yes[cite: 21] |
Creating Partitions using fdisk
sudo fdisk /dev/sdb
| Command | Purpose |
|---|---|
| n | Create partition[cite: 21] |
| d | Delete partition[cite: 21] |
| p | Print partition table[cite: 21] |
| w | Write changes[cite: 21] |
| q | Quit without saving[cite: 21] |
⚠ Warning
Always verify the correct disk before writing partition changes[cite: 21].
Using parted
sudo parted /dev/sdb
print
mklabel gpt
mkpart primary ext4 1MiB 20GiB
quit
Creating Filesystems
ext4
mkfs.ext4 /dev/sdb1
XFS
mkfs.xfs /dev/sdb2
FAT32
mkfs.vfat /dev/sdb3
NTFS
mkfs.ntfs /dev/sdb4
Filesystem Comparison
| Filesystem | Usage | Journaling |
|---|---|---|
| ext4 | General Linux[cite: 21] | Yes[cite: 21] |
| XFS | Enterprise[cite: 21] | Yes[cite: 21] |
| Btrfs | Snapshots[cite: 21] | Yes[cite: 21] |
| FAT32 | USB[cite: 21] | No[cite: 21] |
| NTFS | Windows[cite: 21] | Yes[cite: 21] |
Understanding UUID
UUID uniquely identifies each filesystem and is preferred over device names[cite: 21].
blkid
🏢 Production Tip
Always use UUID entries in /etc/fstab[cite: 21].
What is Mounting?
Linux attaches every filesystem to a directory called a mount point[cite: 21].
🏢 Enterprise Insight
Large servers commonly use mount points like /u01, /backup, /data and /oracle[cite: 21].
Temporary Mount & Unmount
mount /dev/sdb1 /data
mount UUID=xxxxxxxx /data
umount /data
⚠ Important
A filesystem cannot be unmounted while it is in use[cite: 21].
/etc/fstab Configuration Table
The /etc/fstab file defines filesystems that should automatically mount during boot[cite: 21].
UUID=67bc1234-45ab /data ext4 defaults 0 2
| Field | Description |
|---|---|
| UUID | Filesystem identifier[cite: 21] |
| Mount Point | Directory[cite: 21] |
| Filesystem | ext4, xfs etc.[cite: 21] |
| Options | Mount options[cite: 21] |
| Dump | Backup flag[cite: 21] |
| Pass | Filesystem check order[cite: 21] |
Common Mount Options
| Option | Description |
|---|---|
| defaults | Default options[cite: 21] |
| rw | Read and write[cite: 21] |
| ro | Read only[cite: 21] |
| noexec | Disable execution[cite: 21] |
| nosuid | Disable SUID[cite: 21] |
| nodev | Ignore device files[cite: 21] |
| noatime | Improve performance[cite: 21] |
🏢 Production Tip
Always test /etc/fstab with mount -a before rebooting[cite: 21].
Disk Usage Commands
| df | du |
|---|---|
| Filesystem usage[cite: 21] | Directory usage[cite: 21] |
| Total capacity[cite: 21] | Folder/file size[cite: 21] |
Repair ext4 & XFS Filesystems
Run repair utilities only on unmounted filesystems[cite: 21].
umount /dev/sdb1
fsck -f /dev/sdb1 # For ext4[cite: 21]
xfs_repair /dev/sdb2 # For XFS[cite: 21]
⚠ Warning
Never execute fsck on a mounted ext4 filesystem[cite: 21].
Swap Administration
Swap provides virtual memory when RAM becomes insufficient[cite: 21].
swapon --show
free -h
swapon /swapfile
swapoff /swapfile
Deleted but Open Files
A deleted file may still consume disk space if a running process keeps it open[cite: 21].
lsof | grep deleted
🏢 Production Tip
Restart the owning process after confirming the deleted file is no longer required[cite: 21].
Storage Performance Monitoring
| Tool | Purpose |
|---|---|
| iostat | Disk I/O statistics[cite: 21] |
| iotop | Process disk usage[cite: 21] |
| sar | Historical performance[cite: 21] |
Knowledge Check (MCQs)
- Which command repairs ext4? Answer: fsck[cite: 21]
- Which tool repairs XFS? Answer: xfs_repair[cite: 21]
- Which file stores persistent mounts? Answer: /etc/fstab[cite: 21]
- Which command shows filesystem usage? Answer: df -h[cite: 21]
- Which command shows directory size? Answer: du[cite: 21]
- Which command lists deleted open files? Answer: lsof[cite: 21]
- Which command enables swap? Answer: swapon[cite: 21]
- Which tool monitors disk I/O? Answer: iostat[cite: 21]
- Why use UUID? Answer: Stable device identification.[cite: 21]
- Should fsck run on mounted ext4? Answer: No.[cite: 21]
Commands Covered in This Chapter
lsblk- Display block device parameters[cite: 21]blkid- Show UUID and filesystem type[cite: 21]fdisk/gdisk/parted- Partition management tools[cite: 21]mkfs- Build a system filesystem[cite: 21]fsck/xfs_repair- Diagnose and fix filesystem corruption[cite: 21]mount/umount- Control temporary directories mounts[cite: 21]df/du/findmnt- Disk metrics monitoring systems[cite: 21]swapon/swapoff- Virtual memory operations[cite: 21]lsof- Locate open file allocations[cite: 21]iostat/iotop/sar- Disk performance auditing suites[cite: 21]