创建磁盘配额是实际工作中会遇到的内容,下面是一个磁盘配额的全部过程
一、总体步骤
1 启用配额挂载选项
2 创建配额数据库
3启用数据库
4指定用户空间限制
5测试
6查询
二、分步操作过程
(1) 查看独立的磁盘(或者是分区)
[root@localhoast ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 3.7G 0 rom sda 8:0 0 120G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 119.5G 0 part ├─vg_localhoast-lv_root (dm-0) 253:0 0 50G 0 lvm / ├─vg_localhoast-lv_swap (dm-1) 253:1 0 2G 0 lvm [SWAP] └─vg_localhoast-lv_home (dm-2) 253:2 0 67.6G 0 lvm /home
sdb 8:16 0 20G 0 disk ├─sdb1 8:17 0 2G 0 part ├─sdb2 8:18 0 3G 0 part ├─sdb3 8:19 0 4G 0 part ├─sdb4 8:20 0 1K 0 part └─sdb5 8:21 0 5G 0 part [root@localhoast ~]# vim /etc/fstab # # /etc/fstab # Created by anaconda on Wed Oct 12 16:48:42 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_localhoast-lv_root / ext4 defaults 1 1 UUID=d78fba61-0bea-40de-8e48-ced5d3933a02 /boot ext4 defaults 1 2 /dev/mapper/vg_localhoast-lv_home /home ext4 defaults 1 2 /dev/mapper/vg_localhoast-lv_swap swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 UUID="cbdd2adc-3578-4de4-bb91-e5ce34e50a43" /quota ext4 defaults,usrquota,grpquota 0 0 [root@localhoast ~]# mount -a [root@localhoast ~]# mount /dev/mapper/vg_localhoast-lv_root on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/mapper/vg_localhoast-lv_home on /home type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sdb1 on /quota type ext4 (rw,usrquota,grpquota)
(2)创建配额数据库
[root@localhoast ~]# setenforce 0 [root@localhoast ~]# quotacheck -cug /quota 创建数据库
(3)启用数据库
[root@localhoast ~]# quotaon -p /quota 查看 group quota on /quota (/dev/sdb1) is off user quota on /quota (/dev/sdb1) is off [root@localhoast ~]# quotaon /quota 开启 [root@localhoast ~]# quotaon -p /quota 查看 group quota on /quota (/dev/sdb1) is on user quota on /quota (/dev/sdb1) is on
4指定用户空间限制
[root@localhoast ~]# edquota han 编辑配额 edit quota=edquota Disk quotas for user han (uid 500): Filesystem blocks soft hard inodes soft hard /dev/sdb1 0 100 150 0 0 0
5测试
[root@localhoast ~]# su - han [han@localhoast ~]$ cd /quota/ [han@localhoast quota]$ dd if=/dev/zero of=aaa bs=1K count=130 sdb1: warning, user block quota exceeded. 成功 130+0 records in 130+0 records out 133120 bytes (133 kB) copied, 0.000868992 s, 153 MB/s
6查询
[root@localhoast ~]# quota han Disk quotas for user han (uid 500): Filesystem blocks quota limit grace files quota limit grace /dev/sdb1 132* 100 150 6days 1 0 0 [root@localhoast ~]# repquota /quota/ *** Report for user quotas on device /dev/sdb1 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 20 0 0 2 0 0 han +- 132 100 150 6days 1 0 0
原创文章,作者:hanlln1,如若转载,请注明出处:http://www.178linux.com/60535