quota xfs

这篇博客展示了如何在Linux系统中使用XFS文件系统为用户设置磁盘配额,通过`mkfs.xfs`创建文件系统,`useradd`添加用户,`xfs_quota`设定软硬限制,并通过`dd`命令测试超过配额时的限制。当用户尝试写入超过其配额的数据时,系统会阻止进一步的写入操作,保护了磁盘资源。
摘要由CSDN通过智能技术生成
[root@starplatinum 桌面]# mkfs.xfs /dev/sdb2
meta-data=/dev/sdb2              isize=256    agcount=4, agsize=12800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=51200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

[anan3@starplatinum ~]$ exit

[root@starplatinum 桌面]# umount /var/quotatest/

[root@starplatinum 桌面]# mount -o usrquota,grpquota /dev/sdb2 /var/quotatest/
ng 桌面]# useradd -u 1035 -d /var/quotatest/anan4 -g qtest anan4
[root@starplatinum starplatinum]# su anan4
[anan4@starplatinum starplatinum]$ cd
[anan4@starplatinum ~]$ quotacheck -acgmu

[root@starplatinum 桌面]#  xfs_quota -x -c 'limit bsoft=100M bhard=150M isoft=25 ihard=30 -u anan4' /var/quotatest

dd if=/dev/zero of=test bs=1M count=100
dd if=/dev/zero of=test bs=1M count=100

[root@starplatinum 桌面]# xfs_quota -x -c 'report -ubih' /var/quotatest/
User quota on /var/quotatest (/dev/sdb2)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- --------------------------------- 
root            0      0      0  00 [------]      3      0      0  00 [------]
anan4      100.0M   100M   150M  00 [6 days]     13     25     30  00 [------]


[anan4@starplatinum ~]$ dd if=/dev/zero of=test bs=1M count=110
记录了110+0 的读入
记录了110+0 的写出
115343360字节(115 MB)已复制,0.166153 秒,694 MB/[root@starplatinum 桌面]# xfs_quota -x -c 'report -ubih' /var/quotatest/
User quota on /var/quotatest (/dev/sdb2)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- --------------------------------- 
root            0      0      0  00 [------]      3      0      0  00 [------]
anan4      128.0M   100M   150M  00 [7 days]     13     25     30  00 [------]

dd if=/dev/zero of=test bs=1M count=150

[anan4@starplatinum ~]$ dd if=/dev/zero of=test bs=1M count=150
dd: 写入"test" 出错: 超出磁盘限额
记录了150+0 的读入
记录了149+0 的写出
157270016字节(157 MB)已复制,0.148485 秒,1.1 GB/[root@starplatinum 桌面]# xfs_quota -x -c 'report -ubih' /var/quotatest/
User quota on /var/quotatest (/dev/sdb2)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- --------------------------------- 
root            0      0      0  00 [------]      3      0      0  00 [------]
anan4        150M   100M   150M  00 [7 days]     13     25     30  00 [------]



[anan4@starplatinum ~]$ ls
test
[anan4@starplatinum ~]$ rm test
[anan4@starplatinum ~]$ ls
[anan4@starplatinum ~]$ 

[anan4@starplatinum ~]$ touch a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9
touch: 无法创建"s": 超出磁盘限额
touch: 无法创建"t": 超出磁盘限额
touch: 无法创建"u": 超出磁盘限额
touch: 无法创建"v": 超出磁盘限额
touch: 无法创建"w": 超出磁盘限额
touch: 无法创建"x": 超出磁盘限额
touch: 无法创建"y": 超出磁盘限额
touch: 无法创建"z": 超出磁盘限额
touch: 无法创建"1": 超出磁盘限额
touch: 无法创建"2": 超出磁盘限额
touch: 无法创建"3": 超出磁盘限额
touch: 无法创建"4": 超出磁盘限额
touch: 无法创建"5": 超出磁盘限额
touch: 无法创建"6": 超出磁盘限额
touch: 无法创建"7": 超出磁盘限额
touch: 无法创建"8": 超出磁盘限额
touch: 无法创建"9": 超出磁盘限额

[root@starplatinum 桌面]# xfs_quota -x -c 'report -ubih' /var/quotatest/
User quota on /var/quotatest (/dev/sdb2)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- --------------------------------- 
root            0      0      0  00 [------]      3      0      0  00 [------]
anan4         20K   100M   150M  00 [------]     30     25     30  00 [7 days]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值