Debian Samba server reports free size of root drive, not all drives

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.


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:

[global]
dfree command = /usr/local/bin/dfree

Script /usr/local/bin/dfree

#!/bin/sh
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:

#!/bin/sh
df $1 | tail -1 | awk '{print $2" "$4}'

and then in your smb.conf:

[global]
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:

#!/bin/sh
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!