1

I have some programs on a server (Centos4-OpenVZ) that use a directory as temp directory - but pay no attention to the size as it grows.

I want to enforce a limit, such as that this folder cannot exceed 300MB.

I would use quota but OpenVZ does not support loop devices, that could be used to mount a file as a device.

Any other solutions? (Apart from scripting a periodic delete of files in the directory).

Editing the application's code to implement this functionality is not entirely out of the question (if it can be done easily and no other ways exist it's written in cpp) but I don't know where I would start if going that route.

random
  • 450
  • 1
  • 9
  • 16
George
  • 13
  • 3

2 Answers2

0

What about mounting the filesystem inside your OpenVZ environment using NFS? Then you can implement quotas on the NFS server (which may be the same machine running OpenVZ).

larsks
  • 43,623
  • 14
  • 121
  • 180
  • That's an intersting idea, hadn't thought of that. Looking now about how it can be done.. Not sure about the overhead of that solution though, running the nfs server on the same machine etc. It's one way to do it sure :) – George Jun 28 '11 at 02:19
0

You could use your idea of using loop devices, but you would need to mount them on the HN first like this:

losetup somefile
mount -t auto -o rw somefile /mnt/mpoint
mount -n --bind /mnt/mpoint /vz/private/101/opt

I'm not sure if you can use the vzquota command for a similar purpose. Maybe somebody who knows more about it can comment.

joechip
  • 668
  • 3
  • 6