磁盘配额quota和磁盘加密luks

首先说一下quota磁盘配额。

      磁盘配额是针对某个分区来设置的,我们知道/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的quota是整合到文件系统中的。并不是其他的外挂程序来管理、可以通过xfs_quota来直接管理


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]

再说一下磁盘加密。

磁盘加密是基于磁盘的加密。是最安全的加密方式。cryptsetup
[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: 

格式化。并挂载(注意。这里是/dev/mapper/secret)
[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

cryptsetup luksAddKey /dev/vdb1 /root/lukspsfile //将两个文件关联
使用上面的那个命令就可以将这块磁盘写进fstab中自动挂载。系统开机时会去读/root/lukspsfile去找密码






  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值