Linux系统中对磁盘配额(Quota),软阵列(RAID)的实现
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] done
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Checked 2 directories and 0 files
quotacheck: 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.user
drwx------. 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 user1
Disk 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 user2
Disk quotas for user user2 (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 0 5 10 0 0 0
[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] done
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old user quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Checked 2 directories and 0 files
quotacheck: 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.user
drwx------. 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 user1 --用户user1使用/mnt/sdb目录不要起过20M
Disk quotas for user user1 (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 0 10000 20000 0 0 0
[root@localhost ~]# edquota -u user2 --用户user2对sdb目录不要超过10M,大于5M超出指定时间删除
Disk quotas for user user2 (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 0 5000 10000 0 0 0