磁碟配額配置文檔(for linux平台)
一.配置yum,以便安裝軟體包
yum全局文件編輯目錄: /etc/yum.repos.d/rhel-source.repo
[root@wanghong ~]# vim //etc/yum.repos.d/rhel-source.repo
#[rhel-source]
#name=Red Hat Enterprise Linux $releasever - $basearch - Source
#baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/SRPMS/
#enabled=0
#gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
#[rhel-source-beta]
#name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
#baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
#enabled=0
#gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[wanghong]
Name=123
Baseurl=file:///mnt/Server
enable=1
gpgcheck=0
備註: #是註釋作用,在此對文件沒用任何影響,可以去掉
二.安裝quota軟體包,設置磁碟配額
1.Quota軟體包的安裝
[root@wanghong ~]#yum install quota
或者通rpm直接安包程序包quota-3.17-16.el6.i686.rpm
[root@wanghong ~]#rpm -ivh /mnt/Packages/ quota-3.17-16.el6.i686.rpm --force
2.設置磁碟配額
查看quota磁碟配額命令和程序
[root@wanghong ~]#rpm -q
quotaquota-3.17-16.el6.i686
[root@wanghong ~]#rpm -ql quota | grep sbin
/sbin/quotacheck
/sbin/quotaoff
/sbin/quotaon
/usr/sbin/convertquota
/usr/sbin/edquota
/usr/sbin/quota_nld
/usr/sbin/quotastats
/usr/sbin/repquota
/usr/sbin/rpc.rquotad
/usr/sbin/setquota
/usr/sbin/warnquota
磁碟配額前,請確定selinux處於關閉狀態(如果不關閉會對磁碟配額文件生成有影響)
[root@wanghong ~]#vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=0
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@wanghong ~]#setenforce 0 (此命令作用是不需要重啟系統,使配置文件生效)
以支持磁碟配額功能的方式掛載文件系統
[root@wanghong ~]#mount –o usrquota,grpquota
/dev/sdb1 /mailbox[root@wanghong ~]#mount | grep “quota”
/dev/sdb1 on /mailbox type ext4 (rw,usrquota,grpquota)
[root@wanghong ~]#chmod 1777 /mailbox
[root@wanghong ~]#ls –ld /mailbox
drwxrwxrwt. 3 root root 4096 3月 9 01:37 /mailbox/
如果想每次開機的時候自動掛載設備/dev/sdb1,需要改寫fstab文件
[root@wanghong ~]#vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Mar 8 18:28:47 2012
#
# 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=3ab52870-7c41-432c-9efc-028ff51128e4 / ext4 defaults 1 1
UUID=4229ee15-f92f-4510-89dc-3f2816f6cc77 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 /mailbox ext4 defaults,usrquota,grpquota 0 0
檢測磁碟配額並生成配額文件
[root@wanghong ~]#quotacheck -augcv
-a 表示掃描所有分區, -u -g表示檢測用戶和組的配額信息,
-c 表示創建新的配額文件,-v 表示顯示命令執行過程中的細節信息確定/mailbox下會生成用戶配額文件和組
[root@wanghong ~]#ls -l /mailbox/auota.*
-rw-------. 1 root root 7168 3月 9 01:37 /mailbox/aquota.group
-rw-------. 1 root root 7168 3月
9 01:37 /mailbox/aquota.user編輯用戶和組賬號的配額設置
[root@wanghong ~]#edquota -u zhangsan
Disk quotas for user zhangsan (uid 500):
Filesystem blocks soft hard inodes
soft hard/dev/sdb1 0 2048 3072 0 0 0
Filesystem:表示本行配置記錄對應的文件系統(分區),即配額的作用範圍
block: 表示用戶當前已經使用的磁碟容量,默認單位為
KB,該數值由edquota程序自動計算,無需修改inodes: 表示用戶當前已經擁有的文件數量(即佔有i節點的個數),該數值也是由
edquota程序自動計算的soft:第3列中的soft對應的磁碟容量的軟限制數值,默認單位為
KB,第6列中的soft對應為文件數量的軟限制數值,默認單位為個hard:
第4列中的hard對應為磁碟容量的硬限制數值,默認單位為KB,第7列中的 hard對應為文件數量的硬限制數值,默認單位為個
進行配額限制時,只需修改相應的soft、hard
列下的數值即可,其他的數值或文字不要修改(也無需修改)[root@wanghong ~]#edquota -g test(組名) 修改配置同上
3.啟動文件系統的磁碟配額功能
[root@wanghong ~]#quotaon -ugv /mailbox
/dev/sdb1 [/mailbox]: group quotas turned on
/dev/sdb1 [/mailbox]: user quotas turned on
4.驗證磁碟配額功能
以用戶zhangsan登錄,分別拷取不同大小的文件(1M,
2M,2.5M,3M,4M)到/mailbox目錄底下5.查看用戶或分區的配額使用狀況
[root@wanghong ~]#quota –u zhangsan
Disk quotas for user zhangsan (uid 500): none
[root@wanghong ~]#quota -g users
Disk quotas for group users (gid 100): none
[root@wanghong ~]#repquota /mailbox 查看/mailbox文件系統的配額使用情況
*** Report for user quotas on device /dev/sdb1
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20 0 0
2 0 0
本文出自 「學海無涯苦作舟!」 博客,謝絕轉載!
[火星人 ] 磁碟配額配置文檔(for linux平台)已經有763次圍觀