Learn FreeBSD - Filesystems, Mounts & Disks
Episode 7 of 23

Learn FreeBSD - Filesystems, Mounts & Disks

Understanding FreeBSD filesystems: UFS with soft updates and snapshots, ZFS with datasets and properties, and pseudo-filesystems like tmpfs, fdescfs, and devfs. You will also master mount and umount, /etc/fstab configuration, and swap management with swapon.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

In the previous episode 6, you managed services with the rc system and sysrc. Now we go one layer down to the foundation of storage: filesystems, mounts, and disks. Understanding this layer matters because every decision — from layout to disaster recovery — rests on it.

FreeBSD provides two main filesystems with very different personalities: UFS, classic and simple, and ZFS, modern with checksums and snapshots. On top of those are pseudo-filesystems for devices and memory. This episode maps it all out, then covers mounts, fstab, and swap.

Main Filesystems: UFS and ZFS

UFS: The Classic Berkeley Filesystem

UFS (Unix File System) is a Berkeley legacy with a long history in FreeBSD. Its modern version (UFS2) supports soft updates and snapshots. For simple systems, UFS remains a legitimate choice:

Memeriksa filesystem dengan mount dan df
mount
df -h

UFS is fast for small workloads and easy to understand. Its drawbacks: no end-to-end checksums, no multi-disk pooling, and limited snapshots compared to ZFS.

ZFS: The Modern Filesystem

ZFS combines a volume manager and a filesystem into a single layer. Datasets, properties, checksums, compression, and snapshots make it far superior for production. ZFS details are covered fully in episodes 8-9, but you've already seen its traces since the bsdinstall stage.

Melihat dataset ZFS
zfs list

Info

Generally speaking, for a new installation in this day and age, use ZFS. UFS remains useful for special cases — such as small boot volumes or very constrained environments — but ZFS is the future of FreeBSD.

Pseudo-Filesystems

FreeBSD mounts several virtual filesystems that don't store permanent data. Understanding them prevents confusion when mount displays many entries.

devfs: Devices as Files

devfs provides device nodes in /dev. When you add a disk, new nodes appear automatically. This is why FreeBSD uses names like /dev/da0 for SCSI/SATA disks and /dev/ada0 for ATA disks.

tmpfs: A Filesystem in Memory

tmpfs stores data in RAM and swap. It's well suited for /tmp, whose contents are easily discarded:

Memasang tmpfs di /tmp
mount -t tmpfs tmpfs /tmp

procfs and fdescfs

procfs exposes processes as files (usually mounted at /proc for compatibility), and fdescfs provides file descriptors in /dev/fd. Both are rarely touched, but useful for compatibility with certain applications.

Mount and Umount

Mounting Filesystems

mount connects a filesystem to a directory (mount point):

Memasang filesystem UFS
mount -t ufs /dev/da1p1 /mnt
mount -t zfs tank/data /tank-data

mount -t specifies the filesystem type. Without a flag, FreeBSD tries to detect it automatically. View all mount points with mount or df.

Unmounting Filesystems

umount detaches a filesystem. Make sure no process is using the mount point:

Melepas filesystem
umount /mnt
umount -f /mnt

The -f flag forces an unmount when a process is still using it. Use it only when truly necessary — you can lose data that hasn't been synced yet.

Warning

Before detaching a disk, make sure no process is writing. Use fstat to find processes that have files open on the mount point: fstat /mnt will show the PIDs that must be stopped first.

/etc/fstab: Automatic Mounts

Understanding the fstab Format

/etc/fstab determines which filesystems are mounted automatically at boot. Each line has six columns: device, mount point, type, options, dump flag, and passno:

Contoh isi /etc/fstab
cat /etc/fstab

On UFS systems, entries like /dev/ada0p2 / ufs rw 1 1 appear in this file. On ZFS systems, fstab is usually empty or minimal — ZFS mounts its own datasets at boot through the pool.

Adding an Entry

To add a permanent filesystem, edit /etc/fstab with the right options. The noauto option prevents automatic mounting:

Menambahkan entri fstab
mount -a

mount -a mounts all fstab entries. After editing, run it to verify the syntax before rebooting.

Swap Configuration

Swap is configured via an fstab entry with type swap, or managed manually with swapon and swapoff:

Mengelola swap
swapon /dev/da1p3
swapoff /dev/da1p3
swapinfo

swapinfo displays swap status. On a default ZFS installation, swap is created as a ZVOL in the pool.

Success

Check fstab with mount -a before rebooting every time you change this file. An error in fstab isn't always fatal — FreeBSD drops to single-user mode — but it's better to catch problems early.

Checking Disk Health

A few commands for monitoring disks and filesystems:

Memantau disk
df -h
pstat -s
fsck -f /dev/ada0p2

df -h shows used capacity, pstat -s shows swap, and fsck checks and repairs UFS filesystems. ZFS doesn't need fsck — its integrity is maintained by checksums and zpool scrub (episode 9).

Closing

In this episode 7, you understood FreeBSD filesystems: UFS and ZFS as the two main choices, the pseudo-filesystems devfs, tmpfs, procfs, and fdescfs, the mount and umount commands, the format and use of /etc/fstab, and swap management with swapon.

Key takeaways:

  • UFS is classic and simple; ZFS is modern with checksums and snapshots.
  • devfs exposes devices in /dev; tmpfs stores data in RAM.
  • mount -t <type> and umount control filesystem mounting.
  • /etc/fstab determines automatic mounts; verify with mount -a.
  • Swap is configured in fstab or via swapon/swapoff.

In the next episode, episode 8, we'll cover ZFS fundamentals — pools and vdevs, datasets, properties like compression and checksum, plus snapshots, clones, and boot environments with bectl. This is the storage foundation most widely used in FreeBSD production.

Learn FreeBSD - Filesystems, Mounts & Disks | Learn FreeBSD