Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Created June 22, 2016 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CMCDragonkai/3795849391a53262fd7afde5f905a459 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/3795849391a53262fd7afde5f905a459 to your computer and use it in GitHub Desktop.
ZFS: Introspect a File (Acquiring Creation Time... etc)

Introspecting a file on ZFS

Derived from: http://www.c0t0d0s0.org/archives/7485-Find-out-in-depth-information-about-a-file-in-ZFS.html

Sometimes you need to acquire in-depth information about a file that isn't exposed by other commands like stat.

ZFS allows you to do this with zdb. However there's a confusing problem. If you're just trying to access a file on your root pool that doesn't have any nested datasets, you need use rpool/ instead of just rpool (assuming "rpool" is the name of your root pool).

Here's 3 examples of acquiring information on /filepath.

zdb -dddd rpool/ $(find /filepath -maxdepth 0 -printf "%i")
zdb -dddd rpool/ $(ls --inode --directory /filepath | cut --delimiter=' ' --fields=1)
zdb -dddd rpool/ $(stat --format '%i' /filepath)

If you don't use rpool/, the error comes back as:

zdb: dmu_bonus_hold(2220608) failed, errno 2

Where 2220608 is the inode of the file/directory you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment