Filesystems, Mounting & fstab
Creating & Mounting Filesystems
A partition is just raw, undifferentiated space until you write a filesystem onto it - the data structure that actually organizes bytes into files, directories, and metadata like permissions and timestamps. Formatting a partition means writing one of these structures onto it (destructively - any prior data is gone).
| FS | Notes |
|---|---|
ext4 | Long-standing Linux default, journaling |
xfs | RHEL default, great for large files |
btrfs | Snapshots, subvolumes |
vfat/exfat | Cross-platform removable media |
"Journaling" (ext4, xfs) means the filesystem keeps a running log of changes it's about to make before actually making them - so if the power dies mid-write, it can replay or roll back that log on next boot instead of leaving the filesystem in a half-written, corrupted state.
$ mkfs.ext4 /dev/sdb1 # create a filesystem
$ mkdir /data
$ mount /dev/sdb1 /data # mount temporarily
$ umount /data # unmount
Recall from Foundations that Linux has no drive letters - a second disk doesn't become D:, it gets mounted: grafted onto an existing directory (here, /data) so that everything under that directory now actually lives on /dev/sdb1 instead of the root filesystem. mount with no options like this is temporary - it vanishes the moment the system reboots.
Persistent mounts - /etc/fstab
To make a mount survive reboots, it has to be declared in /etc/fstab ("filesystem table"), which the boot process reads and re-mounts automatically. Each line has six fields: <device> <mountpoint> <fstype> <options> <dump> <pass>
UUID=1234-5678 /data ext4 defaults 0 2
- Prefer UUID (a unique ID baked into the filesystem itself, found with
blkid) over/dev/sdX- device names likesdbare assigned by detection order at boot, and can shift if you add, remove, or reorder disks. A UUID stays the same no matter what slot the disk is plugged into. - Test without rebooting:
mount -amounts everything listed in fstab that isn't already mounted - this is how you catch a typo before it becomes a failed boot. pass= fsck order:0skip (don't check this filesystem at boot),1root (check first),2others (checked after root).
Danger: A broken/etc/fstabentry - a bad UUID, a typo'd filesystem type - can leave a system unable to boot at all, dropping you into an emergency shell instead of a login prompt. Always runmount -aimmediately after editing/etc/fstab, while you still have a working session open, so any error surfaces on the spot rather than at the next reboot when you might not be sitting at the console.