Disk Quota -- restricrting users as well as stopping Denial of Service Attacks
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
By tataiermail at 2007-06-21 03:52
DISK QUOTA
--------------------------------------------------------------------------------
USE
----------------------------
The quota package contains system administration tools for monitoring
and limiting user and or group disk usage per filesystem.
IMPLEMENTING QUOTA
----------------------------
Configure the Kernel with Quota support.
Install the quota package.
Edit /etc/fstab
Establish the quota files
Set quotas.
Turn on Quota checking.
Configuring the Kernel
----------------------
In order to support quotas, the kernel must have been compiled with CONFIG_QUOTA option enabled. Standard RHEL kernels include quota option.
Installing the Quota Package
-----------------------
Only one package is needed to enable Quota. That package is quota-<version>.rpm.
To get info on the package use :
rpm -qi quota.
the /etc/rc.d/rc.sysinit file performs the following steps when the systems is booted:
runs quotacheck on the root filesystem
runs quotacheck on all other local filesystems.
Turns on quota checking.
Revising /etc/fstab
-----------------------
to specify that the /home partition supports user and group disk quotas, revise its line as follows:
/dev/hda3 /home ext3 defaults, usrquota, grpquota 1 2
Once the partition options are revised, we must remount the partition. For example:
mount -o remount /home
Establishing the Quota files
-------------------------
After editing the fstab with quota entry, we must establish the quota files aquota.user and aquota.group in each such partition. Use the quotacheck command to do this.
quotacheck -avug
This command may require several minutes to complete its task of accumulating and storing a record of the disk space used by each user and group.
To avoid Denial of Service Attack the files should be readable and writable by root only.
Setting Quotas
--------------------------
To set quota for a user, issue the command
edquota -u user
where user is the login name of the user. The edquota command launches the defaulkt editor(specified by the $EDITOR env var)
Example:
Disk quotas for user sumanc (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/hdd2 944 0 0 110 0 0
To specify a limit, change the appropriate number, save the file, exit he editor. A limit of 0 means no limits.
To verify that the quota has been set, issue:
quota -u sumanc
Setting a Group Quota
To specify a group quota, issue:
edquota -g group
To verify, issue:
quota -g group
Setting the grace period
edquota -t
Setting quotas for Multiple Users
1.Issue the command:
edquota -p user # This establishes specified user a/c as a template.
2.Issue the command:
edquota -p user user1 user2 ....
Turning On Quota checking
Quota checking will be activated when the system reboots, but without reboot also we can turn on quota checking by issuing the following command:
quotaon -av # this command turns on both user and group quotas
quotaon -avu # this turns on only user quotas. Similarly quotaon -avg will group quota.
To turn off quotas, issue the command
quotaoff -av | quotaoff -avu | quotaoff -avg
Administering Quotas
-----------------------
once quotas are up & running, we can use the commands that report the status of quotas. To view the status of quotas for multiple users, issue the command:
repquota -a
Example:
[root@srv home]# repquota -a
*** Report for user quotas on device /dev/hdd2
Block grace time: 00:01; Inode grace time: 00:01
Block limits File limits
User used soft hard grace used soft hard grace
---------------------------------------------------------------------------------------
root -- 17640 0 0 4 0 0
sumanc -- 44 380 400 10 490 500
amitdas +- 484 380 400 7days 10 0 0
siddas -- 48 380 400 11 0 0
** Users in violating condition are flagged with a + sign.
QUOTA ON NFS SHARE
On a NFS exported directory, simply apply the desired limits to the local users that are mapped with the remote users.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.