LINUX-17 DISK
QUOTA ON “XFS” (RHEL-7)
A way to limit the users to eat disk space.
Quota can be implemented on behalf of,
·
Block size: limit by block size
·
Inode no: limit by inode/no of files
Limit is also differentiated in,
·
Soft Limit: For warnings, it’s like a
barrier means if you jump the
Barrier you will be notified about the jumping
incident.
·
Hard Limit: No way, you jumped the barrier
and we notified about your daredevil act. Now we can not allow you to cross
the limits.
XFS quotas are enabled as filesystem mount options when the
filesystem is mounted.
User, Group and Project quotas are enabled independently.
Each quota type can be specified as noenforce, in this case quota
reporting will be maintained but not enforced.
Valid mount options are
Mount Options Description
uquota Enable
user quotas and enforce usage limits.
gquota Enable
group quotas and enforce usage limits.
pquota Enable
project quotas and enforce usage limits.
uqnoenforce Enable
user quotas. Report usage, but do not enforce
usage limits.
gqnoenforce Enable
group quotas. Report usage, but do not enforce
usage limits.
pqnoenforce Enable
project quotas. Report usage, but do not enforce
usage limits.
Once quotas are enabled, the xfs_quota tool can be used to set limits
and report on disk usage
xfs_quota has two modes of operation, basic and expert
mode
Basic mode includes commands for reporting disk usage to users.
Expert mode (xfs_quota -x) contains advanced commands that allow the
modification of the quota system.
BASIC MODE…………………………………..
[root@rhel7-server ~]# xfs_quota
xfs_quota> help
df [-bir] [-hn] [-f file] -- show free and used counts for blocks and
inodes
help [command] -- help for one or all commands
print -- list known mount points and projects
quit -- exit the program
quota [-bir] [-gpu] [-hnNv] [-f file] [id|name]... -- show usage and
limits
Use 'help commandname' for extended help.
xfs_quota> df
Filesystem 1K-blocks Used
Available Use% Pathname
/dev/sda5 15349760 7022460
8327300 46% /
/dev/sdd1 1038336 32928
1005408 3% /tdir2
/dev/sde1 508588 25760
482828 5% /tdir3
/dev/sdb1 1038336 32928
1005408 3% /tdir1
/dev/sda3 1038336 36812
1001524 4% /home
/dev/sda1 713388 125484
587904 18% /boot
xfs_quota> print
Filesystem Pathname
/ /dev/sda5
/tdir2 /dev/sdd1
/tdir3 /dev/sde1
/tdir1 /dev/sdb1
/home /dev/sda3
/boot /dev/sda1
xfs_quota> help quota
quota [-bir] [-gpu]
[-hnNv] [-f file] [id|name]... -- show usage and limits
display usage and quota information
-g -- display group quota information
-p -- display project quota information
-u -- display user quota information
-b -- display number of blocks used
-i -- display number of inodes used
-r -- display number of realtime blocks used
-h -- report in a human-readable format
-n -- skip identifier-to-name translations,
just report IDs
-N -- suppress the initial header
-v -- increase verbosity in reporting (also
dumps zero values)
-f -- send output to a file
The (optional) user/group/project can be
specified either by name or by
number (i.e. uid/gid/projid).
xfs_quota> q
[root@rhel7-server ~]#
EXPERT MODE……………………..
[root@rhel7-server ~]# xfs_quota -x -c
xfs_quota: option
requires an argument -- 'c'
Usage: xfs_quota
[-V] [-x] [-p prog] [-c cmd]... [-d project]... [path]
[root@rhel7-server ~]# xfs_quota -x -c 'df -h' /home
Filesystem Size Used
Avail Use% Pathname
/dev/sda3 1014M 35.9M 978.1M
4% /home
[root@rhel7-server ~]# xfs_quota -x -c 'df -ih' /home
Filesystem Inodes Used
Free Use% Pathname
/dev/sda3 1.0m 236
1.0m 0% /home
Setting quota for “user1” to limit block & inode via EXPERT MODE……..
[root@rhel7-server
~]# xfs_quota -x -c 'limit bsoft=20m bhard=30m isoft=50 ihard=75 user1' /home
xfs_quota: cannot set limits: Function not implemented ççç
Let’s implement the function……..
[root@rhel7-server ~]# mount -o remount,rw,uquota,gquota
/home
[root@rhel7-server ~]# mount |grep /home
/dev/sda3 on /home type xfs
(rw,relatime,seclabel,attr2,inode64,noquota)
Nothing happened……………..
It means some more exercise required…………..
[root@rhel7-server ~]# umount /home
[root@rhel7-server ~]# mount -o uquota,gquota /dev/sda3
/home
[root@rhel7-server ~]# mount |grep /home
/dev/sda3 on /home
type xfs (rw,relatime,seclabel,attr2,inode64,usrquota,grpquota)
[root@rhel7-server ~]# grep home /etc/fstab
UUID=87eef21b-7f45-4b27-a64e-81c3afa53b96
/home xfs defaults 1 2
No changes in /etc/fstab, means it might not sustain reboot.
[root@rhel7-server ~]# xfs_quota -x /home
xfs_quota> print
Filesystem Pathname
/home /dev/sda3 (uquota, gquota)
28 0 0
00 [--------]
xfs_quota> state
User quota state on
/home (/dev/sda3)
Accounting: ON
Enforcement: ON
Inode: #1152 (2 blocks, 2 extents)
Group quota state
on /home (/dev/sda3)
Accounting: ON
Enforcement: ON
Inode: #1190 (2 blocks, 2 extents)
Project quota state
on /home (/dev/sda3)
Accounting: OFF
Enforcement: OFF
Inode: #1190 (2 blocks, 2 extents)
Blocks grace time:
[7 days 00:00:30]
Inodes grace time:
[7 days 00:00:30]
Realtime Blocks
grace time: [7 days 00:00:30]
xfs_quota> report -h
User quota on /home
(/dev/sda3)
Blocks
User ID Used
Soft Hard Warn/Grace
----------
---------------------------------
root 32K 0
0 00 [------]
araman 3.5M
0 0 00 [------]
raman 52K 0
0 00 [------]
user1 56K
20M 30M 00 [------]
user3 28K 0
0 00 [------]
user4 28K 0
0 00 [------]
user5 28K 0
0 00 [------]
Group quota on
/home (/dev/sda3)
Blocks
Group ID Used
Soft Hard Warn/Grace
----------
---------------------------------
root 32K 0
0 00 [------]
araman 3.5M
0 0 00 [------]
raman 52K 0
0 00 [------]
user1 56K 0
0 00 [------]
user3 28K 0
0 00 [------]
user4 28K 0
0 00 [------]
user5 28K 0
0 00 [------]
xfs_quota> limit bsoft=10M bhard=15M user3 çç setting quota via BASIC MODE
xfs_quota> report -h
User quota on /home
(/dev/sda3)
Blocks
User ID Used
Soft Hard Warn/Grace
----------
---------------------------------
root 32K 0
0 00 [------]
araman 3.5M
0 0 00 [------]
raman 52K 0 0 00
[------]
user1 56K
20M 30M 00 [------]
user3 28K
10M 15M 00 [------]
user4 28K 0
0 00 [------]
user5 28K 0
0 00 [------]
Group quota on
/home (/dev/sda3)
Blocks
Group ID Used
Soft Hard Warn/Grace
----------
---------------------------------
root 32K 0
0 00 [------]
araman 3.5M
0 0 00 [------]
raman 52K 0
0 00 [------]
user1 56K 0
0 00 [------]
user3 28K 0
0 00 [------]
user4 28K 0
0 00 [------]
user5 28K 0
0 00 [------]
SETTING QUOTA BY EXPERT MODE……………………..
[root@rhel7-server
~]# xfs_quota -x -c 'limit bsoft=25m bhard=50m isoft=50 ihard=100 user1' /home
[root@rhel7-server
~]# xfs_quota -x -c 'limit bsoft=125m bhard=150m isoft=200 ihard=500 user3'
/home
[root@rhel7-server ~]# xfs_quota -x -c "report
-bih" /home
User quota on /home
(/dev/sda3)
Blocks Inodes
User ID Used
Soft Hard Warn/Grace Used
Soft Hard Warn/Grace
----------
--------------------------------- ---------------------------------
root 32K 0
0 00 [------] 4
0 0 00 [------]
araman 3.5M
0 0 00 [------]
133 0 0
00 [------]
raman 52K 0
0 00 [------] 27
0 0 00 [------]
user1 56K
25M 50M 00 [------] 30
50 100 00 [------]
user3 28K
125M 150M 00 [------] 14
200 500 00 [------]
user4 28K 0
0 00 [------] 14
0 0 00 [------]
user5 28K 0
0 00 [------] 14
0 0 00 [------]
REMOVING QUOTA BY EXPERT MODE……………………..
[root@rhel7-server
~]# xfs_quota -x -c 'limit bsoft=0 bhard=0 isoft=0 ihard=0 user1' /home
[root@rhel7-server
~]# xfs_quota -x -c 'limit bsoft=0 bhard=0 isoft=0 ihard=0 user3' /home
[root@rhel7-server ~]# xfs_quota -x -c "report
-bih" /home
User quota on /home
(/dev/sda3)
Blocks Inodes
User ID Used
Soft Hard Warn/Grace Used
Soft Hard Warn/Grace
----------
--------------------------------- ---------------------------------
root 32K 0
0 00 [------] 4
0 0 00 [------]
araman 3.5M
0 0 00 [------]
133 0 0
00 [------]
raman 52K 0
0 00 [------] 27
0 0 00 [------]
user1 56K 0
0 00 [------] 30
0 0 00 [------]
user3 28K 0
0 00 [------] 14
0 0 00 [------]
user4 28K 0
0 00 [------] 14
0 0 00 [------]
user5 28K 0
0 00 [------] 14
0 0
00 [------]
[root@rhel7-server ~]# xfs_quota -x -c 'off -ugp -v' /home
User quota are not enabled on /dev/sda3
[root@rhel7-server
~]# xfs_quota -x -c 'limit bsoft=125m bhard=150m isoft=200 ihard=500 user3'
/home
xfs_quota: cannot set limits: Function not implemented ççsee the msg
[root@rhel7-server ~]# mount |grep /home
/dev/sda3 on /home type xfs
(rw,relatime,seclabel,attr2,inode64,noquota)
Enable the quota…………………..
Did changes at /home in /etc/fstab
[root@rhel7-server ~]# grep home /etc/fstab
UUID=87eef21b-7f45-4b27-a64e-81c3afa53b96
/home xfs defaults,uquota,gquota 1 2
Trying to implement quota……..
[root@rhel7-server ~]# xfs_quota -x -c "enable -gu -v" /home
XFS_QUOTAON: Function not implemented
[root@rhel7-server ~]# xfs_quota -x /home
xfs_quota> report
xfs_quota> q
[root@rhel7-server ~]# mount -o remount,rw /home
[root@rhel7-server ~]# mount |grep /home
/dev/sda3 on /home type xfs
(rw,relatime,seclabel,attr2,inode64,noquota)
Nothing Happened,
Reboot the system……………………………..
[root@rhel7-server ~]# xfs_quota -x -c "enable -gu -v" /home
XFS_QUOTAON: File exists
[root@rhel7-server ~]# mount |grep /home
/dev/sda3 on /home
type xfs (rw,relatime,seclabel,attr2,inode64,usrquota,grpquota)
[root@rhel7-server ~]# xfs_quota -x /home
xfs_quota> report -b
User quota on /home
(/dev/sda3)
Blocks
User ID Used Soft Hard
Warn/Grace
----------
--------------------------------------------------
root 32 0 0
00 [--------]
araman 3596 0 0
00 [--------]
raman 52 0 0
00 [--------]
user1 56 0 0
00 [--------]
user3 28 0 0
00 [--------]
user4 28 0 0
00 [--------]
user5 28 0 0
00 [--------]
Group quota on
/home (/dev/sda3)
Blocks
Group ID Used Soft Hard
Warn/Grace
----------
--------------------------------------------------
root 32 0 0
00 [--------]
araman 3596 0 0
00 [--------]
raman 52 0 0
00 [--------]
user1 56 0 0
00 [--------]
user3 28 0 0
00 [--------]
user4 28 0 0
00 [--------]
user5 28 0 0
00 [--------]
xfs_quota> state -u
User quota state on
/home (/dev/sda3)
Accounting: ON
Enforcement: ON
Inode: #1152 (2 blocks, 2 extents)
Blocks grace time:
[7 days 00:00:30]
Inodes grace time:
[7 days 00:00:30]
Realtime Blocks
grace time: [7 days 00:00:30]
xfs_quota> timer -b 3days
xfs_quota> state -u
User quota state on
/home (/dev/sda3)
Accounting: ON
Enforcement: ON
Inode: #1152 (2 blocks, 2 extents)
Blocks grace time:
[3 days 00:00:30]
Inodes grace time:
[7 days 00:00:30]
Realtime Blocks
grace time: [7 days 00:00:30]
No comments:
Post a Comment