Disk Quota Management

A battle that most system administrators face is the task of disk space management.  Disk space is a finite resource that can be exploited by a few selfish users to the detriment of many.  Traditionally, a sysadmin would rely upon peer pressure or other non-enforceable means to keep disk usage down to reasonable levels, however with the advent of the Quota facility with Berkeley UNIX, it became possible for administrators to let the system place soft and hard limits that were enforced by the operating system itself.

The disk space problem is still a problem to machines running FTP service.  The easiest and most efficient way to enforce disk quotas on the FTP server machine is to enable them in the operating system, just as you would for a regular login account.  The big problems with this are that not all operating systems have quota support built-in, and for those that do, only real users listed in the /etc/passwd file can have them.  If your system has operating system quotas and you only allow logins from real users, you should use the existing quota system.  Otherwise, if your OS doesn't have quotas or you want virtual users to have a disk quota, you can use NcFTPd's built-in (as of version 2.5.0) support for quotas.


Performance considerations
Before you blindly skip to the section on how to enable NcFTPd's quotas, you must be aware that there is a price to pay in system performance when you use quotas.  Remember that NcFTPd quotas are not directly integrated with the kernel or filesystem itself, so it has to do quotas the hard way.  This means that a FTP user's quota must be calculated by iterating through the entire directory structure starting at that user's home directory.  In other words, NcFTPd needs to do the equivalent of a "du -k -s" on the user's home directory at some point.  This can take a long time if the user's directory structure is complex.

Naturally NcFTPd avoids doing that very system-intenstive calculation until it needs to.  Under normal circumstances, this calculation is not done until something that would increase disk usage would occur (these are: file uploads, directory creation, or symbolic link creation).  If you choose to display the quota status to the user, then this also causes the disk usage calculation to be done.  Therefore, you should resist the temptation to put the quota status in the login message, since that would mean that each and every login would cause the disk usage calculation to run, whether or not they do an upload.

Also think twice before using NcFTPd quotas over an NFS partition.  The disk usage calculation will be much slower than it already is on a local hard disk.

End-user considerations
If you use NcFTPd quotas, your users should be aware that there could be a significant delay during their session, which is directly related to how many files they have in their home directory tree.

They should also use an FTP client that displays the messages from the FTP server; otherwise when the user exceeds quota you'll get unnecessary calls because their uploads are failing but the client program did not bother to tell them that it got a "disk quota exceeded" message.

The users could also benefit from an FTP client that can issue the "SITE QUOTA" command to display their current disk usage.  Another way to let the user be aware of their quota is to put that information in the login message or logout message using special NcFTPd cookies in the message text (described later).  Again, this depends on the user having a client that displays this message!

The end result is that if you use quotas, you should tell the users how to check their FTP quota, and if they get errors related to uploading, that it could be because they have exceeded their quota.

NcFTPd quotas are really approximations.  NcFTPd does a disk usage calculation once per session and from then on, tracks changes it is aware of, such as uploads and deletions.  It is not aware of other filesystem activity going on the user's home directory.  Therefore, if the user also had a telnet session open and created a 5 megabyte file, the NcFTPd FTP session would not know to add 5 megabytes to the current disk usage.  Similarly if the user had two FTP sessions open to the server, each session only knows about the changes made in its session and so actual disk usage may vary from each session's calculations.

The user can simply close a FTP session and reconnect to get a more accurate quota calculation.

back home next