Force samba to tell accumulated share size

I wanted to backup my win7 on my fileserver, using the builtin backuptool and CIFS.
However, I have one big share where some cryptofilesystems are mounted, and samba will only tell the size/avail of the root directory which is exported, thus Windows thinks there is not enough space to do the backup.

Fortunately, you can force samba to tell an arbitrary sharesize with the dfree command.

I wanted samba to tell the combined size/avail of all filesystems currently mounted under my share, so I wrote this script:


filr ~ # cat /etc/samba/dfree
#!/bin/sh
df /enc* | tail -n +2 | sort | uniq | awk '{blocks +=$(NF-4); avail += $(NF-2)}; END {print blocks " " avail}'

and made it executable and told samba to use this for calculating the shares size/avail:

filr ~ # grep dfree /etc/samba/smb.conf
dfree command = /etc/samba/dfree
(in the [global] section)

And thats it. How does it work? the df - command matches all currently mounted cryptovolumes (as they all begin with /enc* here), tail -n +2 strips the first line of df's output (that would be the header), sort|uniq catches non-mounted Filesystems, and the awk command extracts the columns for blocks and avail and sums them up.

Now Windows sees the "correct" size and usage of the share, and will hopefully be able to backup now.

samba filr

Trackback URL for this post:

http://pronweb.de/trackback/85

Informative. Suche nach

Informative. Suche nach Informationen für das neue Projekt pokern. Auch dachte ich nicht finden können - und dann hatte Glück - stieß auf Ihrer Website! Danke!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions. Once you passed the test, you wont be challenged anymore.
Type in the two words: