Disks, partitions, filesystems, and mounting
The full chain from a raw block device to something you can read and write files on. · 11 min
A block device (`/dev/sda`, `/dev/nvme0n1`) represents a raw disk as the kernel sees it — unusable for files directly until it's partitioned and formatted. Partitioning divides a disk into logical sections, recorded in a partition table using one of two schemes: the older MBR (Master Boot Record, limited to 4 primary partitions and 2TB disks) or the modern GPT (GUID Partition Table, supporting far larger disks and more partitions) — GPT is the standard choice for any new system today.
A filesystem then formats a partition (or an LVM logical volume) with a structure for actually organizing files and directories — ext4 is the long-standing, reliable default on most Linux distributions; XFS is common on RHEL-family systems and excels with very large files and filesystems; Btrfs offers built-in snapshots and checksumming at the cost of more complexity. Creating a filesystem (`mkfs`) is what turns an empty partition into something `mount` can actually attach to the directory tree.
Mounting attaches a filesystem to a specific point in the existing directory tree, making its contents accessible at that path — `mount /dev/sdb1 /mnt/data` makes that partition's files appear under `/mnt/data`. A mount performed manually like this doesn't survive a reboot; `/etc/fstab` is the file that defines mounts to be applied automatically at boot, referencing each filesystem by its UUID (a stable identifier, preferred over a device name like `/dev/sdb1` which can shift if disks are added or removed) rather than a device path that isn't guaranteed stable across reboots.
| Command | Purpose | Example |
|---|---|---|
| lsblk | List block devices and their partitions/mount points in a tree view | — |
| blkid | Show filesystem type and UUID for each block device | — |
| fdisk / gdisk | Create, delete, and inspect partitions (fdisk for MBR, gdisk for GPT — both interactive) | — |
| parted | Alternative partitioning tool supporting both MBR and GPT, scriptable | — |
| mkfs.ext4 / mkfs.xfs | Create a filesystem on a partition | sudo mkfs.ext4 /dev/sdb1 |
| mount / umount | Attach or detach a filesystem at a directory | sudo mount /dev/sdb1 /mnt/data |
| df -h | Show disk space usage per mounted filesystem | — |
| du -sh | Show total size of a specific directory | du -sh /var/log |
Common Mistakes
- ⚠ Referencing a mount by device name (`/dev/sdb1`) in `/etc/fstab` instead of UUID — device names can shift if disks are added, removed, or the boot order changes
- ⚠ Running `mkfs` on the wrong device and destroying existing data — always double- and triple-check the device path with `lsblk` first
- ⚠ Forgetting that a manual `mount` command doesn't survive a reboot without a corresponding `/etc/fstab` entry
Takeaway: The chain is always disk → partition → filesystem → mount point — and `/etc/fstab` referenced by UUID, not device name, is what makes a mount survive a reboot.