welcome: please sign in
location: ZVolPermissionsWithUdev

Managing zvol ownership and permissions with udev

There is something of a FAQ on how to make the permissions of a zfs volume (zvol) stick. In particular, the user and group (uid and gid) of the owner. When using ZFS on Linux, we can make this work by using udev.

udev puts out less information about these than about most others, but we can figure it out anyhow. There is a file /lib/udev/rules.d/60-zvol.rules that forms the basis for what we'll do.

First, create a udev rule, say /etc/udev/rules.d/99-local-zvol.rules:

KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="/lib/udev/zvol_id /dev/%k" RESULT=="tank/vm/debian" OWNER="jgoerzen"

Note carefully the number of equals signs in a row at different places.

The RESULT parameter holds the dataset path in zfs form (no leading slash).

If you have multiple zvols you wish to control, add them all here.

You can set, for instance:

OWNER="jgoerzen" GROUP="disk" MODE="0750"

or however you like.

To apply, run udevadm control --reload. The permission change will take effect on the next import of the zpool.

See Also

ZFSOnLinux

WikiCompleteOrg: ZVolPermissionsWithUdev (last edited January 17, 2014 by JohnGoerzen)