Set arc cache max limit (/etc/modprobe.d/zfs.conf) and reboot
# Max 8 GB Cache
options zfs zfs_arc_max=8589934592
Activate compression and deduplication
zfs set dedup=on tank0
zfs set compression=on tank0
Add ZFS dataset as mountpoint
cat /etc/pve/lxc/100.conf
...
mp0: /tank0/storage/media,mp=/storage/media,acl=1
Start container, add sambauser and group media
useradd --no-create-home sambauser
smbpasswd -a sambauser
groupadd media
usermod -g media sambauser
id sambauser
uid=1000(sambauser) gid=1001(media) groups=1001(media)
If gid is xxxx -> set gid of dataset to 10xxxx
chown :10xxxx /tank0/storage/media -R -f
Set default file/folder permissions
chmod g+s /tank0/storage/media
apt install acl
zfs set acltype=posixacl tank0
zfs set xattr=sa tank0
setfacl -d -m g::rwx /tank0/storage/*
setfacl -d -m o::0 /tank0/storage/*
getfacl media
# file: media
# owner: root
# group: 10xxxx
# flags: -s-
user::rwx
group::rwx
other::---
default:user::rwx
default:group::rwx
default:other::---
Verify
ls -lan /storage/media
drwxrwxrwx 4 65534 1001 7 Jul 11 11:11 .
-rw-r--r-- 1 0 1001 70 Jul 11 10:28 testfile
Edit /etc/samba/smb.conf
cat /etc/samba/smb.conf
[global]
wide links = yes
unix extensions = no
# Default mask for new files
create mask = 0770
directory mask = 0770
vfs objects = recycle shadow_copy2
# Add .zfs to Windows Shadow Copy
# Works with snapshots created by sanoid
shadow: snapdir = .zfs/snapshot
shadow: sort = desc
shadow: format = _%Y-%m-%d_%H:%M:%S_
shadow: snapprefix = ^autosnap
shadow: delimiter = _
shadow: localtime = yes
# Adds recycle bin for deleted files
# Preserves original dir structure
recycle:repository = .recycle
recycle:keeptree = yes
recycle:versions = yes
recycle:directory_mode = 0770
[share]
path = /path/to/share
valid users = @share-group
read only = no