5

I'm running Debian 10 in a VM (using KVM) and I want to use ZFS as a non-root user. Here is what I did.

I added this line to my sources.list file

deb http://deb.debian.org/debian buster-backports main contrib non-free

Here is my complete sources.list file

deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free

deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free

deb http://deb.debian.org/debian buster-updates main contrib non-free
deb-src http://deb.debian.org/debian buster-updates main contrib non-free

deb http://deb.debian.org/debian buster-backports main contrib non-free

I installed ZFS

sudo apt install zfs-dkms zfsutils-linux -y

Then during the installation I got the following error

Failed to start Mount ZFS filesystems

And I resolved my problem by running

sudo /sbin/modprobe zfs
sudo apt upgrade -y

I added the following line to the /etc/modules

zfs

There is 2 disks connected to my VM :

  • /dev/sdb
  • /dev/vda

I created a pool

sudo zpool create -f mypool mirror /dev/vda /dev/sdb

See my zpool list

$ sudo zpool list
NAME     SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
mypool  9.94G   291K  9.94G         -     0%     0%  1.00x  ONLINE  -

And my zpool status

$ sudo zpool status
  pool: mypool
 state: ONLINE
  scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    mypool      ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        vda     ONLINE       0     0     0
        sdb     ONLINE       0     0     0

errors: No known data errors

Then I tried to delegate ZFS permissions. So I added a new user :

sudo adduser zfsuser

I changed the permissions of /mypool/

sudo chown zfsuser:zfsuser /mypool -R
sudo chmod u+rwx /mypool -R
sudo chmod go-rwx /mypool -R

Then I gave the permissions

sudo zfs allow -u zfsuser create,destroy,mount mypool

Here is the result of zfs allow mypool

$ sudo zfs allow mypool
---- Permissions on mypool -------------------------------------------
Local+Descendent permissions:
    user zfsuser create,destroy,mount

But when I log as zfsuser

su zfsuser

The user isn't able to mount even if I gave the permission in a previous command

$ /sbin/zfs create mypool/test
filesystem successfully created, but it may only be mounted by root

What am I missing ? Should I edit my fstab file to allow zfsuser to mount ? How should I do that ?

Thanks

amrbcl
  • 53
  • 5

1 Answers1

2

Please refer to "Possible Workarounds for Inability to Mount as non-root under Linux #10648".

zfs create and zfs clone won't work right now.

ivzhh
  • 136
  • 3