一、检查quota是否安装:
[[email protected] ~]# rpm -qa | grep quota
quota-3.13-1.2.5.el5
二、检查、配置磁盘挂载选项
1.配置quota前
[[email protected] ~]# cat /etc/fstab |grep sdc
UUID="d6c99ad6-0c55-46e8-b9ac-68e19c3c3c12" /sdc ext2 defaults 1 1
[[email protected] ~]# mount |grep /dev/sdc
/dev/sdc on /sdc type ext2 (rw)
2.修改quota配置
[[email protected] ~]# cat /etc/fstab |grep sdc
UUID="d6c99ad6-0c55-46e8-b9ac-68e19c3c3c12" /sdc ext2 defaults,usrquota,grpquota 1 1
[[email protected] ~]# umount /dev/sdc
[[email protected] ~]# mount -a (无报错即可成功挂载。)
[[email protected] ~]# mount |grep /sdc
/dev/sdc on /sdc type ext2 (rw,usrquota,grpquota)
三、创建用户、组,配置磁盘限额
1.创建用户、组
[[email protected] ~]# groupadd share
[[email protected] ~]# useradd user1 -g share
2.创建配额文件
[[email protected] sdc]# quotacheck -cumg /sdc
[[email protected] sdc]# ls
aquota.group aquota.user lost+found
3.创建用户配额
shell命令创建
[[email protected] sdc]# setquota -u user1 102400 102400 0 0 /sdc
软限制容量50M,硬限制100M,限制300个文件、目录,
edquota创建(类似vi)
[[email protected] sdc]# edquota -u user1
Disk quotas for user user1 (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdc 0 102400 102400 0 300 500
4.开启配额
[[email protected] sdc]# quotaon -avug
/dev/sdc [/sdc]: group quotas turned on
/dev/sdc [/sdc]: user quotas turned on
四、smb配置
[[email protected] samba]# tail smb.conf
; writable = yes
; printable = no
; write list = +staff
[sdc]
comment = sdc
path = /sdc/share
public = no
writable = yes
guest ok = no
valid users = user1
五、验证
①在windows上映射磁盘,显示分区为100M
②在Linux上挂载,显示为共享磁盘的原始容量。
但是测试往磁盘写200M数据,只能成功写入100M。