🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.hackers
Article #131

Re: Now FreeBSD boots from an EFI partition plus a single HAMMER2 volume, with snapshots and boot environments, without a single...

#131
From: vermaden
Date: Fri, 04 Dec 2026 12:39
352 lines
17322 bytes
Hi,

this is very interesting and welcome, would be great to have that in 'main' tree.

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

This part seems interesting to me, why is that needed?


Thanks,
vermaden


> 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).
> 
> The follow-up for HyperBSD. One PFS per jail, with per-jail snapshots and rollback.
> 
> 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
> 
>> 
>> 1. 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.
		
>> 
>> Click to expand...
>> 
> 
> 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)
		
>> 
>> Click to expand...
>> 
> 
> 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
		
>> 
>> Click to expand...
>> 
> 
> 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.
>> 
>> Open checks. Some minor items of the brief (V1, V3, V4, V8) and the package build on the root are not yet closed.
		
>> 
> 
> 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....
> 
> -- 
> 
> Mario.
> 


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <fjbnoxntvvfcpeuvefnv@zuob>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
References: <CA+1FSijDaxB=kHBVq5We2x0u7WxWed=OEazQ_qJhPzHNdPxdjw@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: vermaden <vermaden@interia.pl>
Newsgroups: muc.lists.freebsd.hackers
Subject: Re: Now FreeBSD boots from an EFI partition plus a single HAMMER2
 volume, with snapshots and boot environments, without a single line of ZFS
 code.
Date: Fri, 04 Dec 2026 13:39:44 +0100
Organization: Newsgate at muc.de e.V.
Approved: news-admin@muc.de
Distribution: world
Message-ID: <fjbnoxntvvfcpeuvefnv@zuob>
References: <CA+1FSijDaxB=kHBVq5We2x0u7WxWed=OEazQ_qJhPzHNdPxdjw@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="9576"; mail-complaints-to="news-admin@muc.de"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1796387993;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references:list-id:list-help:
	 list-owner:list-unsubscribe:list-subscribe:list-post;
	bh=BWDlxN0ygdnLXWm6uc60zHARjdKoeunIfctqxHjQzP8=;
	b=KYHoe3BewGOie8Rn58SsfR53HteJHo55HEVQP3gtuq7aYKYSjqJaT1caoHcmL90h9zLUi/
	qLieBeE2SkMV+XqJNQ9HVI+3j5v0b97VRdskGqBLT8Xl21r0h/v7W9FxNZ9UkZ2oFxmdIl
	NPurphUdduMBQ95amTrd/u1Q4UbFSCnsXUYT4y06MGEOv3YQN3fnG85PynpTsZyZKxLfdO
	bc/lTFD56FcfBuExdDT3ZJtYyPUIQi9sAkiBxMIFT/pykdP4q/uEF+kCk16t++EArUbecO
	tDdczS6B77XmmrQuSWJsGcq5tJ0spLltrDb3zkjP34Vm/uItS/6vGP6x3nD6aA==
X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org
Authentication-Results: mx1.freebsd.org;
	dkim=pass header.d=interia.pl header.s=dk header.b=eu6WQxG0;
	spf=pass (mx1.freebsd.org: domain of vermaden@interia.pl designates 217.74.67.75 as permitted sender) smtp.mailfrom=vermaden@interia.pl;
	dmarc=pass (policy=none) header.from=interia.pl
In-Reply-To: <CA+1FSijDaxB=kHBVq5We2x0u7WxWed=OEazQ_qJhPzHNdPxdjw@mail.gmail.com>
X-Originating-IP: 45.148.42.3
Precedence: list
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl; s=dk;
	t=1796387986; bh=BWDlxN0ygdnLXWm6uc60zHARjdKoeunIfctqxHjQzP8=;
	h=Date:From:Subject:To:Message-Id:MIME-Version:Content-Type;
	b=eu6WQxG0EGVWO0fmqKVTceLkSA9IJYjRHqEBBydc1yIDzNjrEzEQS/thhoZ8QUY+V
	 0YO/YOoceuTI1lIbfdPC31s92e6qTGnPiV6sBJyH+MiP7BIGwozXQvTaD7o6JFSIVN
	 kdDyZEnqcH08EyTr9ifdn2OfisWPHWPoXxaMF8Ik=
X-Rspamd-Queue-Id: 4jgrfs52PNz3CDC
X-Spamd-Bar: /
X-Spamd-Result: default: False [-0.60 / 15.00];
	DMARC_POLICY_ALLOW(-0.50)[interia.pl,none];
	MID_RHS_NOT_FQDN(0.50)[];
	R_SPF_ALLOW(-0.20)[+ip4:217.74.64.0/22];
	R_DKIM_ALLOW(-0.20)[interia.pl:s=dk];
	RCVD_IN_DNSWL_LOW(-0.10)[217.74.67.75:from];
	ONCE_RECEIVED(0.10)[];
	RWL_MAILSPIKE_GOOD(-0.10)[217.74.67.75:from];
	MIME_GOOD(-0.10)[text/plain];
	MIME_TRACE(0.00)[0:+];
	DWL_DNSWL_NONE(0.00)[interia.pl:dkim];
	ARC_NA(0.00)[];
	FREEMAIL_ENVFROM(0.00)[interia.pl];
	FREEMAIL_FROM(0.00)[interia.pl];
	ASN(0.00)[asn:16138, ipnet:217.74.64.0/22, country:PL];
	FREEMAIL_TO(0.00)[gmail.com,freebsd.org];
	RCPT_COUNT_TWO(0.00)[2];
	TO_MATCH_ENVRCPT_SOME(0.00)[];
	FROM_EQ_ENVFROM(0.00)[];
	FROM_HAS_DN(0.00)[];
	RCVD_COUNT_ZERO(0.00)[0];
	TO_DN_ALL(0.00)[];
	SUSPICIOUS_AUTH_ORIGIN(0.00)[];
	HAS_XOIP(0.00)[];
	MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org];
	DKIM_TRACE(0.00)[interia.pl:+]
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes