Disk QuoTa
ext4
https://www.linuxtechi.com/enable-user-group-disk-quota-on-centos-7-rhel-7/
RPM
yum -y install quota*
yum install xfsprogs xfsdump -y
yum install xfsprogs-devel xfsprogs-qa-devel -y
------------centos 6---------------
Change it
## UUID=d65e7b25-3d16-4cb7-9999-51d22ca212ca /boot ext4 defaults 0 2 [ ADD 1 ]
# vi /etc/fstab
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_mail-lv_root / ext4 defaults 1 1
UUID=d65e7b25-3d16-4cb7-9999-51d22ca212ca /boot ext4 defaults 1 2
/dev/vg_mail/lv_home /home ext4 grpquota,usrquota 0 1
/dev/mapper/vg_mail-lv_swap 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
-------------------------------------------------
/dev/vg_mail/lv_root / ext4 grpquota,usrquota 0 1
UUID=d65e7b25-3d16-4cb7-9999-51d22ca212ca /boot ext4 defaults 1 2
/dev/vg_mail/lv_home /home ext4 grpquota,usrquota 0 1
/dev/mapper/vg_mail-lv_swap 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
----------------------------------------------
#
/dev/vg_mail/lv_root / ext4 grpquota,usrquota 0 1
UUID=a7fea8ee-f8f9-4a36-b456-ef67f96ae6e9 /boot ext4 defaults 1 2
UUID=CC1E-6CEC /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/vg_mail-lv_swap 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
~
------------------------------------------------------------------
#### change UUID=172285b1-b31b-4f3d-9a70-bbae5fffe2c1 /boot ext4 usrquota,grpquota 0 2 [ remove 0 & add 1]
#
/dev/vg_mail/lv_root / ext4 grpquota,usrquota 0 1
UUID=172285b1-b31b-4f3d-9a70-bbae5fffe2c1 /boot ext4 usrquota,grpquota 1 2
/dev/mapper/vg_mail-lv_swap 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
~
---------------------------------------------------------------------------------
Step:4 Assign user & group disk quota via edquota commands
Syntax # edquota -u <User_Name>
# edquota -g <Group_Name>
[root@linuxtechi ~]# edquota -u accesstel
ls -l /home/
Step:5 Display Quota report for Users in human readable
# repquota -as
Step:6 Configure Grace Period for Soft Limit
# edquota -t
Initial quota check on Linux filesystem using quotacheck
# quotacheck -avug
Display Quota report for Users in human readable
# repquota -as
repquota -a
user quotas turned on
# quotaon -avug
# quotaon -amvug
command announces to the system that disk quotas should be enabled on the desired file system.
# quotaon /
turn off disk quota checking, thus disabling the quotas for the different users and groups.
# quotaoff
# show status
[root@dlp ~]# quotaon -ap
group quota on /home (/dev/sdb1) is on
user quota on /home (/dev/sdb1) is on
5. Add quotacheck to daily cron job
# cat /etc/cron.daily/quotacheck
quotacheck -avug
----------to send warnings to use Warnquota.-------------------------
yum -y install quota-warnquota
# df -h
# vi /etc/quotatab
# add device and description which quota is set
/dev/mapper/centos-root: Your Home Director
# change domain name to your own one
[root@ ~]# sed -i -e "s/example\.net/worldcm\.net/g" /etc/warnquota.conf
# vi /etc/warnquota.conf
8 FROM = "root@example.com"
11 CC_TO = "root@example.com"
16 SUPPORT = "root@example.com"
24 MESSAGE = Your disk usage has exceeded the agreed limits\Mailbox is full
28 SIGNATURE = root@example.com
# run warnquota
[root@dlp ~]# warnquota -s
# if a user is over the limit when warnquota runs, following warning is sent
From root@mail.worldcm.net Thu Oct 20 19:08:08 2015
Return-Path: <root@mail.worldcm.net>
X-Original-To: cent
Delivered-To: cent@mail.worldcm.net
From: root@mail.worldcm.net
Reply-To: root@mail.worldcm.net
Subject: NOTE: You are exceeding your allocated disk space limits
To: cent@mail.worldcm.net
Cc: root@mail.worldcm.net
Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline
Date: Thu, 20 Oct 2015 19:08:08 +0900 (JST)
Status: R
Your disk usage has exceeded the agreed limits on this server
Please delete any unnecessary files on following filesystems:
Your Home Directory (/dev/sdb1)
Block limits File limits
Filesystem used soft hard grace used soft hard grace
/dev/sdb1 +- 4112M 4096M 5120M 6days 6 0 0
root@mail.worldcm.net
------------------------------------Centos 7-------------------------------------------------------
XFS quotas
# umount /home
# umount /
# mount -o uquota,gquota /dev/mapper/centos-root /
-
[root@mail ~]# vi /etc/fstab
---------- --------------------------------
#
# /etc/fstab
# Created by anaconda on Mon Apr 17 17:02:43 2017
#
# 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
#
/dev/mapper/centos-root / ext4 usrquota,grpquota 0 1
UUID=5c37ec49-dd94-4819-b659-3f6d3b9d3b6b /boot ext4 defaults 0 2
UUID=0C69-C820 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
-----------------------------------------------------------
[root@mail ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Apr 6 18:25:48 2016
#
# 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
#
/dev/centos/root / xfs grpquota,usrquota 0 1
UUID=6fc18528-c6bd-4d0b-aa1f-00060e412c4f /boot xfs grpquota,usrquota 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
---------------------------------------------------------------------------------------
CentOS-7
# yum -y install quota*
[root@mail ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
[root@mail ~]# cp /etc/default/grub /etc/default/grub.BK
[root@mail ~]# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet rootflags=uquota,pquota"
GRUB_DISABLE_RECOVERY="true"
[root@mail ~]# cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
[root@mail ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
**The path on some OSs has been changed to E F I [ EFI BOOT ] **
# /boot/efi/EFI/centos/grub.cfg
[root@mail ~]# cp /boot/efi/EFI/centos/grub.cfg /boot/efi/EFI/centos/grub.cfg.org
[root@mail ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
# reboot
[root@mail ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,prjquota)
Then Go to webmin----->
1. Disk and Network --->/ (Root filesystem) or home ---> Enable user & groups quotas ---> save
2. Disk Quotas ---->/ (users) / (groups) ---> ok
------------------------------
---------------https://help.directadmin.com/item.php?id=557
Disk Usage is show
# /usr/sbin/repquota /home OR /usr/sbin/repquota /
Setting up quotas on an XFS partition
Last Modified: Jun 25, 2017, 12:00 pm
The xfs file system is different than the previous ext3/ext4 file systems.
This guide will be closely related to the standard quota setup guide, except that xfs may have a few extra steps that require more manual intervention.
If you need quotas setup on the /home partition, then the guide should be very similar to the standard quota setup guide. However, if you need quotas setup on /, where / uses use an XFS partition (/home is only a directory under /), then extra steps are required.
As well, we replace the grpquota with pquota (project quotas), which will allow DA to setup directoy quotas, for things like enforcement of per-domain disk quotas.
To confirm what setup you have, run the df commmand, eg:
[root@es7-64 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 2.3G 12G 17% /
devtmpfs 915M 0 915M 0% /dev
tmpfs 921M 24K 921M 1% /dev/shm
tmpfs 921M 8.5M 912M 1% /run
tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/sda1 497M 125M 372M 26% /boot
[root@es7-64 ~]#
as you can see, /home is not a partition, so it falls under the / partition, so we must ensure that quotas are functional on the / partition.
0) Next confirm that / is actually using the xfs file system:
[root@es7-64 ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
[root@es7-64 ~]#
if you see the "noquota" option, then you need to go to step 1, below.
If you don't see noquota, then you should be able to follow the standard quota setup guide, but adding uquota,pquota to the /etc/fsab, after the default option.
If you see "noquota" in the xfs mount options for the / partition
1) Because "noquota" is a default kernel mounting option, we must change it in the kernel boot options.
Edit the file:
vi /etc/default/grub
2) Find the line with the variable "GRUB_CMDLINE_LINUX", that might look like this (it may not look exactly the same, don't worry):
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet"
3) We're going to take the mount options that we found from step 0), and add them to the end of the line.
- We're going to put them after a "rootflags=" variable.
- Add uquota,pquota.
It might look something like this:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=uquota,pquota"
4) Now, based on that setup, we'll backup, then create a new grub.cfg file:
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
grub2-mkconfig -o /boot/grub2/grub.cfg
The path on some OSs has been changed to
/boot/efi/EFI/centos/grub.cfg
5) Lastly, we must reboot the box in order for the kernel to see these new options
reboot
6) We keep our fingers crossed that the box comes back, and login again. Go back to step 0) to check the mounting options to ensure that "noquota" is gone, eg:
[root@es7-64 ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,prjquota)
[root@es7-64 ~]#
Once it's gone, we want to see usrquota,prjquota(or uquota,pquota, they're the same thing).
If you don't see, them, then add them to the / partition with the standard quota setup guide.
7) Ensure that DirectAdmin has xfs quotas enabled in the directadmin.conf:
cd /usr/local/directadmin
./directadmin c | grep use_xfs_quota
8) If there are already Users created in DA, then you'll also want to reset their quota limits:
echo "action=rewrite&value=quota" >> /usr/local/directadmin/data/task.queue
to ensure their upper disk usage limits are enforced.
vi /etc/default/grub
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet" # original File
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=uquota,pquota" # Edit file
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_el7/root vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos_el7/swap crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=usrquota,grpquota"
-------------
Enabling Quotas in CentOS7
http://www.interworx.com/support/faq/enabling-quotas-centos7/
The release of EL7 marks the shift from Ext4 to XFS as the default filesystem for RHEL-based distros like CentOS. While XFS brings many improvements and features to the OS, user and group quotas are no longer enabled by default on the root (‘/’) partition.
While quotas are an optional feature, they are recommended to get the full InterWorx experience. Follow these steps from the command line to enable quotas:
First, check if quotas are enabled:
mount | grep ' / '
You should see ‘noquota’ if quotas are disabled, for example:
# /dev/mapper/centos_el7-root on / type xfs (rw,relatime,attr2,inode64,noquota)
Next, edit /etc/default/grub:
vi /etc/default/grub Find the line beginning with GRUB_CMDLINE_LINUX and append the following:
rootflags=usrquota,grpquota
The line should end up looking something like this:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_el7/root vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos_el7/swap crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=usrquota,grpquota"
Backup the grub configuration:
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
For servers using EFI, the grub.cfg file is listed here: /boot/efi/EFI/centos/grub.cfg
Generate the new grub configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
For EFI, use this command: grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Reboot:
reboot
Verify success:
mount | grep ' / '
You should see quotas are now enabled:
/dev/mapper/centos_el7-root on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
ERROR
Disk Usage is show
# /usr/sbin/repquota /home OR /usr/sbin/repquota /
If the "used" column is not showing anything, or users are not in the list, then you'll need to run the quotacheck program:
# /sbin/quotaoff -a; /sbin/quotacheck -avugm; /sbin/quotaon -a;
Enable Additional Repositories And Install Some Software
https://www.howtoforge.com/tutorial/perfect-server-centos-7-1-apache-mysql-php-pureftpd-postfix-dovecot-and-ispconfig3/
First we import the GPG keys for software packages:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
Then we enable the EPEL repository on our CentOS system as lots of the packages that we are going to install in the course of this tutorial are not available in the official CentOS 7 repository:
yum -y install epel-release
yum -y install yum-priorities
Edit /etc/yum.repos.d/epel.repo...
nano /etc/yum.repos.d/epel.repo
... and add the line priority=10 to the [epel] section:
[epel] name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 priority=10 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [...]
Then we update our existing packages on the system:
yum update
Now we install some software packages that are needed later on:
yum -y groupinstall 'Development Tools'
7 Quota
(If you have chosen a different partitioning scheme than I did, you must adjust this chapter so that quota applies to the partitions where you need it.)
To install quota, we run this command:
yum -y install quota
Now we check if quota is already enabled for the filesystem where the website (/var/www) and maildir data (var/vmail) is stored. In this example setup, I have one big root partition, so I search for ' / ':
mount | grep ' / '
[root@server1 ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
[root@server1 ~]#
If you have a separate /var partition, then use:
mount | grep ' /var '
instead. If the line contains the word "noquota", then proceed with the following steps to enable quota.
Enabling quota on the / (root) partition
Normally you would enable quota in the /etc/fstab file, but if the filesystem is the root filesystem "/", then quota has to be enabled by a boot parameter of the Linux Kernel.
Edit the grub configuration file:
nano /etc/default/grub
search fole the line that starts with GRUB_CMDLINE_LINUX and add rootflags=uquota,gquota to the commandline parameters so that the resulting line looks like this:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=uquota,gquota"
and apply the changes by running the following command.
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg_bak
grub2-mkconfig -o /boot/grub2/grub.cfg
and reboot the server.
reboot
Now check if quota is enabled:
mount | grep ' / '
[root@server1 ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
[root@server1 ~]#
When quota is active, we can see "usrquota,grpquota" in the mount option list.
Enabling quota on a separate /var partition
If you have a separate /var partition, then edit /etc/fstab and add ,uquota,gquota to the / partition (/dev/mapper/centos-var):
nano /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Sep 21 16:33:45 2014
#
# 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
#
/dev/mapper/centos-root / xfs defaults 1 1
/dev/mapper/centos-var /var xfs defaults,uquota,gquota 1 2
UUID=9ac06939-7e43-4efd-957a-486775edd7b4 /boot xfs defaults 1 3
/dev/mapper/centos-swap swap swap defaults 0 0
Then run
mount -o remount /var
quotacheck -avugm
quotaon -avug
to enable quota. When you get a error that there is no oartition with quota enabled, then reboot the server before you proceed.
----------------------------------
---