2021-05-12 14:32:11
Quota+Samba實現共用配額
一、檢查quota是否安裝:
[root@localhost ~]# rpm -qa | grep quota
quota-3.13-1.2.5.el5
二、檢查、設定磁碟掛載選項
1.設定quota前
[root@localhost ~]# cat /etc/fstab |grep sdc
UUID="d6c99ad6-0c55-46e8-b9ac-68e19c3c3c12" /sdc ext2 defaults 1 1
[root@localhost ~]# mount |grep /dev/sdc
/dev/sdc on /sdc type ext2 (rw)
2.修改quota設定
[root@localhost ~]# cat /etc/fstab |grep sdc
UUID="d6c99ad6-0c55-46e8-b9ac-68e19c3c3c12" /sdc ext2 defaults,usrquota,grpquota 1 1
[root@localhost ~]# umount /dev/sdc
[root@localhost ~]# mount -a (無報錯即可成功掛載。)
[root@localhost ~]# mount |grep /sdc
/dev/sdc on /sdc type ext2 (rw,usrquota,grpquota)
三、建立使用者、組,設定磁碟限額
1.建立使用者、組
[root@localhost ~]# groupadd share
[root@localhost ~]# useradd user1 -g share
2.建立配額檔案
[root@localhost sdc]# quotacheck -cumg /sdc
[root@localhost sdc]# ls
aquota.group aquota.user lost+found
3.建立使用者配額
shell命令建立
[root@localhost sdc]# setquota -u user1 102400 102400 0 0 /sdc
軟限制容量50M,硬限制100M,限制300個檔案、目錄,
edquota建立(類似vi)
[root@localhost 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.開啟配額
[root@localhost sdc]# quotaon -avug
/dev/sdc [/sdc]: group quotas turned on
/dev/sdc [/sdc]: user quotas turned on
四、smb設定
[root@localhost 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。
本文永久更新連結地址:http://www.linuxidc.com/Linux/2017-02/141174.htm
相關文章