Like.. User john123, you can only use 100mb of my harddisk. User jake155, you can only use 250mb of my harddisk.
To restrict hard disk usage per user efficiently we could create a separate partition for each of the
/home directories. However then it's obviously not so easy to change the granted space or add new users.
We therefore may use fixed sized images as a container for the users
/home and mount these as loop devices (as root):
1 mkdir /media/users/ 2 dd if=/dev/zero of=/media/users/john123.img bs=512K count=200 3 mkfs.ext4 /media/users/john123.img 4 mkdir /home/john123
5 mount -o loop /media/users/john123.img /home/john123
After having done so we then create our user john123 who will now have 100 MB space available in his
Subsequently the loop devices will have to be mounted prior to login, e.g. by adding this to
6 /media/users/john123.img /home/john123 ext4 loop 0 2
The standard way to do it in UNIX is through the
quota command. It allows you to dynamically change how much disk space each user can use.
See the man page, or google for a tutorial.
The route to take may be to limit the size of a user's home directory, i.e. limit /home/jake155 to a certain size. Typically a non-admin user cannot access anything beyond their home directory unless you change permissions otherwise. This thread discusses multiple ways to do that.