ZFS + Samba problems (no used space report)

So far so good I’ve succesfully migrated my 4tb drives to zfs.
The only “problem” if have is that windows doesn’t report the used space of the pool:
I think it’s because I used datasets but mount the “root” pool

And Windows:
image
Is there a way to fix this?

I’ve already found a way to potentially fix this. Editing the samba.conf with this:
dfree command = /boot/config/plugins/user.scripts/scripts/dfree/script
and the script that would be executed is something like this:

#!/bin/bash

    CUR_PATH=`pwd`

    USED=$((`zfs get -o value -Hp used $CUR_PATH` / 1024)) > /dev/null
    AVAIL=$((`zfs get -o value -Hp available $CUR_PATH` / 1024)) > /dev/null

    TOTAL=$(($USED+$AVAIL)) > /dev/null

    echo $TOTAL $AVAIL

which gives me this output:

 root@Unraid-Ryzen:/mnt/zfs# sh /boot/config/plugins/user.scripts/scripts/dfree/script
    10993962589 724870574

So the script is working fine. But still the same problem with windows.
Have any of you the same problem and an idea on how to fix this?
Help much appreciated :+1:

you should share your whole samba config

1 Like

My current samba config is:

  [rootshare]
    path = /mnt/user
    comment =
    browseable = yes
    valid users = paul, root, win10vm, paul10gbit, osx
    write list = paul, root, win10vm, paul10gbit, osx
    vfs objects = catia fruit streams_xattr
    #unassigned_devices_start
    #Unassigned devices share includes
       include = /tmp/unassigned.devices/smb-settings.conf
    #unassigned_devices_end

    [Zfs-Unraid]
    path = /mnt/zfs
    comment = my Zfs pool
    browseable = yes
    valid users = paul, root, win10vm, paul10gbit, osx
    write list = paul, root, win10vm, paul10gbit, osx
    vfs objects = catia fruit streams_xattr
    dfree command = /boot/config/plugins/user.scripts/scripts/dfree/script

    [Zfs-SSD]
    path = /warp
    comment = my Zfs SSD pool
    browseable = yes
    valid users = paul, root, win10vm, paul10gbit, osx
    write list = paul, root, win10vm, paul10gbit, osx
    vfs objects = catia fruit streams_xattr

Are there really no global settings?

What’s the permissions on /mnt/zfs

root@Unraid-Ryzen:~# ls -l /mnt/zfs/
total 38
drwxrwxrwx  4 root root  4 Apr 19 22:17 Backup/
drwxrwxrwx  7 root root  8 Apr 19 22:15 Media/
drwxrwxrwx  4 root root  5 Apr 11 08:51 Movies/
drwxrwxrwx 21 root root 21 Apr 15 22:17 Misc/
drwxrwxrwx  3 root root  4 Apr 10 10:09 Steamcache/
drwxrwxrwx  3 root root 13 Apr 15 09:50 isos/

root@Unraid-Ryzen:~# ls -l /mnt/
drwxrwxrwx  8 nobody users   9 Apr 15 09:45 zfs/

I’m assuming you didnt change anything in the samba file that has your globals. looks like unraid uses separate samba files for the shares. I’m also assuming your other shares do display their usage correctly. If these are incorrect then feel free to correct me.

Correct, I think it’s a problem specificly with zfs datasets. I also have another zfs pool that has no datasets and that does not have this problem.

If you have a pool then you have a dataset, so I’m not sure what you mean.

I mean that I’ve created additional datasets:

 root@Unraid-Ryzen:~# zfs list
    NAME                     USED  AVAIL     REFER  MOUNTPOINT
    pool1                   23.6T  7.10T      232K  /mnt/zfs
    pool1/Backup             459G  7.10T     3.29G  /mnt/zfs/Backup
    pool1/Backup/SSD-Array   456G  7.10T      373G  /mnt/zfs/Backup/SSD-Array
    pool1/Media             5.93T  7.10T     5.93T  /mnt/zfs/Media
    pool1/Misc              1.00T  7.10T     1.00T  /mnt/zfs/Misc
    pool1/Steamcache         180K  7.10T      180K  /mnt/zfs/Steamcache
    pool1/isos              15.4G  7.10T     15.4G  /mnt/zfs/isos
    warp                     383G   997G      383G  /warp

And the storage used by these children don’t count towards used space

Instead of using datasets (zfs) use the pool (zpool).

Single pool

#!/bin/bash
# name         zpool-total+avail.sh
# description  Get zpool total & avail
# author          

zpoolName="ZpoolName"
#used=$((`zpool list -o alloc -Hp $zpoolName` / 1024)) > /dev/null
avail=$((`zpool list -o free -Hp $zpoolName` / 1024)) > /dev/null
total=$((`zpool list -o size -Hp $zpoolName` / 1024)) > /dev/null
echo $total $avail #$used

Multi pool

To make it more scalable I made it callable.

#!/bin/bash
# name         zpool-total+avail.sh
# description  Get zpool total & avail
# author          

zpoolName=$1
#used=$((`zpool list -o alloc -Hp $zpoolName` / 1024)) > /dev/null
avail=$((`zpool list -o free -Hp $zpoolName` / 1024)) > /dev/null
total=$((`zpool list -o size -Hp $zpoolName` / 1024)) > /dev/null
echo $total $avail #$used

But I can’t get Samba to call the script and sent a argument.

#!/bin/bash
$(dirname ${BASH_SOURCE[0]})/zpool-total+avail.sh ZpoolName
1 Like