3

I am trying to let a non root user create zfs snapshots.

I've created a permission set and given the appropriate user the privileges defined in it:

root@computer:~# zfs allow homepool/myuser
---- Permissions on homepool/myuser -----------------------------------
Permission sets:
    @myuser_allowed mount,snapshot
Local+Descendent permissions:
    user myuser @myuser_allowed

But when I try to create the snapshot I get the following error:

root@computer:~# su - myuser
myuser@computer:~$ /sbin/zfs snapshot homepool/myuser@`date +%F_%R`
Permission denied the ZFS utilities must be run as root.

Creating the snapshot as root works as expected:

root@computer:~# zfs snapshot homepool/myuser@`date +%F_%R`
root@computer:~# zfs list -t snapshot
NAME                              USED  AVAIL  REFER  MOUNTPOINT
homepool/myuser@2016-10-30_19:01    44K      -  5,32G  -
homepool/myuser@2016-10-30_19:37      0      -  5,32G  -

Do I need to add something else to the permission set? Or is it something with the privileges on the zfs binary?

root@computer:~# ls -l `which zfs`
-rwxr-xr-x 1 root root 103352 okt  5 15:05 /sbin/zfs

Applying the privileges described here works no better:

root@computer:~# zfs allow -s @myuser_allowed create,mount,snapshot,clone,promote homepool/myuser
root@computer:~# zfs allow homepool/myuser
---- Permissions on homepool/myuser -----------------------------------
Permission sets:
    @myuser_allowed clone,create,mount,promote,snapshot
Local+Descendent permissions:
    user myuser @myuser_allowed
root@computer:~# su - myuser
myuser@computer:~$ /sbin/zfs snapshot homepool/myuser@`date +%F_%R`
Permission denied the ZFS utilities must be run as root.
CC BY-SA 3.0

2 Answers 2

4

It seems zfs allow support was added as a feature in (the still not released) ZoL 0.7.0.

Judging from the names of the installed packages (why can't you just do zfs --version?):

# dpkg-query --list | grep -i zfs
ii  libzfs2linux                                0.6.5.6-0ubuntu14                             amd64        Native OpenZFS filesystem library for Linux
ii  libzpool2linux                              0.6.5.6-0ubuntu14                             amd64        Native OpenZFS pool library for Linux
ii  zfs-doc                                     0.6.5.6-0ubuntu14                             all          Native OpenZFS filesystem documentation and examples.
ii  zfs-zed                                     0.6.5.6-0ubuntu14                             amd64        OpenZFS Event Daemon (zed)
ii  zfsutils-linux                              0.6.5.6-0ubuntu14                             amd64        Native OpenZFS management utilities for Linux

Ubuntu 16.04 seem to be running version 0.6.5of ZFS on Linux.

That's probably the explanation to why it is not working for me. The error message could've been more explicit imho.

CC BY-SA 3.0
1

As of this writing, there isn't support for 'zfs allow' or 'zfs unallow' in ZoL. If you absolutely need to run zfs commands as a non-root user, you simply 'sudo chmod g+o rw /dev/zfs'. This will give all users the ability to run commands. Until there is built-in support for the allow/unallow commands, this is the only way. See the link attached for more information. https://github.com/zfsonlinux/zfs/issues/4410

CC BY-SA 3.0
2
  • Note that the permissions on /dev/zfs are reset on machine reboot. Might need a startup (or cron) script or something to make sure they are persistent
    – Alecz
    Nov 14, 2017 at 21:56
  • Didn't work. "sudo chmod g+o rw /dev/zfs" = "chmod: cannot access 'rw': No such file or directory". I ran that same command but replaced "rw" with the files and folders I wanted to give access to but still got "Permission denied", even when running as sudo. Well, maybe the previous text does not apply since it is about zfs commands ran by not root.
    – Rublacava
    4 mins ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.