Basic disk quota configuration
From Notes_Wiki
<yambe:breadcrumb>Configuring disk quota|Configuring disk quota</yambe:breadcrumb>
Basic disk quota configuration
To enable user quota on some filesystem follow these steps:
- Add option 'usrquota' in '/etc/fstab' of the partition on which you want to enable quota
- Then unmount the partition, if it is already mounted. Mount the partition and verify that option 'usrquota' got enabled.
- If you have edited /etc/fstab file for a mounted partition then you can use
mount -o remount <partition>
to remount the partition with 'usrquota' option. This is in case filesystem is in use and cannot be unmounted.
- If you have edited /etc/fstab file for a mounted partition then you can use
- Use command 'quotacheck -vcf -F vfsv0 /home' to create new quota file where '/home' is the mount point for the partition. This command will take time based on the size of the partition.
- Do not turn quotas on before doing this. It is also recommended that the filesystem should not be in use otherwise the values would be wrong. 'quotacheck' tries to make the filesystem read-only while it calculates quota, if that is not acceptable use '-m' option of quotacheck command, after understanding its implications.
- Then enable filesystem quota with
quotaon -av
so that quota is switched on for all 'filesystems' listed in '/etc/fstab' with 'usrquota' option. This step is very important, just re-mounting the partition and creating quota file is not enough for calculating/enforcing quota. - Use 'edquota -u <username>' to set quota. Current usage in blocks will be shown. Values are in kb. So you can set 100000 110000 as values for soft and hard blocks to set quota to 100MB-110MB.
Seeing quota
To see set quotas for all users we can use command
repquota -a
To see individual user quota we can use
edquota -u <username>
and see the value or we can also first `su - <username>' and then use 'quota' command.
Recalculating quota
If you feel quota is off the proper values and you want to force recalculation then
- First use 'quotaoff -av' to turn of quota for all filesystems with 'usrquota' option enabled.
- Then use 'quotacheck -vbf -F vfsv0 <mount_point>' if mounting filesystem and read-only is acceptable. If filesystem is in use then 'quotacheck -vbfm -F vfsv0 /home' command is better option.
- Here b is for backup and we omitted 'c' so that we do not loose current quota limits set manually using edquota.
- Then re-enable quota using 'quotaon -av' command.
Do not run quotacheck on filesystem when quotas are enabled (on).
Refer:
<yambe:breadcrumb>Configuring disk quota|Configuring disk quota</yambe:breadcrumb>