Samba dfree problems

Keith Farrar farrar at parc.com
Sat Mar 24 11:26:33 GMT 2007


To fool your Windows clients: move /mnt to a file system
with a lot of free space.

The smbd daemon performs a chdir to the root of the shared path
before launching the dfree command, and then calls the dfree
command with the argument '.'.

Samba shares which cross mount points only show clients the
free space of the top-level shared directory. This does not work
well with your example, nor with the forest of symlinks to
(a couple thousand) NFS exports that I use at work.

On the other hand, if the dfree command requests spawned
thousands of non-cached df checks against hundreds of active
NFS mount points, that might make life less pleasant for
our Samba server and our NFS servers.

It would be nice to be able to toggle the chdir on a
per-share basis.

The dfree.sh script below logs the behavior (checked against
samba-3.0.25pre2). Set dfree command to this script, connect
to your share with smbclient, browse your shared directory
tree (crossing mount points a few times), then grep the
daemon.debug syslog output for smbd_dfree_cwd lines (they
will show the top-level shared directory path). Note: I
checked this under Linux, you may need to adjust the df
arguments on another platform.

-------
#!/bin/bash
df  $1 | tail -1 | awk '{print $2" "$4}'
echo $1 | logger -t smbd_dfree_args -p daemon.debug
echo `pwd` | logger -t smbd_dfree_cwd -p daemon.debug
-------



laesq wrote:
> Hi,
> 
> I've been trying to get Samba to display the free space of drives correctly
> on windows clients.
> 
> Let me show you my file system layout:
> 
> /
> |--- Mnt
>        |--- Storagei (mounted drive)
>        |--- Storageii (mounted drive)
>        |--- TempStore (mounted drive)
> 
> Ok, so as you can see, I have three drives mounted in /mnt. They all work
> fine and I'm able to copy files back and forth with no problems.
> 
> In my Samba config I share Mnt as Public. Windows clients map a drive to
> Public and that's fine. If I try and get the free space of one of the
> mounted drives from a windows client, it just returns the size and free
> space of /.
> 
> The reason I want to get sizes from the drives is that with the advent of
> windows vista, this first checks the free space of the destination drive
> before files are copied to it. Now if a user wants to copy a 2GB file to one
> of the mounted drives and I have less than 2GB free on / then then vista
> tells me I can't copy the files as there's not enough  space, even though
> the mounted drives all have way over 2GB free.
> 
> Now ideally I'd like to have Samba report the correct free space of the
> mounted drives. But if that's not possible, a simple faked free space being
> returned to windows clients would be equally useful.
> 
> I have tried using the dfree command option in smb.conf but I get error
> messages as follows:
> 
> [2007/03/22 15:33:02, 0] smbd/dfree.c:disk_free(117)...
> disk_free: sys_popen() failed for command /usr/local/bin/dfree .. Error was
> : No child processes... 
> 
> The script file I have at /usr/local/bin is named dfree. I have tried it's
> contents to be a df command which worked when run normally from the shell. I
> have also tried the contents as a simple echo "large number large number".
> Both execute fine from the shell, but they give the same errors in my samba
> log files.
> 
> I have also tried to add a line in the script file that creates a log file.
> Again, if run from the shell, it works. But when samba attempts to run it, I
> get the same errors in the log file.
> 
> The version of samba I'm running is smbd version 3.0.20a-2.2.cc. It's got
> the CC suffix as I'm running Clarkconnect and it's part of that distro.
> 
> Any help or pointers would be greatly appricated.
> Regards,
> LaesQ
> 


More information about the samba-technical mailing list