Configuration of disk usage quotas on Linux - Perform the following as root:
1. Edit file /etc/fstab to add qualifier "usrquota" or "grpquota" to the partition. The following file system mounting options can be specified in /etc/fstab
    * To enable user quota support on a file system, add "usrquota" to the fourth field containing the word "defaults".
          ...
          /dev/hda2     /home   ext3    defaults,usrquota              1    1
          ...
                   
    * Replace "usrquota" with "grpquota", should you need group quota support on a file system.
          ...
          /dev/hda2     /home   ext3    defaults,grpquota              1    1
          ...
                   
    * Need both user quota and group quota support on a file system?
          ...
          /dev/hda2     /home   ext3    defaults,usrquota,grpquota     1    1
          ...
                   
          This enables user and group quotas support on the /home file system. 
2. touch /partition/aquota.user
where the partition might be /home or some partition defined in /etc/fstab.
then
chmod 600 /partition/aquota.user
The file should be owned by root. Quotas may also be set for groups by using the file aquota.group 
3. Re-boot or re-mount file partition with quotas.
    * Re-boot: shutdown -r now
    * Re-mount partition: mount -o remount /partition
After re-booting or re-mounting the file system, the partition will show up in the list of mounted filesystems as having quotas. Check /etc/mtab:
    ...
    /dev/hda5 / ext3 rw,usrquota 0 0
    ...
         
4. quotacheck -vgum /partition
or
quotacheck -vguma 
 The options used are as follows:
    *      a — Check all quota-enabled, locally-mounted file systems
    *      v — Display verbose status information as the quota check proceeds
    *      u — Check user disk quota information
    *      g — Check group disk quota information 
5. quotaon -av
System Response: /dev/hda6: user quotas turned on
quotaon - enable disk quotas on a file system.
quotaoff - turn off disk quotas for a file system.
6. edquota -u user_id
Edit directly using vi editor commands. (See below for more info.)
For example: edquota -u user1
    * System Response (RH 7+):
      Disk quotas for user user1 (uid 501):
        Filesystem                   blocks       soft       hard     inodes     soft     hard
        /dev/hda5                      1944          0          0        120        0        0
            
          o blocks: 1k blocks
          o inodes: Number of entries in directory file
          o soft: Max number of blocks/inodes user may have on partition before warning is issued and grace persiod countdown begins.
            If set to "0" (zero) then no limit is enforced.
          o hard: Max number of blocks/inodes user may have on partition.
            If set to "0" (zero) then no limit is enforced.
If editing group quotas: edquota -g group_name
 To verify that the group quota has been set, use the command:
quota -g group_name
Also please note that quota is assigned in KB
7. List quotas:
quota -u user_id
For example: quota -u user1
System response:
Disk quotas for user user1 (uid 501):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/hda6     992   50000   55000              71   10000   11000
      
If this does not respond similar to the above, then restart the computer: shutdown -r now
Quota Reports:
    * Report on all users over quota limits: quota -q
    * Quota summary report: repquota -a
      *** Report for user quotas on device /dev/hda5
      Block grace time: 7days; Inode grace time: 7days
                              Block limits                File limits
      User            used    soft    hard  grace    used  soft  hard  grace
      ----------------------------------------------------------------------
      root      -- 4335200       0       0         181502     0     0
      bin       --   15644       0       0            101     0     0
      ...
      user1     --    1944       0       0            120     0     0
          
      No limits shown with this user as limits are set to 0.
Cron:
    Quotacheck should scan the file system via cronjob periodically (say, every week?). Add a script to the /etc/cron.weekly/ directory.
    File: /etc/cron.weekly/runQuotacheck
        * Linux Kernel 2.4: Red Hat 7.1 - Fedora Core 3:
              #!/bin/bash
              /sbin/quotacheck -vguma
        * Linux Kernel 2.2: Red Hat 6/7.0:
              #!/bin/bash
              /sbin/quotacheck -v -a
    (Remember to chmod +x /etc/cron.weekly/runQuotacheck)
Note: You can refer more details from the urls:
http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-disk-quotas.html
http://www.yolinux.com/TUTORIALS/LinuxTutorialQuotas.html
 
 
No comments:
Post a Comment