💾 Archived View for complete.org › managing-zfs-zvol-permissions-with-udev captured on 2024-08-24 at 23:44:48. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Managing ZFS zvol permissions with udev

There is something of a FAQ on how to make the permissions of a ZFS on Linux[1] 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.

1: /zfs-on-linux/

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.

Additional note for LVM

If you use LVM on your host, and your zvols contain LVM images, you might also want to add this to lvm.conf so that zvol LVM images are not presented on the host:

      filter = [ "r|/dev/zvol|", "r,/dev/zd.*,", "a/.*/" ]

See Also

ZFS on Linux

--------------------------------------------------------------------------------

Links to this note

2: /zfs-on-linux/

This is about running ZFS[3] on Linux[4] and Debian[5].

3: /zfs/

4: /linux/

5: /debian/

More on www.complete.org

Homepage

Interesting Topics

How This Site is Built

About John Goerzen

Web version of this site

(c) 2022-2024 John Goerzen