I am running a Samba server on a Debian box. It works fine; Windows can read and write to it just fine, but there's one issue.

The folder I'm sharing over Samba (/var/samba) is stored on my main drive, which is an old 40GB IDE drive. Inside that folder are symlinks to other folders on my system, 2 of which are actually on my 1TB SATA drive.

In Windows, I have the Samba share mapped to a drive letter, and it says there is only 9GB remaining (which is how much space is left on the server's root drive (40GB drive)).

Can I tell Samba to report that a different amount of free space is remaining? I was trying to make a Windows backup into one of the folders that's symlinked to the 1TB drive (yes, there's enough space remaining on that drive), but Windows won't let me because it thinks there's not enough free space left.

  • 1
    Any update to this question now that it's 2020 and we have Samba V4 and the OS X fruit extensions now? (Also, hello Rocket Hazmat, I think we used to work together :)
    – Josh
    Feb 23, 2020 at 16:30
  • @Josh I'm not sure if the dfree command trick still works or not. I've since rebuilt this server and the samba root directory is now on the larger drive, so the free size is reported correctly. (Hi, Josh. If you're the Josh I think you are, then I'm Eric! :-)
    – gen_Eric
    Feb 24, 2020 at 17:02
  • 1
    I am the Josh you think I am and definitely recognized your Gravatar :)
    – Josh
    Feb 24, 2020 at 17:03

2 Answers 2


I don't really there is much you can do aside from faking it.

Copied from the the linked article.

In your smb.conf, set the dfree command to a script. The parameter expects a command that will return the total number of blocks followed by the available number of blocks. The samba docs recommend the following:

dfree command = /usr/local/bin/dfree

Script /usr/local/bin/dfree

df $1 | tail -1 | awk '{print $2" "$4}'

Man smb.conf section 'dfree command'

The following content is a complete snapshot taken directly from https://web.archive.org/web/20150410132141/http://www.subvs.co.uk/faking_available_disk_space_samba which is a replica of what used to exist at the original webpage address for future internet visitors. https://m.xkcd.com/979/ indeed.

Faking available disk space on samba

I was running an exmerge on a just-about-to-croak exchange server, and the only place I could find to put the exported pst files was an old underworked ubuntu server. It had the free space needed, so it was just a case of a few changes to the smb.conf and off it went. The first run was fine, but a bit later I wanted to run this again. Exmerge will do a sort of synchronisation if the pst files matching the mailboxes it is exporting are already there, so when it said it needsed60G, it didnt actually, cos 59G is already there.

Of course it will refuse to run unless there is enough space for the full export (unless there is a "force" switch I dont know of?). In comes samba, and something that was not actually made for the job but worksperfectly: dfree command. This will let you swindle the connecting machines into believing you have whatever disk space you want.

The parameter expects a command that will return the total number of blocks followed by the available number of blocks. The samba docs recommend the following:

df $1 | tail -1 | awk '{print $2" "$4}'

and then in your smb.conf:

dfree command = /usr/local/bin/dfree

Of course now you have a choice of how to forge the available disk space reported by samba, you could make the command just cat a text file with the numbers you want, or even easier, just make it look like a migic disk, with the same amount of total and available space:

df $1 | tail -1 | awk '{print $2" "$2}'

With a cunning change of the command, it reports the free space as the same as the total space. Probably not a great idea to leave it like this, but it can really help in a pinch!

  • Faking it is pretty much what I was wondering if I could do. I just need Windows to think it has enough free space to make a backup.
    – gen_Eric
    Oct 26, 2011 at 18:51
  • This is dead link. Can anyone tell me how to "fake" it? I have the same problem asked in the question. One Samba share on a small drive that contains sym links to a very large drive. Windows only sees the size on the smaller drive and doesn't know that the symlinks are to much bigger folders. Thanks
    – DAB
    Mar 26, 2019 at 8:44
  • 2
    @DAB here is a copy from the wayback machine. web.archive.org/web/20150410132141/http://www.subvs.co.uk/…
    – Zoredache
    Mar 26, 2019 at 16:57
  • 1
    It looks like there's a bug with samba where it calls dfree with a $cwd of the share's root, and the path given in $1 is always '.', so if you symlink to a different disk, a properly implemented dfree just responds with the share's root's size..not the actual directory attempting to be written to's disk's size. Ended up having to fudge it, which isn't good because [the bodged dfree] affects all shares in that group.
    – Hashbrown
    Jan 17, 2022 at 8:14

The dfree command setting in smb.conf is indeed the solution to this problem, but unfortunately it's documentation, as of May 2023, is not accurate.

  • As noted in the comment by @Hashbrown, the path of the share is NOT given as an argument to the called script. $1 is always ".".
  • It is also not possible to give custom arguments to the script.
  • However, Samba calls the script from the share's directory, so if needed, the script can use $PWD to select it's actions according to the wanted share.
  • The setting should generally NOT be placed in the [global] section, but in the share sections where it is needed. So the other shares will use the default mechanism to return the sizes.

So if you have different disks mounted under a single Samba share, you need to decide what sizes to report for that share and define the script which does it.

Here is an example, with 2 different disks mounted under a single share.

$ tree /mnt

└── myshare
    ├── disk1
    └── disk2

In "smb.conf" :

    comment = Share with 2 mounted disks
    path = /mnt/myshare
    ;# ... other share settings ...
    dfree command = /usr/local/bin/my_dfree.sh

In the my_dfree.sh script, select for which of the 2 disks you want to return the sizes, and then echo the total blocks and free blocks for that disk :



# get total number of blocks and free blocks
# into arrays sizesA and sizesB
sizesA=( $( df $diskA | tail -1 | awk '{print $2,$4}' ) )
sizesB=( $( df $diskB | tail -1 | awk '{print $2,$4}' ) )

# return sizes of the disk with smaller free space left
if (( ${sizesA[1]} <= ${sizesB[1]} )); then
    echo "${sizesA[@]}"
    echo "${sizesB[@]}"
  • This still doesn't work for Mac. Anyone know why?
    – swami
    Dec 27, 2023 at 8:06
  • @swami : If your server is a Mac, it doesn't use Samba. If the Mac is the client and the server is Samba, it should work. Test the script first by itself in the server's shell.
    – mivk
    Dec 27, 2023 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .