21.7 df, du, and ncdu: Measuring Disk Space Usage

Alright, let’s get our hands dirty and talk about figuring out where all your disk space went. You’ve seen the dreaded “No space left on device” error, or you’re just morbidly curious about what’s hoarding all those precious bytes. You have three main tools for this job: the old guard (df and du) and the brilliant new kid (ncdu). They answer related but fundamentally different questions. df tells you how full your filesystems are. du tells you how much space files and directories are consuming. Mixing them up is a classic rookie mistake, so let’s not be rookies.

21.6 /etc/fstab: Persistent Mount Configuration and Options

Alright, let’s talk about /etc/fstab. This is where we graduate from the “oh, just mount it manually for now” phase to a proper, grown-up system administration. Think of it as the system’s little black book of storage relationships—the ones it rekindles every single time it boots up. Forget to make an entry here for that crucial filesystem, and your server’s going to have a very bad, no-good morning when it restarts and can’t find its database.

21.5 mount and umount: Attaching and Detaching Filesystems

Right, let’s talk about getting your filesystems to actually show up. You’ve got this block device—a hard drive partition, a USB stick, a network share, a DVD (bless you, retro enthusiast). It’s just a bucket of ones and zeros to the kernel right now. The mount command is how you tell the system, “Hey, take that bucket, decode it using this specific set of rules (the filesystem type), and slap its contents onto this directory so we can get to it.” The umount command (yes, it’s umount, not ‘unmount’, a petty hill I will die on) is how you politely ask the system to stop doing that so you can, say, yank the USB drive without corrupting everything.

21.4 mkfs: Creating Filesystems (ext4, xfs, btrfs)

Alright, let’s get our hands dirty. You’ve got a disk partition sitting there, empty, raw, and utterly useless. It’s a blank slate, and mkfs (short for ‘make filesystem’) is your chisel. This is where we turn that inert block of storage into something your operating system can actually have a conversation with. Think of it this way: partitioning is like drawing the rooms on an architectural blueprint. Running mkfs is the construction crew showing up to actually build the walls, install the electrical wiring, and lay down the floorboards in each room. Each filesystem type (ext4, XFS, btrfs) is a different crew with their own specialties, quirks, and… well, sometimes their own bizarre ideas about how a house should be built.

21.3 parted: GPT-Capable Partition Management

Alright, let’s talk about parted. This is the tool you reach for when fdisk starts giving you that look—you know, the one where it subtly hints it was designed in an era when a 2GB hard drive was a big deal. parted is its modern, GPT-capable successor. It’s a single tool that does it all: creates partitions, sets flags, and, most importantly, doesn’t faint at the sight of a multi-terabyte drive. It’s also a bit of a control freak; it makes changes immediately, so you have to know what you’re doing before you hit ‘Enter’. No take-backsies.

21.2 fdisk: MBR Partition Management

Alright, let’s get our hands dirty with fdisk, the cantankerous old wizard of partition management. It’s been around since the dawn of time (or 1983, which is basically the same thing in computer years) and it’s still the go-to tool for wrangling MBR (Master Boot Record) partition tables. Forget the shiny graphical tools for a moment; this is where the real control is, and it’s all done through a delightfully archaic, text-based interface. Don’t worry, I’ll be your guide.

21.1 lsblk: Listing Block Devices and Their Layout

Right, let’s talk about lsblk. This is one of those utilities you’ll use so often it’ll become a reflex, like checking your rearview mirror before changing lanes. It’s the fastest, most straightforward way to answer the fundamental question: “What storage is actually attached to this machine, and how is it currently organized?” Forget fumbling through /dev/ and trying to guess which sdX letter you are. lsblk gives you a clean, hierarchical tree view of every block device—your hard drives, SSDs, USB sticks, optical drives, and their partitions—showing you exactly how they relate to each other. It’s like an X-ray for your storage.

— joke —

...