Is there any possibilities to restrict Samba user's to a maximum file size?

Ex, If a samba-user uploads a file onto the server that's more than 100 MB (like video or compressed files), Samba, or the system receiving the file, should not allow it.


So there is a solution.

Considering Samba share size = 10GB

If you want an user not to use more than 1GB then you can use user quota management as described here

Now as of your question, you need to restrict copy and paste of your samba users, then follow the steps here,

# vi /etc/security/limits.conf

Edit this configuration file and append like this to all user whom you need to restrict

savvy       hard  fsize  102400

So the samba user savvy cannot file transfer beyond 100MB. For the changes to take effect logout and log back in or restart your system.

  • 1
    Thanks for the replay, How about guest user ? I've enabled guest user on one of the share on Samba configuration. – Kumar Dec 17 '13 at 12:08
  • savvy hard fsize 102400 Change this line to guest hard fsize 102400 It would be great if you accept my answer and upvote as appreciating in this page. Thanks – Ruban Savvy Dec 17 '13 at 12:11
  • I've enabled these two things on my smb.conf, "public = yes, guest ok = yes". It'll create file with "nobody nogroup". So now how can I restrict with /etc/security/limits.conf ??? – Kumar Dec 17 '13 at 12:17
  • Same rule applies there, #cat /etc/passwd There you will see a user nobody, nobody hard fsize 102400 Will do the trick. ;) – Ruban Savvy Dec 17 '13 at 12:20
  • File restrict is not working with user nobady. how can I check whether limit applied or not, without copy a file ? – Kumar Dec 18 '13 at 9:26

It's an old post, but just in case someone stumbles on it it's good to know that Ruban Savvy's recipe doesn't work (anymore ?), so don't spend too much time on it. At least it's not working on Samba 4. I got a straight answer from the Samba team (the full discussion can be found on the Samba's February mailing list, https://lists.samba.org/archive/samba/2021-February.txt.gz, grep for "limits.conf" to get to the relevant mails)

If someone has an idea it would be great, but according to my research it's basically not possible to limit the size of individual files on a Samba share (nor is it possible on a Windows Server).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.