quota 日本語では「割り当て」とか「取り分」とかでしょうか

ext4の場合 quota/ext4

自分のホームディレクトリに際限なくデータを溜め込むと同じボリュームを共有している他のユーザの「割り当て」が減る.
強いては「お前は取りすぎ」と詰られ、ダイエットに励むことになる.

っでそういったダイエットに向かう前に「少々食べすぎですよ」とか「これ以上は無理だよ」と案内をしてくれるのが「quota」

「/etc/fstab」にて

[root@rockylinux9 ~]# cat /etc/fstab
UUID=043fee50-4602-4669-8c6f-f91afadceefe /     xfs   defaults 0 0
UUID=8fc719a2-52a2-489c-a99c-5df8fb43dc94 /boot xfs   defaults 0 0
UUID=4B90-8B35       /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=439c144b-5d90-4533-b28c-f72a6831e3d6 none  swap  defaults 0 0
#
LABEL=home /home xfs defaults  0 0
 
[root@rockylinux9 ~]#

となっていて「/home」のmount optionは「defaults」で隠れている. これは実際には

[root@rockylinux9 ~]# mount |grep home
/dev/sdb1 on /home type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
[root@rockylinux9 ~]#

から「rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota」である.
ここに「noquota」とあるように、どうやら既定では quota は使えない模様.
まずこの「/etc/fstab」を修正して使えるようにする. だたし「/」領域のquotaは grub で既定する必要があります

ただquotaには「ユーザ毎」「グループ毎」「プロジェクト毎」にquotaが付けられるようで、それ毎にoptionがある様子
ここでは「ユーザ毎」に指定しますので、「uquota」を/etc/fstabのoptionに加えます

[root@rockylinux9 ~]# vi /etc/fstab
 :
LABEL=home /home xfs defaults,uquota  0 0
 
[root@rockylinux9 ~]# umount /home
[root@rockylinux9 ~]# mount -a
[root@rockylinux9 ~]# mount |grep home
/dev/sdb1 on /home type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,usrquota)
 
[root@rockylinux9 ~]#

と「noquota」から「usrquota」に変更されました.
この quota のオプションがあることで「xfs_quota」コマンドが使えます

ユーザを作り始めの時は「Soft」「Hard」のどちらも制限が入っていないです
「soft limit」を入れて、それを超えると警告メッセージが表示され、猶予期間 (grace period)後も超えていたらout. それ以上の書き込みはできないです.
「hard limit」を入れるとそれを超えての書き込みはできないです

[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]
arcueid       12K      0      0  00 [------]
ciel          12K      0      0  00 [------]
 
[root@rockylinux9 ~]#

っで設定
ユーザ「arcueid」にはsoft制限を10GB、Hardを11GB
ユーザ「ciel」にはsoft制限を5GB、Hardを11GB

[root@rockylinux9 ~]# xfs_quota -x -c 'limit bsoft=10G bhard=11G arcueid' /home
 
[root@rockylinux9 ~]# xfs_quota -x -c 'limit bsoft=5G bhard=11G ciel' /home
 
(確認)
[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]
arcueid       12K    10G    11G  00 [------]
ciel          12K     5G    11G  00 [------]
 
[root@rockylinux9 ~]#

猶予期間 (grace period)を2時間にしたいと思います. 既定の値は下記コマンドで表記される

[root@rockylinux9 ~]# xfs_quota -x -c 'state -u' /home
User quota state on /home (/dev/sdb1)
  Accounting: ON
  Enforcement: ON
  Inode: #131 (2 blocks, 2 extents)
Blocks grace time: [7 days]
Blocks max warnings: 5
Inodes grace time: [7 days]
Inodes max warnings: 5
Realtime Blocks grace time: [7 days]
[root@rockylinux9 ~]#

この猶予期間は皆共通で、個別の事前指定は無理みたい. 「arcueid」は10日, 「ciel」は3日とか事前にそれぞれ定義は出来ない様子
だが、「soft limit」に入ってからユーザ別に延長/短縮とかは可能っぽい.

[root@rockylinux9 ~]# xfs_quota -x -c 'timer -u 2h -d' /home
 
[root@rockylinux9 ~]# xfs_quota -x -c 'state -u' /home
User quota state on /home (/dev/sdb1)
  Accounting: ON
  Enforcement: ON
  Inode: #131 (2 blocks, 2 extents)
Blocks grace time: [0 days 02:00:00]
Blocks max warnings: 5
Inodes grace time: [0 days 02:00:00]
Inodes max warnings: 5
Realtime Blocks grace time: [0 days 02:00:00]
 
[root@rockylinux9 ~]#

テスト

ユーザ「ciel」が5GBを超える占有を行ったら

[ciel@rockylinux9 ~]$ dd if=/dev/zero of=curry01 bs=1G count=5
[ciel@rockylinux9 ~]$ ls -lh
total 5.0G
-rw-r--r--. 1 ciel ciel 5.0G Jan 29 14:51 curry01
 
[ciel@rockylinux9 ~]$ quota -s
Disk quotas for user ciel (uid 1001):
     Filesystem   space   quota   limit   grace   files   quota   limit   grace
      /dev/sdb1   5121M*  5120M  11264M   01:58       5       0       0
 
[ciel@rockylinux9 ~]$

と「quota」で自身の制限を超えたことが分かる.
またrootによる「xfs_quota」コマンドでも下記のように判明する.

[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [0 days]
arcueid       12K    10G    11G  00 [------]
ciel         5.0G     5G    11G  00 01:57:30
 
[root@rockylinux9 ~]#

だが執行猶予中ならHardまで容量は使えます
さらにファイルを作ってみます

[ciel@rockylinux9 ~]$ dd if=/dev/zero of=curry02 bs=1G count=1
[ciel@rockylinux9 ~]$ ls -lh
total 6.0G
-rw-r--r--. 1 ciel ciel 5.0G Jan 29 14:51 curry01
-rw-r--r--. 1 ciel ciel 1.0G Jan 29 14:56 curry02
[ciel@rockylinux9 ~]$
[ciel@rockylinux9 ~]$ quota -s
Disk quotas for user ciel (uid 1001):
     Filesystem   space   quota   limit   grace   files   quota   limit   grace
      /dev/sdb1   6145M*  5120M  11264M   01:55       6       0       0
[ciel@rockylinux9 ~]$

っな感じ.

ここで残念なお知らせ. soft limitを超えても、明確なお知らせがないです.
一応メールで容量をお知らせしてくれる「quota-warnquota」が唯一のお知らせでしょうか.
っが、メールで知らせてくれるより、画面上でお知らせしてほしいのだが、探してもないみたい...
なので、「quota-warnquota」の定義を行っていないと実質 hard limit まで使い切るのかなと思われ.

でも状況を知るためにコマンド quota を使う

[ciel@rockylinux9 ~]$ echo "quota -s -q" >> $HOME/.bashrc

soft limitを超えていれば 新しいターミナルを開いたときに

Disk quotas for user ciel (uid 1001):
        In block grace period on /dev/sdb1

とか表示される. soft limit以内ではなのも表示されない. これかなぁ

閑話休題.
執行猶予を短くしてみます. 猶予を2minにしてみます

[root@rockylinux9 ~]# xfs_quota -x -c 'timer -u 2m ciel' /home
 
[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [0 days]
arcueid       12K    10G    11G  00 [------]
ciel         6.0G     5G    11G  00 00:01:59
 
[root@rockylinux9 ~]#

2分後

[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [0 days]
arcueid       12K    10G    11G  00 [------]
ciel         6.0G     5G    11G  00 [0 days]
 
[root@rockylinux9 ~]#

となって、新なファイルを作ろうとすると

[ciel@rockylinux9 ~]$ echo "abc" > sample
-bash: sample: Disk quota exceeded
[ciel@rockylinux9 ~]$

っとsoft limitが効いてこれ以上書けなくなってます.

この状態で執行猶予を伸ばすと

[root@rockylinux9 ~]# xfs_quota -x -c 'timer -u 1d ciel' /home
[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [0 days]
arcueid       12K    10G    11G  00 [------]
ciel         6.0G     5G    11G  00 23:59:57
 
[root@rockylinux9 ~]#

となって、Hard limit まで書き込めます

[ciel@rockylinux9 ~]$ echo "abc" > sample
[ciel@rockylinux9 ~]$ ls -lh
total 6.1G
-rw-r--r--. 1 ciel ciel 5.0G Jan 29 14:51 curry01
-rw-r--r--. 1 ciel ciel 1.0G Jan 29 14:56 curry02
-rw-r--r--. 1 ciel ciel    4 Jan 29 15:06 sample
[ciel@rockylinux9 ~]$

無効にするには

執行猶予のカウントを止めるには

[root@rockylinux9 ~]# xfs_quota -x -c 'disable -v' /home
User quota state on /home (/dev/sdb1)
  Accounting: ON
  Enforcement: OFF
  Inode: #131 (2 blocks, 2 extents)
 :
[root@rockylinux9 ~]#

再開するには

[root@rockylinux9 ~]# xfs_quota -x -c 'enable -v' /home
User quota state on /home (/dev/sdb1)
  Accounting: ON
  Enforcement: ON
  Inode: #131 (2 blocks, 2 extents)
 :
[root@rockylinux9 ~]#

容量制限とかも全ていったん止めるには「xfs_quota -x -c off」を実行する

[root@rockylinux9 ~]# xfs_quota -x -c off /home
[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
[root@rockylinux9 ~]#

再開するには一旦指定ボリュームをunmountして、mountし直せば戻る. まぁー再起動でも可 執行猶予の時間もリセットされます

個別に設定を無効にしたいなら

[root@rockylinux9 ~]# xfs_quota -x -c 'limit bsoft=0 bhard=0 arcueid' /home
[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [0 days]
arcueid       12K      0      0  00 [------]
ciel         6.0G     5G    11G  00 01:58:23
 
[root@rockylinux9 ~]#

また、すべてのquota設定を破棄したいなら

[root@rockylinux9 ~]# xfs_quota -x -c 'disable -v' /home
[root@rockylinux9 ~]# xfs_quota -x -c 'off -v' /home
[root@rockylinux9 ~]# xfs_quota -x -c 'remove -v' /home
[root@rockylinux9 ~]# reboot
[root@rockylinux9 ~]# xfs_quota -x -c 'report -h' /home
User quota on /home (/dev/sdb1)
                        Blocks
User ID      Used   Soft   Hard Warn/Grace
---------- ---------------------------------
root            0      0      0  00 [------]
arcueid       12K      0      0  00 [------]
ciel         6.0G      0      0  00 [------]
 
[root@rockylinux9 ~]#
最新の60件
2023-12-06 2023-12-05 2023-11-30 2023-11-27 2023-11-21 2023-11-19 2023-11-18 2023-11-14 2023-11-10 2023-11-09 2023-11-05 2023-11-03 2023-10-31 2023-10-30 2023-10-26 2023-10-24 2023-10-19 2023-10-16 2023-10-15 2023-10-12 2023-10-11 2023-10-09 2023-10-03 2023-10-02 2023-09-30 2023-09-29 2023-09-26 2023-09-24 2023-09-19 2023-09-18 2023-09-17 2023-09-16 2023-09-14 2023-09-12 2023-09-11 2023-09-08 2023-09-05 2023-09-02 2023-08-30 2023-08-29

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-01-30 (月) 00:16:20