Bug 296022 - FreeBSD can't mount NetBSD FFSv2 partitions
Summary: FreeBSD can't mount NetBSD FFSv2 partitions
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-06-12 14:15 UTC by Ricardo Branco
Modified: 2026-07-09 16:24 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo Branco 2026-06-12 14:15:04 UTC
We can mount OpenBSD's just fine but for partitions created in NetBSD 10.0+ we get:

$ sudo mount -r /dev/ada0p5 /mnt
mount: /dev/ada0p5: No such file or directory

And this line on dmesg:
[969] UFS2 superblock failed: fs->fs_metaspace (131072) > fs->fs_fpg / 2 (94980)

The check was added in this commit: d22531d572829

I also tried this command on NetBSD to convert the fs to support extattrs and ACLs:
# fsck_ffs -c ea /
https://man.netbsd.org/fsck_ffs.8
Comment 1 Ricardo Branco 2026-06-12 14:35:06 UTC
I ran this command on NetBSD:

# dumpfs -s /
file system: /dev/rdk6
format    FFSv2
endian    little-endian
location 65536    (-b 128)
magic    19540119    time    Fri Jun 12 16:24:17 2026
superblock location    65536    id    [ 68d06135 787b968e ]
nbfree    9260990    ndir    51861    nifree    18957676    nffree    16418
ncg    414    size    78643200    blocks    77424358
bsize    32768    shift    15    mask    0xffff8000
fsize    4096    shift    12    mask    0xfffff000
frag    8    shift    3    fsbtodb    3
bpg    23745    fpg    189960    ipg    46848
minfree    5%    optim    time    maxcontig 2    maxbpg    4096
symlinklen 120    contigsumsize 2
maxfilesize 0x000800800805ffff
nindir    4096    inopb    128
avgfilesize 16384    avgfpdir 64
sblkno    24    cblkno    32    iblkno    40    dblkno    2968
sbsize    4096    cgsize    32768
csaddr    2968    cssize    8192
cgrotor    0    fmod    0    ronly    0    clean    0x02
wapbl version 0x1    location 2    flags 0x0
wapbl loc0 314597568    loc1 131072    loc2 512    loc3 3
snapshot inodes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
usrquota 0    grpquota 0
flags    wapbl 
fsmnt    /
volname        swuid    0

It seems FreeBSD is reading NetBSD WAPBL fields as UFS2 fields due to struct layout divergence:

wapbl loc1 131072

FreeBSD reports fs_metaspace = 131072. That's wapbl loc1. FreeBSD's fs_metaspace field offset in struct fs corresponds to a NetBSD WAPBL journal location field.
Comment 2 Ricardo Branco 2026-06-12 16:12:42 UTC
Fix: https://github.com/freebsd/freebsd-src/pull/2279
Comment 3 Konstantin Belousov freebsd_committer freebsd_triage 2026-06-13 00:09:51 UTC
AFAIK NetBSD did a noisy mod to FFS code to allow it to support endianess different
from the host.  So we already do not support the NetBSD FFS mounts in some cases.

Might be we should just claim that NetBSD FFS is not FFS.
Comment 4 Ricardo Branco 2026-06-13 08:36:13 UTC
(In reply to Konstantin Belousov from comment #3)
We already fail on endian mismatch:
https://github.com/freebsd/freebsd-src/blob/main/sys/ufs/ffs/ffs_subr.c#L544
Comment 5 Warner Losh freebsd_committer freebsd_triage 2026-06-26 16:31:41 UTC
Apart from a minor style nit, I think the suggested patch in the pull request is good.
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-07-08 05:17:23 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3eb80d8d7daf4f14c22dd462d8c4e5b6fc818bd4

commit 3eb80d8d7daf4f14c22dd462d8c4e5b6fc818bd4
Author:     Ricardo Branco <rbranco@suse.de>
AuthorDate: 2026-06-13 08:26:58 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-07-08 05:16:01 +0000

    ufs: Allow read-only mounting of NetBSD FFSv2 WAPBL filesystems

    Skip UFS2 fs_metaspace upper-bound validation that rejects NetBSD FFSv2
    WAPBL filesystems due to differing superblock layouts.

    Detect the condition during mount instead and permit read-only mounts
    while rejecting read-write mounts with EROFS.  This follows NetBSD's
    recommendation for systems without WAPBL support and avoids modifying
    unsupported journal metadata.

    PR: 296022
    Signed-off-by: Ricardo Branco <rbranco@suse.de>
    Reviewed by: imp, kirk
    Pull Request: https://github.com/freebsd/freebsd-src/pull/2279

 sys/ufs/ffs/ffs_subr.c   | 14 +++++++++++++-
 sys/ufs/ffs/ffs_vfsops.c | 27 +++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)