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

Learn DragonFlyBSD - Filesystems, Mounts & Disks

This episode covers the foundations of DragonFlyBSD storage: comparing HAMMER2, UFS, tmpfs, and mfs; mount and umount operations; disk management with disklabel and newfs_hammer2; laying out /etc/fstab; checking with fsck; and swap configuration.

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

Introduction

In episode 6 you set up services and boot order through the rc system. Now we go down to the most physical layer: disks and filesystems. All data — packages, logs, configuration, databases — ultimately lives on a filesystem. Understanding how filesystems are chosen, formatted, mounted, and maintained is a core administrator skill.

This episode is the foundation of storage. Here you'll get to know HAMMER2 as the primary filesystem, UFS as the classic alternative, tmpfs for fast storage in RAM, and mfs for memory-mapped filesystems. In episodes 8 and 9 we'll build this foundation into advanced HAMMER2 management.

Choosing a Filesystem

HAMMER2: The Primary Filesystem

HAMMER2 is DragonFlyBSD's default filesystem. It's designed for modern workloads: copy-on-write, per-block checksums, cheap snapshots, deduplication, compression, and encryption. For almost every need — root, data, snapshots — HAMMER2 is the first choice.

UFS: The Classic Alternative

UFS is the mature, lightweight classic BSD filesystem. It doesn't have snapshot and checksum features like HAMMER2, but it's very stable and tested over decades. Use UFS for small partitions that don't need advanced features, or when compatibility with legacy tooling is a priority.

tmpfs & mfs: Storage in RAM

Both of these filesystems live in memory, so they're very fast but their contents disappear on reboot:

FilesystemCharacteristicsUse cases
tmpfsRAM-based filesystem with a size limit/tmp, cache, build areas
mfsMemory filesystem that can be mountedSimilar to tmpfs, from classic BSD

Common uses: putting /tmp on tmpfs to speed up temporary file access, or pointing the DPorts build area at tmpfs so it doesn't wear down your disk.

Mount & Umount Operations

mount and umount

Mounting is the process of attaching a filesystem to the directory hierarchy. The basic commands:

Mount and umount filesystems
mount /dev/da1s1a /mnt/data
mount -t tmpfs tmpfs /tmp
umount /mnt/data

Without specifying a filesystem, mount guesses from the disk's contents. For known filesystems, just name the device and the mount point. umount detaches the filesystem; you must make sure no process is using the mount point.

Viewing Mount Status

Show all mounted filesystems along with their options:

View mounted filesystems
mount
df -h

df -h shows space usage in human-readable units — a command that will become your daily companion.

Disk Management

disklabel: Disk Layout

disklabel splits a disk into partitions. After plugging in a new disk, the steps are: initialize the label, create partitions, then format:

Create a disklabel on a new disk
disklabel -r -w da1 auto
disklabel -e da1
newfs_hammer2 -L data /dev/da1s1d

disklabel -r -w da1 auto creates an automatic label; disklabel -e opens an editor to adjust the partitions. Once the layout is done, the partition is formatted with newfs_hammer2.

newfs_hammer2: Formatting the Filesystem

newfs_hammer2 formats a partition into a HAMMER2 filesystem. Important options worth knowing:

OptionPurpose
-L labelSets the filesystem label
-s sizeVolume size
-c 0/1Enables checksum (on by default)
Format with a label and size
newfs_hammer2 -L data -s 10G /dev/da1s1d

This label is what you'll use for mounting in /etc/fstab — a more stable way to mount than remembering device names.

/etc/fstab: Permanent Mount Configuration

Filesystems you want always mounted at boot must be recorded in /etc/fstab. The format is: device/label, mount point, filesystem, options, dump, pass. Example:

Example /etc/fstab
# Device                Mountpoint    FSType     Options          Dump Pass
/dev/da0s1a             /             hammer2    rw               0    0
/dev/da0s1b             none          swap       sw               0    0
/dev/da1s1d             /data         hammer2    rw               0    0
tmpfs                   /tmp          tmpfs      rw,mode=1777     0    0

You can put all your HAMMER2 filesystems in one line with many mount points, or write one line per entry as above. After editing, test with mount -a to mount every entry without needing a reboot.

fsck: Filesystem Checking

When the system doesn't shut down cleanly, the filesystem may need checking. fsck checks and repairs the filesystem structure:

Check a filesystem
fsck -t hammer2 /dev/da1s1d

With its copy-on-write design, HAMMER2 is fairly crash-tolerant, but periodic checking is still a healthy habit. For HAMMER2, the dedicated tools fsck_hammer2 and hammer2 offer deeper insight into filesystem health — we'll cover them in episode 11.

Swap

Swap is disk space used when RAM is full. Enabling swap on a prepared partition:

Enable swap
swapon /dev/da0s1b
swapinfo

DragonFlyBSD also supports swapcache — using swap as a cache for rarely accessed HAMMER2 file data, reducing pressure on the main disk. This is an advanced setting useful for storage workloads (we'll touch on it in episode 19).

Warning

Pay attention to mount order: filesystems that hold other mount points must be mounted first. mount -a will fail if a parent entry is missing. Always test /etc/fstab changes with mount -a from single-user mode before rebooting, to avoid a system that can't boot.

Closing

In this episode 7 you understood the foundations of DragonFlyBSD storage: the comparison between HAMMER2, UFS, tmpfs, and mfs; mount and umount operations; disk management with disklabel and newfs_hammer2; laying out /etc/fstab for permanent mounts; checking with fsck; and swap configuration with swapon.

Key takeaways:

  • HAMMER2 is the primary filesystem; UFS for classic cases; tmpfs/mfs for fast in-RAM data.
  • disklabel arranges partitions, newfs_hammer2 -L data /dev/da1s1d formats them.
  • /etc/fstab makes mounts permanent; test with mount -a before rebooting.
  • fsck checks filesystems; swapon and swapinfo manage swap.
  • df -h and mount are the two diagnostic commands you'll use most often.

In the next episode, episode 8, we enter the heart of this series: HAMMER2 fundamentals. You'll learn the concepts of PFS and datasets, how to mount with mount_hammer2, adding volumes with hammer2 volume-add for multi-volume disk spanning, plus the compression properties (zstd, lz4), checksums, and mount options.