if you are interested to contribute your LAB PROGRAM Please send mail to jkumaron@gmail.com

How To Set Userquota Disk quota Redhat Linux Rhel5

Linux RedHat we can set the Maximum amount of disk space for every separate user Using Quota file aquota.user aquota.group. These quota file are located in the /home directory.Because every user directory located in the /home folder. Disk quota limit it set by the
we can set Limit in Two ways.
SOFT LIMIT >> after user reaches the Soft Limit it will give the warning.Soft Limit act as grace period or border limit. It will give only warning Even though it will write into disk.
HARD LIMIT >> While user reach the Hard Limit . User will not write or store any data in the partition.

usrquota for creating quota for user
grpquota for creating quota for group
mount the home directory and set defaults,usrquota,grpquota
[root@rhel5 ~]# vi /etc/fstab
/dev/vg1/data /home ext3 defaults,usrquota,grpquota 0 0
Remount the Home directory >> It is very important step
If you remount then only the quota file usrquota is located in the home directory.
[root@rhel5 ~]# mount -o remount /home
After remount the Home directory user quota and group quota has been created

Using quotacheck command we can check the quota
[root@rhel5 ~]# quotacheck -cf /home
-c for scan disk
-f force to check
And there file has been located in the home directory.
[root@rhel5 ~]# cd /home/
[root@rhel5 home]# ls
aquota.group  aquota.user
Using these file we can confirm the quto has been created succefully.

Edit Disk Quota For User

[root@rhel5 home]# edquota -u bashscript
edquota command is used to edit the user qutoa bashscript.
-u edit the user quota
-g edit the group quota
Starting stage
Disk quotas for user bashscript (uid 500):
Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg0-lv0               4          0          0          4        0        0

After I Edit the Hard Limit and Soft Limit 
Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg0-lv0               4          24         44        4        0        0
Now I am allowing only 40 blocks to write into the disk.
Default in the system it has 4 blocks .
Now I set it will give the warning message while it will reaches the 24 (20+4)blocks and
it will stop the writing the data block when it  reaches the 44(40+4) blocks.
[root@rhel5 ~]# repquota -a
*** Report for user quotas on device /dev/mapper/vg0-lv0
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
root      --    1138       0       0              4     0     0       
bashscript +-      4      24      44  6days      15     0     0 
b>Verification Method
Note : Login us the Bash script user
su - bashscript     How to set userquota Redhat Linux Rhel5 Disk quota
DD Linux Command Tutorial
[bashscript@rhel5 ~]$ dd if=/dev/zero of=/home/bashscript/checkquota bs=1024 count=10 [10]
10+0 records in
10+0 records out
10240 bytes (10 kB) copied, 0.00159895 seconds, 6.4 MB/s
[bashscript@rhel5 ~]$ dd if=/dev/zero of=/home/bashscript/checkquota1 bs=1024 count=10 [10+10=20]
There is no issue For creating upto 20 Kilo bytes
[bashscript@rhel5 ~]$ dd if=/dev/zero of=/home/bashscript/checkquota2 bs=1024 count=10 [20+10=30]
dm-0: warning, user block quota exceeded.
After that while we are creating the block it will give the warning message .
“warning, user block quota exceeded.”
[bashscript@rhel5 ~]$ dd if=/dev/zero of=/home/bashscript/checkquota3 bs=1024 count=10 [30+10=40]
[bashscript@rhel5 ~]$ dd if=/dev/zero of=/home/bashscript/checkquota4 bs=1024 count=10 [40+10=50]
dm-0: write failed, user block limit reached.
dd: writing `/home/bashscript/checkquota4': Disk quota exceeded
Finally it will give the failed message to write into the disk
List of command for userquota
quotacheck  -cf
eduqota -u
repquota -a
Managing Disk quota user quota

Related post