Disk and Filesystem
Storage is the foundation of every Linux system. Files, applications, logs, and processes all reside on disks. To master Linux, you must learn how to inspect, organize, and manage storage so that the kingdom’s knowledge remains safe, accessible, and persistent.
Understanding Storage
In Linux (including Ubuntu), storage is managed through block devices, partitions, file systems, and mount points.
Data is organized using file systems like ext4, and devices are mounted into a single unified directory tree starting at /. Tools like LVM, RAID, and NFS extend storage flexibility and scalability
- Block devices: Physical disks (
/dev/sda). - Partitions: Logical divisions of a disk (
/dev/sda1). - Filesystems: Structures like
ext4that organize data. - Mount points: Locations in the unified directory tree where devices are attached.
/. Example: a USB drive may be mounted at /media/usb.| # | Component | Example | Purpose |
|---|---|---|---|
| 1 | Disk | /dev/sda |
Physical hard drive |
| 2 | Partition | /dev/sda1 |
Root partition |
| 3 | File system | ext4 |
Organizes files |
| 4 | Mount point | / |
Root directory |
| 5 | Additional mount | /home |
User data storage |
Storage Management Tools
| # | Tool / Concept | Description |
|---|---|---|
| 1 | fdisk/gdisk | Partitioning tools. |
| 2 | mkfs | Create a filesystem on a partition. |
| 3 | mount/umount | Attach or detach devices. |
| 4 | /etc/fstab | Configuration file for persistent mounts at boot. |
| 5 | LVM | Logical Volume Manager for flexible resizing. |
| 6 | RAID | Combines disks for redundancy or performance. |
| 7 | NFS/SMB | Network-based storage sharing. |
Core Disk Commands
You must learn the commands to explore and manage the dungeon:
| # | Command | Description |
|---|---|---|
| 1 | lsblk | Lists block devices (disks and partitions). |
| 2 | blkid | Shows device identifiers (UUIDs). |
| 3 | df -h | Displays disk usage in human-readable form. |
| 4 | du -sh | Shows size of a directory. |
| 5 | mount / umount | Attaches or detaches a vault. |
| 6 | fdisk | Creates or modifies partitions. |
| 7 | mkfs | Creates a filesystem on a partition. |
Filesystem Types
You must know the common magical structures:
| # | Filesystem | Description |
|---|---|---|
| 1 | ext4 | Default, reliable filesystem for most Linux systems. |
| 2 | XFS | High-performance, scalable filesystem. |
| 3 | Btrfs | Advanced features like snapshots and self-healing. |
| 4 | FAT32/exFAT | Used for USB drives, cross-platform compatibility. |
Data Persistence
Mounting a vault manually works, but to ensure persistence across reboots, entries must be added to /etc/fstab.
UUID=1234-5678 /data ext4 defaults 0 2
# → Ensures the /data vault is mounted automatically at boot.
Why Storage Rocks
| # | Aspect | Description |
|---|---|---|
| 1 | Efficiency | Proper partitioning improves performance. |
| 2 | Security | Separate partitions (like /home, /var) protect against corruption. |
| 3 | Flexibility | LVM and RAID allow scaling storage without downtime. |
| 4 | Integration | Unified directory tree makes Linux storage intuitive compared to Windows drive letters. |
Practical Exercises
# Add persistence
sudo nano /etc/fstab
# Create a new filesystem
sudo mkfs.ext4 /dev/sdb1
# Mount a vault
sudo mount /dev/sdb1 /mnt
# Check disk usage
df -h
du -sh /home/apprentice
# Explore block devices
lsblkHackers Quest
Create a Vault of Knowledge:
- Partition a disk (or virtual disk)
- Format it with
ext4 - Mount it at
/vault - Store files inside
- Configure
/etc/fstabfor persistence - Document the process in your spellbook
Hackers Notebook
The Dungeon of Disk Management holds the kingdom’s treasures. To master Linux, you must not only cast commands but also guard the vaults where knowledge resides. Control the disks, and you control the persistence of the kingdom itself.
