I have a complex setup with two systems running on two computers with shared space.

One of the systems downloads large files and creates symlinks in the shared space. The other system (a windows system) thinks that there is not space left.

What I would like to do is to limit the size of files in one folder in linux. In other words, the directory (and sub-directories) will only contain files up to say 1MB. Anything larger than that will be disregarded. Can that be done?


  • You already have a process that creates the symlinks from the downloaded files to the directory. Can't you modify that process so that it doesn't create a link if the filesize is too large?
    – cjc
    Nov 6, 2012 at 20:42

3 Answers 3


I'm affraid that it's possible to set the maximum file size limit for the whole system only (for each and every file).

ulimit -f <size_in_blocks>

You might also limit the total size of a directory by mounting the directory from the virtual filesystem (a file):

dd if=/dev/zero of=~/disk_image count=<size_in_blocks>
mkfs -t ext3 ~/disk_image
mount -o loop=/dev/loop0 ~/disk_image <directory>

Another method I thought of would be to schedule a cronjob to run on the linux machine every minute or at an interval of your choosing that executes a script that looks for any files greater than 1M and either removes them or moves them to another directory for review.

For the script, look into using 'find'

man find

An example:

find /home/user/storage -type f -size +1M

This would look through the /home/user/storage directory and locate files greater than 1MB. You can also add -exec to the line to perform actions on the files found.

  • 3
    Instead of doing that, you may want to consider inotify, particularly the incrontab facility. It will watch the directory for I/O, so no need for a messy cron job.
    – cjc
    Nov 6, 2012 at 20:40
  • That's not a bad idea either cjc, I should have thought of that :)
    – bmurtagh
    Nov 6, 2012 at 22:49

You can use a product called quota it seems to be preinstalled on Red Hat.

check the following links

http://souptonuts.sourceforge.net/quota_tutorial.html http://www.yolinux.com/TUTORIALS/LinuxTutorialQuotas.html

I have never actually administered this myself, however I have worked on systems that have had this installed and it seems to work.

Let me know how you get along


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.