Web Hosting Talk







View Full Version : Enable Quota Support for Plain Red Hat Linux


choon
01-17-2004, 12:05 AM
Hi everyone,

These are the steps I used to enable quota support for all my managed plain Red Hat Linux servers so that you can set user or/and group quota.

What is Quota?
Quoted from http://www.tldp.org/HOWTO/Quota-1.html#ss1.1

Quota allows you to specify limits on two aspects of disk storage: the number of inodes a user or a group of users may possess; and the number of disk blocks that may be allocated to a user or a group of users.

The idea behind quota is that users are forced to stay under their disk consumption limit, taking away their ability to consume unlimited disk space on a system. Quota is handled on a per user, per file system basis. If there is more than one file system which a user is expected to create files, then quota must be set for each file system separately. Various tools are available for you to administer and automate quota policies on your system.

Step 1: Gain root access to your server using SSH.

Step 2: Check whether the quota package is install or otherwise please install it before continue.
rpm -qa|grep quota

Step 3: Modify /etc/fstab file
Partitions that you have not yet enabled quota normally look something like:
/dev/hda5 /home ext3 default 1 2
To enable user quota support for that partition, simply add in usrquota next to default such as below:
/dev/hda5 /home ext3 default,usrquota 1 2
To enable group quota, just add grpquota.
To enable both user and group quotas, add in both usrquota,grpquota.

Step 4: Reboot or Not to Reboot.
Normally I won't reboot, you can try this command on the partition that you have modified or added in quota support:
mount -o remount /home

Step 5: Quota Check
/sbin/quotacheck -cguvamf -F vfsv0

Step 6: Rerun Quota Check for old version
/sbin/quotacheck -cguvamf -F vfsold

Step 7: Turn on Quotas
/sbin/quotaon -a

To see the report of quotas, issue this command:
repquota -a

To set a user quota, issue the following command:
setquota -u USERNAME SOFTQUOTA HARDQUOTA SOFTFILELIMIT HARDFILELIMIT -a
Where:
USERNAME is the user
SOFTQUOTA in kilobytes
HARDQUOTA in kilobytes
SOFTFILELIMIT set it to 0 normally
HARDFILELIMIT set it to 0 also

You are done :o)

References:
Quota mini-HOWTO (http://www.tldp.org/HOWTO/Quota.html)

Thanks.

Kindest regards,
Choon

BP Steven
01-17-2004, 01:28 AM
Nice howto, however you may want to explain what quota does in the intro as I'm sure there will be newbies who don't know what it does.

choon
01-17-2004, 01:32 AM
Thanks for your feedback and I can't edit my post but those newbies will have a reference URL in my post that they can read the Quota Intro.

Once again, thanks.

Knogle
01-17-2004, 06:36 AM
choon, report your post to a CL, and state the update you want to make. We can do it for you. :)

<edit>signature removed</edit>

propcgamer
01-17-2004, 10:59 PM
Nice guide! Thanks!

<edit>signature removed</edit>

LynxPrime
04-03-2004, 04:40 PM
i needed that haha thx

<edit>signature removed</edit>

hostchamp
06-08-2004, 01:34 PM
worked for me, thanks!

hostchamp
06-08-2004, 02:25 PM
when i do repquota -a it shows me one of the user using 11600 blocks (i.e. 11.6Mb) whereas when i do a du -sk inside the user's home directory it shows 17Mb disk space used.

Why does the repqota doesn't match the actual disk usage?

I also did /sbin/quotacheck -avug still the results are the same.

heislyc
08-01-2005, 09:47 AM
Originally posted by choon
Thanks for your feedback and I can't edit my post but those newbies will have a reference URL in my post that they can read the Quota Intro.

Once again, thanks.

Choon,
Its not working for me, How? Everyone, i need serious help for the mail server quota setup. I've followed every steps in man How-To, but still, the quota i've set(edquota) for any user couldn't take effect while the user login into his mail box. The mail box limit wasn't updated according to the aquota.user. Is that possible the problem with my Sendmail? How to rectify this?

choon
08-01-2005, 02:47 PM
Originally posted by hostchamp
when i do repquota -a it shows me one of the user using 11600 blocks (i.e. 11.6Mb) whereas when i do a du -sk inside the user's home directory it shows 17Mb disk space used.

Why does the repqota doesn't match the actual disk usage?

I also did /sbin/quotacheck -avug still the results are the same.
Did you check for ownership in the user home directory? Are all the files in it owned by that user?

choon
08-01-2005, 02:59 PM
Originally posted by heislyc
Choon,
Its not working for me, How? Everyone, i need serious help for the mail server quota setup. I've followed every steps in man How-To, but still, the quota i've set(edquota) for any user couldn't take effect while the user login into his mail box. The mail box limit wasn't updated according to the aquota.user. Is that possible the problem with my Sendmail? How to rectify this?
Show me output of the following commands:
cat /etc/fstab
mount
And your MTA is sendmail which those mailboxes are in /var/spool/mail directory ? You might want to see the location of the user mailbox and its ownership... ... mailbox quota is different from system user quota though... ...

heislyc
08-01-2005, 09:52 PM
Originally posted by choon
Show me output of the following commands:
cat /etc/fstab
mount

cat /etc/fstab:
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
LABEL=/home /home ext3 defaults,usrquota,grpquota 1 1
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
/dev/sda8 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0

mount:
/dev/sda6 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda2 on /home type ext3 (rw,usrquota,grpquota)
none on /dev/shm type tmpfs (rw)
/dev/sda7 on /tmp type ext3 (rw)
/dev/sda5 on /usr type ext3 (rw)
/dev/sda3 on /var type ext3 (rw)


And your MTA is sendmail which those mailboxes are in /var/spool/mail directory ? You might want to see the location of the user mailbox and its ownership... ... mailbox quota is different from system user quota though... ...

Yes, /var/spool/mail. The location of user mailbox is located at /home/<user>. Shall i make sure all <user>'s file and group ownership is <user>? or some <user>, some mail group?

I found ..../openwebmail/etc/users.conf/ What is the correct ownership and mod for these <user> config files? and what's the correct ownership and mod for users.conf directory? How to make edquota able to edit the users.conf/<user> files?

choon
08-01-2005, 10:32 PM
If each user real mailbox are stored in /var/spool/mail directory and /home/<user>/mail/mailbox is a symlink to /var/spool/mail/<user>-mailbox... then you need to enable quota support for your /var partition. If it is the other way, then you don't need to but it is a good idea to enable it though.

User quota support is only taken those files owned by their respective user in the partition that you enable usrquota support. Likewise for grpquota is only taken those files which are owned by the <group>. Whereby for anything related to your mail/MTA setting/configuration is going a bit off-topic... ...

heislyc
08-01-2005, 11:49 PM
Can anyone tell me the default permission/ownership settings for /openwebmail/*?

hostchamp
08-02-2005, 04:52 PM
Choon is my /etc/fstab setup correctly to support quota?

---------------------------------------------------------------------------
/dev/hda2 / ext3 grpquota,usrquota,dev,suid,exec 0 1
/dev/hda1 /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
#/dev/hdc5 /mnt/oldbackup ext2 noauto 0 3
#/dev/hdd2 /mnt/oldprimary ext3 noauto 0 0

choon
08-05-2005, 01:08 AM
hostchamp, from your /etc/fstab it is but did you enable quota? Issue mount command and check whether did you see any usrquota on partition / ;)

hostchamp
08-11-2005, 08:23 PM
Originally posted by choon
hostchamp, from your /etc/fstab it is but did you enable quota? Issue mount command and check whether did you see any usrquota on partition / ;)

Quota is enabled and i am using it currently. To my surprise many of my user quota settings disappered and were reset to 0 (unlimited) all by itself.?? I have no idea how/why this happened?