Bug 240893

Summary: Add ZFS Detection to fstyp(8) Tool
Product: Base System Reporter: Slawomir Wojciech Wojtczak <vermaden>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Feedback Timeout    
Severity: Affects Only Me CC: markj, yuripv
Priority: ---    
Version: 12.1-RELEASE   
Hardware: Any   
OS: Any   

Description Slawomir Wojciech Wojtczak 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 ...  :)

Regards.
Comment 1 Yuri Pankov freebsd_committer freebsd_triage 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
zfs
# fstyp -lu /dev/ada0p3
zfs zroot
Comment 2 Slawomir Wojciech Wojtczak 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
zfs
#
Comment 3 Mark Johnston freebsd_committer freebsd_triage 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.