磁盘配额是针对某个分区来设置的,我们知道/home 是所用普通用户的家,假设/home共100G。普通用户有tom,jerry,yuri,nicholas。他们四个人共用这100G,但是yuri这个人喜欢看电影,他给他的家目录下放了一堆小电影。导致一共就100G的空间。光yuri就占了80G。这是很不公平的。所以就出现了磁盘配额。
磁盘的磁盘配额功能需要挂载时就添加的,假若磁盘没有quota功能可以挂载
[root@www mnt]# mount -o usrquota /dev/sdb3 /mnt/tmp [root@www mnt]# mount |tail -n 1 /dev/sdb3 on /mnt/tmp type xfs (rw,relatime,seclabel,attr2,inode64,usrquota)输入edquota -u wjx(用户名)。来配置他的磁盘配额
Disk quotas for user wjx (uid 1000): Filesystem blocks soft hard inodes soft hard /dev/sdb3 0 0 30000 0 0 0
xfs 主要针对 群组,个人,或单独的目录来进行磁盘使用率的限制
xfs_quota -x -c "指令" [挂载点]
查看该分区的状况
[root@www mnt]# xfs_quota -x -c "report" /mnt/tmp User quota on /mnt/tmp (/dev/sdb3) Blocks User ID Used Soft Hard Warn/Grace ---------- -------------------------------------------------- root 0 0 0 00 [--------] wjx 0 0 30000 00 [--------]
[root@www mnt]# xfs_quota -x -c "limit -u bsoft=250M bhard=300M wjx" /mnt/tmp
[root@www mnt]# xfs_quota -x -c "report" /mnt/tmp User quota on /mnt/tmp (/dev/sdb3) Blocks User ID Used Soft Hard Warn/Grace ---------- -------------------------------------------------- root 0 0 0 00 [--------] wjx 0 256000 307200 00 [--------]
[root@www mnt]# xfs_quota -x -c "timer -u -b 14days" /mnt/tmp #时间改为14days
查看quota分区状态
[root@www mnt]# xfs_quota -x -c "state" /mnt/tmp User quota state on /mnt/tmp (/dev/sdb3) Accounting: ON Enforcement: ON Inode: #131 (2 blocks, 2 extents) Group quota state on /mnt/tmp (/dev/sdb3) Accounting: OFF Enforcement: OFF Inode: #0 (0 blocks, 0 extents) Project quota state on /mnt/tmp (/dev/sdb3) Accounting: OFF Enforcement: OFF Inode: #0 (0 blocks, 0 extents) Blocks grace time: [14 days 00:00:30] Inodes grace time: [7 days 00:00:30] Realtime Blocks grace time: [7 days 00:00:30]
[root@www mnt]# cryptsetup luksFormat /dev/sdb3 WARNING! ======== This will overwrite data on /dev/sdb3 irrevocably. Are you sure? (Type uppercase yes): YES Enter passphrase: Verify passphrase:
[root@www mnt]# cryptsetup open /dev/sdb3 secret Enter passphrase for /dev/sdb3:
[root@www mnt]# mkfs.xfs /dev/mapper/secret meta-data=/dev/mapper/secret isize=256 agcount=4, agsize=130944 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=523776, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
[root@www mnt]# mount /dev/mapper/secret /mnt/tmp/
[root@www mnt]# umount tmp [root@www mnt]# cryptsetup close secret