Learn DragonFlyBSD - Storage Engineering: HAMMER2 Production
Episode 19 of 23

Learn DragonFlyBSD - Storage Engineering: HAMMER2 Production

This episode designs production storage on DragonFlyBSD: NAS with multi-volume HAMMER2, managing dedup and encryption, scheduling snapshots with cron, monitoring with hammer2 status, and growfs for filesystem resizing in 6.2+.

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

Introduction

In episode 18 you ran VMs on top of NVMM. Now we apply all the storage knowledge you've gathered since episode 7 to one final, very tangible goal: designing production storage. This is the moment when HAMMER2 — the filesystem that motivated you to learn this series from the start — really does its job.

Imagine you've been assigned to build a company's storage server: many disks, ever-growing data, daily backup requirements, and demands for data integrity. Episode 19 lays out the blueprint: multi-volume HAMMER2 to use all the disks, dedup and encryption for efficiency and security, scheduled snapshots via cron, routine monitoring, and smooth resizing as capacity grows.

Use Case: NAS / Storage Server

Multi-Volume Architecture

The basis of production storage is using all available disk space. With multi-volume HAMMER2, additional disks are formatted and joined without stopping services:

Assemble a multi-volume HAMMER2
newfs_hammer2 -L data -s 4T /dev/da1s1d
newfs_hammer2 -L data -s 4T /dev/da2s1d
mount_hammer2 /dev/da1s1d@data /srv/nas
hammer2 volume-add /dev/da2s1d /srv/nas

After volume-add, the data filesystem has 8 TB from two disks. When you need more, format a new disk and volume-add again — capacity grows hot.

A PFS Structure per Service

Inside that large filesystem, split it into per-service PFSes so snapshots and properties can be managed per need:

PFS per service
hammer2 pfs-create /srv/nas/docker
hammer2 pfs-create /srv/nas/backup
hammer2 pfs-create /srv/nas/secure
mount_hammer2 /srv/nas/backup /mnt/backup

The secure PFS can be encrypted, the backup PFS gets the most frequent snapshots, and the docker PFS uses zstd compression for its repetitive images.

Dedup for Space

Dedup works best on repeated data — VM images, tar backups, ISOs. Enable and run scheduled bulkfree:

Enable and run dedup
hammer2 bulkfree /srv/nas

Encryption for Sensitive Data

For PFSes storing sensitive data, enable encryption and document the keys:

Encrypt a sensitive PFS
hammer2 set-encrypted /srv/nas/secure

Best Practices

Scheduling Snapshots with Cron

Regular snapshots are the backbone of recovery. Set up a schedule with cron — daily snapshots kept for a few days, weekly snapshots kept longer:

Crontab for snapshots
# snapshot harian jam 2 pagi, simpan 7 hari
0 2 * * * hammer2 snapshot /srv/nas/docker
0 2 * * * hammer2 snapshot /srv/nas/backup

Remove snapshots past their target age with scheduled hammer2 pfs-destroy, or manage them manually at specific points in time. The key to a good schedule is regularity, not variety.

Warning

A snapshot that's never been test-restored is worth as much as no snapshot at all. Also schedule periodic restore tests — for example mounting the oldest snapshot and verifying its contents — as part of your monthly operational procedure.

Monitoring with hammer2 status

hammer2 status becomes your health dashboard:

Monitor HAMMER2 status
hammer2 status /srv/nas
df -h /srv/nas

Integrate it into a monitoring system (for example cron + mail, or output to an external tool). When usage approaches the limit, that's the moment to add a volume or clean up old snapshots.

growfs: Resizing the Filesystem (6.2+)

When a volume is enlarged — for example a VM's virtual disk is expanded — HAMMER2 can extend the filesystem without unmounting. Since 6.2, growfs handles resizing automatically:

Expand a HAMMER2 filesystem
growfs /srv/nas

After the physical disk grows, growfs adjusts the volume size. Check the size after growfs with hammer2 status — the new capacity is immediately available for the next volumes and snapshots.

Off-Site Backup Strategy

A storage server without off-site backup is a time bomb. Combine:

  • Local snapshots — fast recovery from manual mistakes.
  • rsync or hammer2 send to another host — protection from disk loss.
  • Tar archives to other media — portability for major disasters.

Apply the 3-2-1 rule from episode 11: three copies, two media types, one off-site.

Closing

In this episode 19 you designed production storage with HAMMER2: building a multi-volume NAS with hammer2 volume-add, arranging per-service PFSes with different properties, enabling dedup and encryption, scheduling snapshots with cron, monitoring with hammer2 status, and expanding the filesystem with growfs (6.2+).

Key takeaways:

  • Multi-volume HAMMER2 combines many disks hot: hammer2 volume-add /dev/da2s1d /srv/nas.
  • Split storage into per-service PFSes so snapshots and properties can be managed per need.
  • Schedule snapshots with cron and test restores periodically.
  • hammer2 status and df -h are your daily monitoring dashboards.
  • growfs expands the filesystem without unmounting; combine local snapshots + off-site rsync/send.

In the next episode, episode 20, we play with source: build system & kernel customization. You'll build the system from source with make buildworld and make buildkernel, install with make installkernel, understand binary updates with dragonfly-update, and write a custom kernel config in /usr/src/sys.

Learn DragonFlyBSD - Storage Engineering: HAMMER2 Production | Learn DragonFlyBSD