Implement and Manage Disk Quotas in Linux

A disk quota is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems.Disk quotas are very useful in large multi-user environments where you have a large number of users with access to the filesystem, whether because they log into the system or use their file space remotely, through either Samba or NFS.This is very useful if you are an Internet service provider (ISP) providing web space for your users to host their websites.

Debian supports BSD-style disk quotas on the ext2 filesystem. This allows you to limit the amount of disk space that your users consume. QUOTA is implemented using the BSD system call interface as the means of communication with the user level. This is based on the Melbourne quota system which uses both user and group quota files.

Installing Quota in debian

#apt-get install quota quotatool

At the time of installation time it will prompt the following questions

send daily remainders to users over quota with the following screen here select yes and press enter

Email Remainder enable

next screen you need to enter the support email of the admin select ok and press enter

Enter your  admin email address

Here you need to enter the phone support number of the admin select ok and press enter.

Admin phone number

This will complete the quota installation.

Configuring Disk Quotas

Edit /etc/fstab to look like this (I added ,usrquota,grpquota to the partition with the mount point /):

# /etc/fstab: static file system information.



proc /proc proc defaults 0 0

/dev/sda1 / ext3 defaults,errors=remount-ro,usrquota,grpquota 0 1

/dev/sda5 none swap sw 0 0

/dev/hdc /media/cdrom0 iso9660 ro,user,noauto 0 0

/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0

Now you need to Enable quota for this you need to run the following commands

#touch /quota.user /

#chmod 600 /quota.*

#mount -o remount /

When each quota-enabled file system is remounted, the system is now capable of working with disk quotas. However, the
file system itself is not yet ready to support quotas. To do this, you must first run quotacheck.

The quotacheck command examines quota-enabled file systems, building a table of the current disk usage for each one.
This table is then used to update the operating system’s copy of disk usage. In addition, the file system’s disk quota files are updated (or created, if they do not already exist).

#quotacheck -avugm

Check all quota-enabled, locally-mounted file systems (-a)

Display status information as the quota check proceeds (-v)

Check user disk quota information (-u)

Check group disk quota information (-g)

Don’t try to remount filesystem read-only (-m)

Now you need to run quotaon command.quotaon announces to the system that disk quotas should be enabled on one or more filesystems.

#quotaon –avug

Force all filesystems in /etc/fstab to have their quotas disabled (-a)

Display a message for each filesystem affected (-v)

Manipulate user quotas (-u)

Manipulate group quotas (-g)

If you want to manage quotas with graphical webinterface you need to install quota webmin module.

Before installing webmin module make sure that you have installed webmin in your server.If you don’t have webmin installed in your server follow this article to install.

To Install webmin module for quotas run the following command

#apt-get install webmin-quota

Now you login in to the webmin and you can see quota configuration

check Warnquota is configured or not

– email warnings are triggered by warnquota
– warnquota takes its configuration in /etc/warnquota.conf
– warnquota is ran daily by default : /etc/cron.daily/quota

Here is my /etc/warnquota.conf

MAIL_CMD = “/usr/sbin/sendmail -t”
FROM = “[email protected]
SUBJECT = You have exceeded your quota
CC_TO = “[email protected]
SUPPORT = “[email protected]
PHONE = “01 02 03 04 05”
MESSAGE = “quota exceed for this user”
SIGNATURE = “Your signature”

Try dpkg-reconfigure -plow quota, it should ask you questions about warnquota configuration.

BTW, if your use of quota is critical, test it before production or with a test account by lowering quota to a very small level and by running manually /etc/cron.daily/quota.

Sponsored Link

Leave a comment

Your email address will not be published. Required fields are marked *