Jail diskspace management
From FBSD_tips
Contents |
[edit] Managing diskspace for jails
One of the main problems with hosting a jail for any reason be it for your friends or in a serious commercial capacity such as webhosting, is that limiting diskspace seems impossible given the nature of a standard jail. In this short bsdtip I shall provide you with 4 ways to 'lock down' on jail disk space all with their relevent pro's and cons.
[edit] The Four Ways of the Dragon (daniel-san...paint da fence)
[edit] The way of the MD (and thats not Medical Degree)
Ok the most common you see now days is mounting your jail in a File Backed Memory Disk (MD), This is effective but here are its pro's and cons:
- Pro's
- User are restricted to a size preset by you.
- The jail can be resized in two ways
- It is fast and easy to do
- Con's
- To add space to the users MD on / (increase the entire image) the jail must be stopped entirely and unmounted.
- To add space dynamically to another directory, lets say for instance /mnt/morespace you will need to create another MD image.
- There is a harddisk performance loss with this variety of restriction. (Assumed around 10% on large files)
[edit] The way of the slice (Stop thinking of cake)
The next way to restrict a jail is by using real partitions, this works by creation a solid (lets say 10GB) slice on your hard disk formatting it and tellnig the jail to use that. Once again here are the pro's and con's:
- Pro's
- No hard disk performance loss
- Fast and easy to do IF the server in question has a hard disk especially for jails OR has unpartition space.
- Con's
- If you wish to resize it may not be possible if other jails are placed on the same disk (no room to expand)
- You have to play around with your partition table while your OS is running which is generally not recommended.
[edit] The way of the trusting (The minority)
The third and most common way of restricting disk size is not really to restrict it at all, simply watch the mounted jails size and once it hits 9G (when the user has 10G) you send them an email reminding them about space. The joy of this is if they go over it you can charge them more, the negative effect of course is that if they REALLY go over it then can fill the hard disk and really cause you some problems..
- Pro's
- Truelly Dynamic
- No Overheads except the moinitoring daemon
- Con's
- No real restriction
- Can run the system out of diskspace with 'not so trustworthy' users.
[edit] The way of the ZFS (Into the Unknown with a stick of RAM)
The last method is to use ZFS, which has 'per directory' quota support, so far I have not had chance to test this one personally, someone pointed it out to me while I was writing the article :) here is its documentation: docs.sun.com ZFS Quota Documentation
- Pro's
- Simple to setup
- High performance
- Dynamically adjustable
- Con's
- ZFS overhead
- Quite untested

