Hello boys.
this is my latest project,that reached the working phase just right now,after weeks of tests :
https://github.com/Marietto2008/freebsd-src/tree/hammer2-root
HAMMER2 as the root filesystem of FreeBSD 16-CURRENT
3 December 2026
FreeBSD 16-CURRENT now boots from an EFI partition plus a single HAMMER2 volume, with snapshots and boot environments, without a single line of ZFS code.
The work ran from 21/11 to 03/12/2026: six gated phases, all passed, followed by a soak test and interoperability testing with DragonFly.
Why we did it
HyperBSD needs a root filesystem with snapshots and boot environments, but without any code derived from OpenSolaris (CDDL licence): the system must build and boot with ZFS disabled.
The gap in FreeBSD. The available root filesystems are UFS and ZFS. ZFS is ruled out by the licence requirement. UFS has snapshots designed for dump and background fsck, not for going back to an earlier version of the system; it has no data checksums and no compression.
Why HAMMER2. It is DragonFly BSD's file system: BSD licence, copy-on-write, instant snapshots, multiple PFSes (sub-volumes) on one volume, LZ4/zlib compression, a checksum on every block.
The starting point. A FreeBSD port already existed (kusumi/freebsd_hammer2 v1.2.13), but as a module for FreeBSD 14, not bootable as root and never tested under heavy load.
The goal of the brief (21/11). HAMMER2 as a "first-class" filesystem in the FreeBSD tree: kernel, mountroot, GEOM, loader, userland and boot environments,not a module bolted on top. Shortcuts were explicitly forbidden (mount options passed as a string, /boot on another filesystem, cron instead of periodic).
How we did it
Six phases in sequence, each closed by a gate: a list of tests with the expected outcome written down before running them, a report, and the project owner's decision. Without passing the gate, work did not move on to the next phase.
Working rules
Vendor model. Kusumi's port is imported untouched on its own branch; every integration step and every fix is a separate commit, recording what found the defect.
In total 65 commits on top of FreeBSD main 5ddfe1e, 132 files touched (most of the lines are the vendor imports).
Frozen on-disk format. No change to the format: a volume must remain readable and writable by DragonFly.
No CDDL. Not even libsa's lz4.c, which comes from OpenSolaris: the loader uses its own decompressor.
Isolated test bench. Everything in bhyve VMs (bhyveload or UEFI) on disk images; never the host's own disk. Test kernels always run with INVARIANTS and WITNESS enabled.
The phases
- P0, baseline (21–29/11). The port built into the FreeBSD 16 kernel and put through the hardest tests before touching the root. Most of the defects surfaced here (see below).
2. P1, the root (29–30/11). Mounting the root with volume@PFS syntax, mountroot waiting for every device of the volume, mount_hammer2 and its manual page.
3. P2, GEOM (30/11). A /dev/hammer2id/\<fsid\> label to find the volume without depending on the disk name.
4. P3, userland (30/11). fsck_hammer2 following the fsck(8) contract at boot, hammer2 in /rescue, periodic clean-up in periodic(8).
5. P4, the loader (30/11–01/12). A HAMMER2 reader written from scratch in libsa (loader.efi and userboot), which verifies checksums and refuses a corrupted kernel.
6. P5, boot environments (01/12). The hammer2be tool: each BE is a PFS snapshot; selectable from the loader menu, with "boot once" into a new BE.
7. P6, images (01/12). makefs -t hammer2 and mkimg: a bootable UEFI disk built without mounting anything, as for UFS and ZFS.
After the phases, the final validation (02–03/12): a soak test of three buildworlds on the HAMMER2 root, interoperability with DragonFly, a package build.
How we verified it
Every mandatory test passed on the final kernel or on the kernel of its phase; none was relaxed to make it pass.
Test | What it shows | Result
pjdfstest | POSIX semantics (permissions, rename, link, timestamps) | 230/230, repeated on every new kernel
fsx, 24 hours | Data consistency under random reads, writes, truncates, mmap | 403 million operations, 0 errors
stress2, 24 hours | FreeBSD's concurrent filesystem scenarios | rc 0, no panic
Crash loop, 500 rounds | After a hard reset no data confirmed by fsync is lost | 500/500, 720,848 markers verified, 0 lost
Crash loop on the root | The same, with HAMMER2 as the root | 500/500, 1,023,618 markers, 600 root mounts
100 reboots | The root always mounts, without waiting | 100/100, ssh ready in 22.9 s on average
KASAN and KMSAN | Out-of-bounds accesses and uninitialised memory in the kernel | 1 error found and fixed, then clean
WITNESS | Lock ordering (deadlock risk) | 0 reversals after the fixes
Loader reader | The loader reads exactly what the kernel reads | 61,420 entries in 20 compression/checksum combinations, identical
Loader fuzzing | Corrupted images neither hang nor fool the loader | over 12 million executions; 2 defects found and fixed, then 0
Crash while switching BE | The BE choice stays consistent | 20/20 after the fix
makefs -t hammer2 | An image built outside the kernel is correct | 12,079 entries, identical manifest as read by the kernel
Soak | Three buildworld+buildkernel -j8 on the root, bulkfree every 15 minutes | rc 0, 27 clean bulkfree runs, 0 LORs, clean fsck
DragonFly 6.4.2 interop | Volumes written by one system, read and written by the other, both ways | clean fsck on both, identical manifests (up to 125,119 entries)
The expected outcome of each test was written before running it, so a result different from the expectation is visible and cannot be rewritten afterwards.
Defects found and fixed
The tests found more than twenty defects in the starting code; seven of them could lose or corrupt data without any message. All are fixed in separate commits and covered by the test that found them. At least five also apply to DragonFly master (checked by reading the code); the report for its developers is ready but not yet sent.
fsync not durable | Data confirmed by fsync lost after a crash | Crash loop
Freemap: one block written several times per flush | Volume corrupted after a crash | Crash loop, round 422
bulkfree reused blocks still referenced | Volume corrupted after a crash | Crash loop, round 2047
Dirty buffers written after the volume header | Volume corrupted after a crash | Crash loop, rounds 3012 and 4047
Checksum "none" combined with dedup | Silent reads of stale or zeroed data | Comparing the loader reader with the kernel
SEEK_DATA ignored data still in memory | cp of a freshly written sparse file produced a copy full of zeros, with no error | Userland tests (P3)
truncate did not zero the tail of the block | After a truncate and an extension, old data reappeared | fsx
bufdaemon stalls and lost wake-ups | System hung under write load | WITNESS, stall reproducer
Lock not released, wrong assertion in rename | Panics (the second during the soak, in buildworld) | fsx and stress2; soak
Inconsistent lock ordering | Deadlock risk | WITNESS
bulkfree on an idle volume | Space was never freed | Userland tests (P3)
Read past the string on every mount | Out-of-bounds access in the kernel | KASAN
LZ4 decoder and two other undefined behaviours | Invalid accesses on particular data | Fuzzing, UBSan
BE choice saved with a rename on FAT | After a crash the choice vanished and the system booted single-user | Crash while switching BE
The last row was a defect in our own initial design, not in the vendor code: the file is now rewritten in place.
Strengths
The result is a complete root filesystem, entirely BSD-licensed, with robustness that has been measured rather than claimed.
Licence. All BSD: FreeBSD builds and boots from HAMMER2 with ZFS disabled, as HyperBSD requires.
Real integration. Root, GEOM label, loader, fsck at boot, /rescue, periodic, boot environments, makefs: HAMMER2 behaves like UFS and ZFS at every point of the system's life cycle, without any of the forbidden shortcuts.
Proven robustness. Over a thousand hard resets without losing a single confirmed write, 24 hours of fsx and 24 of stress2, three soak buildworlds, KASAN, KMSAN, WITNESS and fuzzing.
Cheap boot environments. A BE is a PFS snapshot: instant, taking space only for the blocks that change afterwards.
A loader that defends itself. The loader reader verifies checksums: a kernel with a single flipped bit does not boot.
Data not locked in. The on-disk format is DragonFly's, verified in both directions: a FreeBSD volume can be read and written by DragonFly and vice versa.
Traceability. Every change is a separate commit with the test that motivated it; every phase has a report with the expectations written beforehand.
Weaknesses and limits
The biggest limit is age: this is thirteen-day-old code, tested only in virtual machines and never used in production.
Never on real hardware. Everything ran in bhyve. The run on the dedicated disk is prepared but not done (it is destructive and needs consent).
amd64 only, UEFI only. arm64 was excluded by choice; there is no BIOS boot.
One disk, no self-healing. Checksums detect a corrupted block but cannot repair it from a copy; mirroring and RAID are possible only with GEOM underneath the filesystem (not tested).
Space is freed later. Deleting a file does not return the space at once: it needs bulkfree, which periodically runs daily and which may need two passes.
No performance figures. There is no speed or memory comparison with UFS and ZFS yet.
A fork to maintain. The fixes have not yet been proposed upstream (FreeBSD, kusumi, DragonFly). As long as they stay here, every update of the port or of FreeBSD main has to be merged by hand.
Few eyes. HAMMER2 has a small community: few users, few reviewers, little experience gathered on FreeBSD.
Pros and cons compared with UFS and ZFS
HAMMER2 offers almost everything ZFS boot environments provide, under a BSD licence, but without self-healing, send/receive and years of production use.
Feature | UFS | ZFS | HAMMER2 (this project)
Licence | BSD | CDDL | BSD
Boots with ZFS disabled | Yes | No | Yes
Boot environments | No | Yes (bectl) | Yes (hammer2be, new)
Snapshots | For dump and background fsck | Yes | Yes, also per PFS
Data checksums | No (metadata only) | Yes, with repair from copies | Yes, detects but does not repair
Compression | No | Yes | Yes (LZ4, zlib)
Redundancy | With GEOM underneath | Built in (mirror, RAIDZ) | With GEOM underneath (not tested)
Sending snapshots to other machines | No | Yes (send/receive) | No
Space after a deletion | Freed at once | Freed at once | After bulkfree
Years of use on FreeBSD | Decades | Over fifteen | Thirteen days (years on DragonFly)
Volumes usable by DragonFly | No | No | Yes, read and write
In short: compared with UFS you gain snapshots, boot environments, checksums and compression; compared with ZFS you gain the licence and lose self-healing, replication and maturity.
What remains to be done
Bare-metal runs on the dedicated disk
Propose the fixes upstream: kusumi/freebsd_hammer2, DragonFly, FreeBSD (needs approval).
Performances (HAMMER2 vs UFS vs ZFS) :
https://github.com/Marietto2008/freebsd-src/blob/hammer2-root/hammer2-project/rapporti/PERFORMANCE-report-20261203-en.md
Thanks to everyone that will help me to improve the code....