ZFS Quickly show pwd to zfs dataset relationship

gladiola

Active Member

Reaction score: 14
Messages: 126

Is there a command that quickly shows the relationship between present working directory and its zfs dataset?

If we already know the pwd value, we can simply zfs list | grep CLUE_FROM_PWD_VALUE. What is the best way to combine a pwd with zfs list and grep? We could build a few lines of script to do this, but is there such a function already made?
 

usdmatt

Daemon

Reaction score: 595
Messages: 1,538

You can get the ZFS dataset for the current directory easily enough -

Code:
root@s1:/storage/config/ssl # df .
Filesystem     1K-blocks Used     Avail Capacity  Mounted on
storage/config 700965479  863 700964615     0%    /storage/config
Code:
root@s1:/storage/config/ssl # df . | cut -wf1 | tail -n1
storage/config
 
Top