Friday, 10 August 2012

Disk quota



#rpm –qa quota
#vim /etc/fstab
Add the below line in the corresponding disk quota required partition after defaults.
usrquota,grpquota
Example: LABLE=/home                 /home    ext4        defaults,usrquota,grpquota               1 2
#save and close
Or
#mount –o remount,usrquota,grpquota,rw /home

#mount | grep home – checking for usrquota,grpquota successfully added or not.
#mount -o remount /home – use only if you use the fstab entry method mentioned above
#quotacheck -cugm /home
 
The options for quotacheck are
  • -c Performs a new scan.
  • -v Performs a verbose scan.
  • -u Scans for user quotas.
  • -g Scans for group quotas.
  • -m Remounts the scanned filesystem
 
This will check the current quota information for all users, groups, and partitions. It stores this information in the appropriate quota partitions. Once the command is run, you should be able to find the aquota.user and aquota.group files in the configured directory.
or you can create these files manually
#touch /home/aquota.group
#touch /home/aquota.user
#quotaon –avug          - turn on the quota
#useradd Vinita
#passwd Vinita
#edquota Vinita – this # will open the vim editior
#set soft link to 50 ( is = 50 kB)
#hard link to 100 (is = 100 kb)
!so now the user Vinita can able to create the file or use the space only for  100Kb
Blocks : The amount of space in 1k blocks the user is currently using
inodes : The number of files the user is currently using.
Soft Limit : The maximum blocks/inodes a quota user may have on a partition. The role of a soft limit changes if grace periods are used. When this occurs, the user is only warned that their soft limit has been exceeded. When the grace period expires, the user is barred from using additional disk space or files. When set to zero, limits are disabled.
Hard Limit : The maximum blocks/inodes a quota user may have on a partition when a grace period is set. Users may exceed a soft limit, but they can never exceed their hard limit.
#edquota –T Vinita – to set the grace period of user
#in block grace type 10 days
#mount –o remount,rw /home
#repquota –a – check the quota is implemented successfully or not.
Now login from Vinita and create the blank file with specified size
#dd if=/dev/zero of=/home/vinita/test bs=1024 count=50
#dd if=/dev/zero of=/home/vinita/test1 bs=1024 count=100
home# du –h tes*
When user vinita run dd command first time to create a blank file more then 50 Mb she got an warning and the file was created. As she is allowed to exceed her soft limit for 10 days.
Second time she tried to create a file of 500 Mb. As you can see in image she was able only to create a file of 20 Mb. As she can not exceed her hard limit that is set to 100 inode.
In third time she is denied to use any more space as she have already crossed her hard limit.
You can verify the space of created file by du command with -h options.
After successfully completing your practical remove quota entry /etc/fstab
#quotaoff –auvg     - turn off the quota
Soft Limit
Disk space a user can use
Hard limit
Absolute limit a user can use
Grace Periods
Time duration till user can use hard limit space
1 inode
1 KB
dd
used to create a blank file of specific size
required RPM
quota-3.13-1.2.3.2.el5
/etc/fstab options
usrquota, grpquota
Quota files
aquota.user, aquota.group
Necessary command
mount, quotaon, quotacheck, edquota, quotaoff



No comments:

Post a Comment