-2

Hope the question is not too general.

As I have a vserver (Ubuntu 12.04) I cannot restrict the size of directories by using quotas. I wonder if there are other possibilities to achieve this.

The only method I could imagine would be a combination of inotify + config-file where the maximum size is stated + command which, well, makes the file empty or removes it or something like this. It's not about restricting user directories but automatically written files like logfiles.
I know it's not the best way, but the only one I think would work. Do you have better ones?

32bitfloat
  • 253
  • 2
  • 3
  • 10

2 Answers2

4

This won't really scale well to lots of quotas, but one simple solution would be to simply create another filesystem that has the fixed size that you want.

If you don't have any spare block storage, then you could use a loopback device pointed to a sparse file. The sparse file will not consume storage until it is being used, but if you create a filesystem on top of that sparse file it will appear to have a fixed maximum amount of storage available. Growing/shrinking will be somewhat difficult though. The safest method will be to create a new sparse file + filesystem that is larger/smaller, then transfer the contents of the old file.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
3

If the issue is specifically log files, use a syslog daemon that supports specifying max filesize. I believe rsyslogd does that. If that's not possible, there are a number of logrotate programs that can rotate logs when they reach max filesize and keep a given number of logs only, so that the total size is kept within limits.

Jenny D
  • 27,780
  • 21
  • 75
  • 114