“Linux 磁盘配额管理”的版本间的差异
来自CloudWiki
(创建页面,内容为“==文件系统配额设置== ===编辑/etc/fstab文件=== 用vi编辑器打开/etc/fstab文件,对/home所在行进行修改,增加命令选项userquota 和grpqu…”) |
|||
第24行: | 第24行: | ||
===创建配额文件=== | ===创建配额文件=== | ||
执行命令quotacheck命令 | 执行命令quotacheck命令 | ||
+ | |||
+ | [root@localhost ~]# quotacheck -avgu | ||
+ | |||
+ | <nowiki>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/sda3 [/home] 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 7 directories and 3 files | ||
+ | quotacheck: Old file not found. | ||
+ | quotacheck: Old file not found.</nowiki> | ||
+ | |||
+ | 查看/home目录 | ||
+ | |||
+ | <nowiki>root@localhost ~]# cd /home | ||
+ | [root@localhost home]# ls | ||
+ | aquota.group aquota.user fly lost+found</nowiki> | ||
+ | |||
+ | ===执行edquota文件=== | ||
+ | edquota -u user1 | ||
+ | |||
+ | <nowiki>Disk quotas for user fly (uid 500): | ||
+ | Filesystem blocks soft hard inodes soft hard | ||
+ | /dev/sda3 32 10240 15360 8 0 0 | ||
+ | </nowiki> | ||
+ | |||
+ | 执行 | ||
+ | |||
+ | [root@localhost home]# edquota -u fly | ||
+ | |||
+ | [root@localhost home]# edquota -u fly | ||
+ | |||
+ | [root@localhost home]# useradd horse | ||
+ | |||
+ | [root@localhost home]# edquota -p fly horse | ||
+ | |||
+ | <nowiki>[root@localhost home]# groupadd user | ||
+ | [root@localhost home]# gpasswd -a fly user | ||
+ | Adding user fly to group user | ||
+ | [root@localhost home]# gpasswd -a horse user | ||
+ | Adding user horse to group user | ||
+ | [root@localhost home]# edquota -g user | ||
+ | </nowiki> | ||
+ | |||
+ | ===启动配额管理 === | ||
+ | [root@localhost home]# quotaon -aguv | ||
+ | |||
+ | <nowiki>/dev/sda3 [/home]: group quotas turned on | ||
+ | /dev/sda3 [/home]: user quotas turned on | ||
+ | </nowiki> | ||
+ | |||
+ | 查看配额情况: | ||
+ | |||
+ | <nowiki>[root@localhost home]# quota fly | ||
+ | Disk quotas for user fly (uid 500): | ||
+ | Filesystem blocks quota limit grace files quota limit grace | ||
+ | /dev/sda3 32 10240 15360 8 0 0</nowiki> | ||
+ | |||
+ | ===关闭配额管理=== | ||
+ | |||
+ | [root@localhost new]# quotaoff -aguv | ||
+ | /dev/sda3 [/home]: group quotas turned off | ||
+ | /dev/sda3 [/home]: user quotas turned off |
2018年6月29日 (五) 02:04的版本
文件系统配额设置
编辑/etc/fstab文件
用vi编辑器打开/etc/fstab文件,对/home所在行进行修改,增加命令选项userquota 和grpquota
# # /etc/fstab # Created by anaconda on Thu Jun 28 04:40:29 2018 # # 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 # UUID=7867ecde-68a9-437f-b68c-1b8e16a53346 / ext4 defaults 1 1 UUID=eec138a9-9e94-4757-8a7f-fc3ccb56c153 /home ext4 defaults,userquota,grpquota 1 2 UUID=4657ef5a-8967-41c0-8818-04564bf6a4f0 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 /dev/sdb1 /mnt/hello ext4 defaults
重启系统
重启系统可使系统读取/etc/fstab文件的内容,重新挂载
创建配额文件
执行命令quotacheck命令
[root@localhost ~]# quotacheck -avgu
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/sda3 [/home] 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 7 directories and 3 files quotacheck: Old file not found. quotacheck: Old file not found.
查看/home目录
root@localhost ~]# cd /home [root@localhost home]# ls aquota.group aquota.user fly lost+found
执行edquota文件
edquota -u user1
Disk quotas for user fly (uid 500): Filesystem blocks soft hard inodes soft hard /dev/sda3 32 10240 15360 8 0 0
执行
[root@localhost home]# edquota -u fly
[root@localhost home]# edquota -u fly
[root@localhost home]# useradd horse
[root@localhost home]# edquota -p fly horse
[root@localhost home]# groupadd user [root@localhost home]# gpasswd -a fly user Adding user fly to group user [root@localhost home]# gpasswd -a horse user Adding user horse to group user [root@localhost home]# edquota -g user
启动配额管理
[root@localhost home]# quotaon -aguv
/dev/sda3 [/home]: group quotas turned on /dev/sda3 [/home]: user quotas turned on
查看配额情况:
[root@localhost home]# quota fly Disk quotas for user fly (uid 500): Filesystem blocks quota limit grace files quota limit grace /dev/sda3 32 10240 15360 8 0 0
关闭配额管理
[root@localhost new]# quotaoff -aguv /dev/sda3 [/home]: group quotas turned off /dev/sda3 [/home]: user quotas turned off