linux系统中对磁盘配额(quota)软阵列(raid)的实现

本文发布时间: 2019-Mar-22
1.创建测试的用户和修改挂载的参数[root@localhost ~]# useradd user1 --新建两个用户[root@localhost ~]# useradd user2[root@localhost ~]# mount -o remount,usrquota,grpquota /mnt/sdb --重新挂载,加参数[root@localhost ~]# mount -l --查看挂载选项/dev/mapper/VolGroup-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)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)/dev/sdb1 on /mnt/sdb type ext4 (rw,usrquota,grpquota)[root@localhost ~]# quotacheck -avug -mf --生成两个quota文件quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.quotacheck: Scanning /dev/sdb1 [/mnt/sdb] donequotacheck: Cannot stat old user quota file: No such file or directoryquotacheck: Cannot stat old group quota file: No such file or directoryquotacheck: Cannot stat old user quota file: No such file or directoryquotacheck: Cannot stat old group quota file: No such file or directoryquotacheck: Checked 2 directories and 0 filesquotacheck: Old file not found.quotacheck: Old file not found.[root@localhost ~]# ll /mnt/sdb --查看生成的两个文件total 26-rw-------. 1 root root 6144 Jan 9 17:59 aquota.group-rw-------. 1 root root 6144 Jan 9 17:59 aquota.userdrwx------. 2 root root 12288 Jan 9 17:55 lost+found[root@localhost ~]# quotaon -avug --开启quota功能/dev/sdb1 [/mnt/sdb]: group quotas turned on/dev/sdb1 [/mnt/sdb]: user quotas turned on[root@localhost ~]# edquota -u user1Disk quotas for user user1 (uid 500):Filesystem blocks soft hard inodes soft hard/dev/sdb1 0 10 20 0 0 0[root@localhost ~]# edquota -u user2Disk quotas for user user2 (uid 501):Filesystem blocks soft hard inodes soft hard/dev/sdb1 0 5 10 0 0 02.验证配额[root@localhost ~]# su - user1[user1@localhost ~]$ cd /mnt/sdb[user1@localhost sdb]$ dd if=/dev/zero of=12 bs=1M count=5 --创建5M的文件没有警告信息,正常5+0 records in5+0 records out5242880 bytes (5.2 MB) copied, 0.0525754 s, 99.7 MB/s[user1@localhost sdb]$ ll -h 12-rw-rw-r--. 1 user1 user1 5.0M Jan 9 18:16 12[user1@localhost sdb]$ dd if=/dev/zero of=123 bs=1M count=21 --创建12M的文件有警告信息,表示失败sdb1: warning, user block quota exceeded.sdb1: write failed, user block limit reached.dd: writing `123': Disk quota exceeded20+0 records in19+0 records out20475904 bytes (20 MB) copied, 0.20094 s, 102 MB/s[user1@localhost sdb]$ ll -h 123-rw-rw-r--. 1 user1 user1 0 Jan 9 18:17 123[user1@localhost sdb]$ exitlogout[root@localhost ~]# su - user2 --用户user2测试[user2@localhost ~]$ cd /mnt/sdb[user2@localhost sdb]$ dd if=/dev/zero of=23 bs=1M count=8 --写入8M文件成功sdb1: warning, user block quota exceeded.8+0 records in8+0 records out8388608 bytes (8.4 MB) copied, 0.0923618 s, 90.8 MB/s[user2@localhost sdb]$ ll -h 23 --查看文件大小-rw-rw-r--. 1 user2 user2 8.0M Jan 9 18:23 23[user2@localhost sdb]$[user2@localhost sdb]$ dd if=/dev/zero of=23 bs=1M count=11 --写入11M文件失败sdb1: warning, user block quota exceeded.sdb1: write failed, user block limit reached.dd: writing `23': Disk quota exceeded10+0 records in9+0 records out10235904 bytes (10 MB) copied, 0.106298 s, 96.3 MB/s[user2@localhost sdb]$3.查看quota配置,修改警告时间,取消quota[root@localhost ~]# quota -vu user1 user2 --查找指定的用户quota信息Disk quotas for user user1 (uid 500):Filesystem blocks quota limit grace files quota limit grace/dev/sdb1 0 10000 20000 0 0 0Disk quotas for user user2 (uid 501):Filesystem blocks quota limit grace files quota limit grace/dev/sdb1 8193* 5000 10000 6days 1 0 0[root@localhost ~]# repquota -av --所有用户和quota信息*** Report for user quotas on device /dev/sdb1Block grace time: 7days; Inode grace time: 7daysBlock limits File limitsUser used soft hard grace used soft hard grace----------------------------------------------------------------------root -- 13 0 0 2 0 0user1 -- 0 10000 20000 0 0 0user2 +- 8193 5000 10000 6days 1 0 0Statistics:Total blocks: 7Data blocks: 1Entries: 3Used average: 3.000000[root@localhost ~]# edquota -t --修改文件警告天数(Block 天数 Inode 天数)Grace period before enforcing soft limits for users:Time units may be: days, hours, minutes, or secondsFilesystem Block grace period Inode grace period/dev/sdb1 7days 7days[root@localhost ~]# vim /etc/warnquota.conf --查看警告信息[root@localhost ~]# quotaoff /mnt/sdb --关闭quota功能


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表