Storage Media

5 min read

Core idea

Unix-like systems unify everything under one filesystem tree. A USB drive, a network share, an ISO image, and your boot disk all appear as directories under /. Underneath that single tree is a stack of layers — physical media, a block device exposed by the kernel as /dev/sdX, one or more partitions, a filesystem written onto each partition, and finally a mount point that grafts the filesystem onto the tree. Each layer has a small set of tools (lsblk, parted, mkfs, mount, fsck), and almost every storage problem is solvable once you know which layer to act on.

Shotts's argument: Windows gives each disk its own letter and hides the wiring. Unix puts every disk into one tree at the cost of teaching you the stack underneath. The Unix model is more uniform, more powerful, and — once internalized — simpler.

Why it matters

One tree, no drive letters

Programs ask for paths, not devices. A script that processes /data/projects does not care whether /data lives on a local SSD, a NAS, an LVM volume, or a USB stick. Mounting decouples what the data is from where it physically lives. This is the cornerstone of Unix portability.

The kernel is a uniform device interface

Whether the hardware is SATA, NVMe, USB, or virtual, the kernel presents it as /dev/sdX (or /dev/nvmeXnY for NVMe). Once a device is a block device, all the tools that read or write blocks — dd, parted, mkfs, fsck, lsblk — work identically on it. You learn the tools once and they transfer to every storage type.

Buffering means unmount before unplug

Linux aggressively buffers writes in RAM and flushes them later for speed. That is wonderful for performance but lethal if you yank a USB stick before the buffers drain. Unmounting forces the flush, then declares the device safe to remove. Skip the unmount and you risk filesystem corruption — the single most common cause of "the drive worked yesterday" disasters.

Recovery is possible if you know fsck

Filesystems include enough redundant structure (superblocks, journal entries, inode tables) that a good filesystem checker can often repair corruption from a power loss or partial write. fsck is the recovery tool of last resort — and the order field in /etc/fstab decides which filesystems get checked first on boot.

Key takeaways

Mental model

The storage stack, layer by layer

Storage on Linux is a Russian doll. The hardware presents bytes. The kernel wraps them as a block device. A partition table cuts the device into regions. A filesystem writes structure into a region. A mount call grafts the filesystem onto the tree at a chosen point. Each layer is independent — you can change the filesystem without re-partitioning, or move a mount point without reformatting.

The storage stack, layer by layer

Buffering and the unmount contract

Reading and writing physical storage is glacially slow compared to RAM. Linux exploits idle memory as a write buffer — free -h will show buffers and cache absorbing whatever isn't used for processes. A write you "completed" with cp may not yet be on the platter. Unmounting performs the flush; only after umount returns is the device safe to physically disconnect. (sync will force the flush without unmounting, useful before pulling power on a server.)

Filesystem table — the boot-time map

/etc/fstab has six columns: the device (or UUID or label), the mount point, the filesystem type, mount options, a dump frequency, and a fsck pass order. The pass order is the only field with non-obvious behavior — 1 for the root filesystem, 2 for everything else that should be checked at boot, 0 to skip. The check happens before mount, which is why filesystem integrity is a boot-time concern rather than a runtime concern.

Practical application

The everyday workflow for any new external drive looks like this. First, plug it in and immediately run lsblk to confirm its device name (likely /dev/sdc or /dev/sdd). Second, examine what is already there: sudo parted /dev/sdX print. Third, decide whether to keep the existing partitions or repartition. Fourth, format only the partitions you want to overwrite with sudo mkfs -t ext4 -L MyLabel /dev/sdX1. Fifth, mount with sudo mount /dev/sdX1 /mnt/work (after creating the directory). When done, sudo umount /mnt/work before physically removing the device.

For long-term mounts on a server, add an entry to /etc/fstab so the drive remounts automatically after reboot. Use the UUID (find it with blkid) rather than /dev/sdX, because device letters can shuffle when you add a new disk.

For verification of downloaded ISOs, the routine is invariant: download the image, download the sha256sum.txt from the same source, then run sha256sum -c sha256sum.txt --ignore-missing. A single bit-flip during download will produce a wildly different hash; matching hashes are nearly proof that the file arrived intact.

Example

Suppose you have a 256 GB external USB hard drive that came pre-formatted as a single 256 GB FAT32 partition. You want to repartition it as 128 GB ext4 (for Linux backups) plus 128 GB NTFS (so the same drive is readable on a friend's Windows machine).

  1. Plug it in. Run lsblk and confirm the device — let's say it appears as /dev/sdd with one partition /dev/sdd1. Verify by capacity, never assume.
  2. If the existing partition was auto-mounted, unmount it: sudo umount /dev/sdd1.
  3. Open parted interactively: sudo parted /dev/sdd. Print the current layout. Delete the existing partition: rm 1. Create the first new partition: mkpart primary ext4 1MB 128000MB. Create the second: mkpart primary ntfs 128000MB 100%. Print, confirm, then quit.
  4. Format each partition with its filesystem: sudo mkfs -t ext4 -L BackupDisk /dev/sdd1, then sudo mkfs -t ntfs -L Sharepoint --quick /dev/sdd2.
  5. Unplug and replug the drive. Most desktops will auto-mount under /media/<user>/BackupDisk and /media/<user>/Sharepoint. Confirm with lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT.
  6. Use it. When done, unmount both partitions before unplugging: sudo umount /media/<user>/BackupDisk /media/<user>/Sharepoint.

The whole operation walks every layer of the stack — block device (/dev/sdd), partitions (/dev/sdd1, /dev/sdd2), filesystems (ext4, NTFS), mount points (/media/...), and the directory tree the shell sees afterward. Same five tools, every time.

Continue exploring

Tags