Bug 240893 - Add ZFS Detection to fstyp(8) Tool
Summary: Add ZFS Detection to fstyp(8) Tool
Status: Closed Feedback Timeout
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2019-09-28 11:07 UTC by vermaden
Modified: 2020-10-28 19:21 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description vermaden 2019-09-28 11:07:39 UTC
Output from 12.1-BETA1:

# fstyp /dev/md0
fstyp: /dev/md0: filesystem not recognized

ZFS is not detected. Either imported or exported.

This is quick and easy way to detect ZFS on a block device:

# head -c 32000 /dev/md0 | strings | grep -q pool_guid

Dunno how that may help with fstyp(8) written in C but ...  :)

Comment 1 Yuri Pankov freebsd_committer 2019-09-28 11:17:51 UTC
Excerpt from the fstyp(8) man page:

     When the -u flag is specified, fstyp also recognizes
     certain additional metadata formats that cannot be handled using
     mount(8), such as geli(8) providers, and ZFS pools.

So the following should work for you:

# fstyp /dev/ada0p3
fstyp: /dev/ada0p3: filesystem not recognized
# fstyp -u /dev/ada0p3
# fstyp -lu /dev/ada0p3
zfs zroot
Comment 2 vermaden 2019-09-28 11:31:50 UTC
Oh, I found -u flag ... but is that 'fread: Invalid argument' a bug?

# fstyp -u /dev/ada0p3.eli
fstyp: fread: Invalid argument
Comment 3 Mark Johnston freebsd_committer 2020-06-09 14:00:41 UTC
(In reply to vermaden from comment #2)
Yes, there is a bug in that handlers for several FS types assume they can read a 512 byte block, but your GELI disk probably has a block size >= 4096.  The errors come from those reads.  I suspect this means that they will not work properly on 4Kn drives either.