From time to time you can run into storage issues where users are uncontrolled and they decide to use your storage as their own. There are several solutions for this problem and I’ll tell you the two of them. The first solution is to delete their account and brake their arms so they won’t be able to use computer at all. This solution is now always acceptable so you should check the second one…
I suppose that your users are located inside /home dir and that /home is a mounting point for user partition (separate partition). The first step is to install quota with
yum install quota
Edit /etc/fstab and add ,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 to the /home partition
# # /etc/fstab # Created by anaconda on Tue Apr 17 08:39:51 2012 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=34ccss6f-5e34-4bbc-9ccf-ceeee02aba48 / ext4 defaults 1 1 UUID=5e345306-3a4a-48c8-bbaa-3a8ffefa4979 /home ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2 UUID=69433540-fa75-4ae3-8726-755e4afe0776 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0
Then remount /home with
mount -o remount /home
After remounting you need now to run an initial quotacheck command which will analyse all files on the partition and creates the aquota.user and aquota.group files in the /home root. Please keep in mind that this operation could take hours if you have a lot of files.
and you will get something like
quotacheck: Scanning /dev/sda2 [/home] done quotacheck: Cannot stat old user quota file: No such file or directory quotacheck: Cannot stat old group quota file: No such file or directory quotacheck: Cannot stat old user quota file: No such file or directory quotacheck: Cannot stat old group quota file: No such file or directory quotacheck: Checked 131 directories and 865 files quotacheck: Old file not found. quotacheck: Old file not found.
which is Ok.
Activate the quota with
and you wil get
/dev/sda2 [/home]: group quotas turned on /dev/sda2 [/home]: user quotas turned on
To see which users uses what amount of space (blocks) and files (inodes) you can use repquota command.
The output will be similar like>
*** Report for user quotas on device /dev/sda2 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 24 0 0 3 0 0 user1 -- 32 0 0 8 0 0 user2 -- 43860472 0 0 135 0 0 user3 -- 91739332 0 0 795 0 0 user4 -- 32 0 0 8 0 0 user5 +- 1326272 10000 15000 7days 4090 0 0
To set user quota you can use command setquota
setquota -u user1 -F vfsv0 0 1000000 0 0 /dev/sda2
The numbers 0 1000000 0 0 will set up:
0 – no soft quota for block size
1000000 – 1000 MB hard quota
0 – no soft quota for file amount
0 – no hard quota for file amount
To edit user quota manually you can use command edquota
and you will get
Disk quotas for user user1 (uid 508): Filesystem blocks soft hard inodes soft hard /dev/sda2 1326272 0 1000000 4090 0 0
(press i to enable edit, change the values and press Esc. Then enter :wq! to save the changes)
To edit group quota enter
edquota -g GROUP
where the GROUP is specific group.