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).

FSNotes
ext4Long-standing Linux default, journaling
xfsRHEL default, great for large files
btrfsSnapshots, subvolumes
vfat/exfatCross-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
Danger: A broken /etc/fstab entry - 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 run mount -a immediately 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.