Linux Quota的配置實戰
增加了一個硬碟/dev/hdb1,用於存放使用者資料,掛載在/home/extra下。
1、修改/etc/fstab
/dev/hdb1 /home/extra ext3 defaults,noatime,usrquota,grpquota 1 2
紅色部分為增加的部分,注意逗號之間沒有空格。
2、建立配額檔案
# cd /home/extra
#touch aquota.user
#touch aquota.group
#chmod 600 aquota.user
#chmod 600 aquota.group
Quota使用了新的配額檔案,舊的檔案是quota.user和quota.group
如果用了這兩個舊檔案格式,啟動Quota的時候會出現錯誤:“Quota format not supported in kernel”
可以使用convertquota命令來轉換。
3、重新掛載/dev/hdb1
# mount -o remount /home/extra
4、掃描磁碟,初始化配額表
#quotacheck -uvg /home/extra
5、為使用者設定磁碟配額
# edquota -u test
Disk quotas for user test (uid 517):
Filesystem blocks soft hard inodes soft hard
/dev/hdb1 0 0 0 0 0 0
可以看出該使用者還沒有使用任何硬碟。各個欄位的含義:
blocks:已經使用的磁碟塊(1k bytes)
soft:軟限額大小,如果使用者超出了這個限額,系統會發出警告,如果在設定的時間內還沒有回到該限額以下,系統將拒絕該使用者使用額外的磁碟空間。
hard:硬限額,使用者不允許超出的磁碟限制
inodes:使用者已經使用的inodes數
soft和hard含義同上,不過,這裡是限制使用者建立的檔案/目錄總數。
限定25G, 最大30G,修改為:
Disk quotas for user test (uid 517):
Filesystem blocks soft hard inodes soft hard
/dev/hdb1 0 26214400 31457280 0 0 0
如果要設定整個群組能使用的磁碟限額,可以用下面的命令:
#edquota -g testgrp
6、修改軟限額期限
# edquota -t
Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/dev/hdb1 7days 7days
預設為7天,修改為希望的值,比如3天。
7、複製到其他使用者
可以一個一個的複製:
# edquota -p test test1
也可以使用awk命令來批處理:
edquota -p test `awk -F: '$3 > 499 {print $1}' /etc/passwd`
複製到uid大於499的所有使用者,我的系統上有一個使用者nfsnobody也符合這個條件,手動關閉它的限額。
# edquota -u nfsnobody
soft和hard改為0
8、啟動磁碟配額
# quotaon -av
9、檢視磁碟配額
整體使用情況:
# repquota -a
*** Report for user quotas on device /dev/hdb1
Block grace time: 3days; Inode grace time: 3days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 195616 0 0 4 0 0
檢視使用者的配額情況:
# quota -vu test
Disk quotas for user test (uid 517):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdb1 0 26214400 31457280 0 0 0
10、關閉Quota
#quotaoff -av
11、其他應用
可以對WWW空間、FTP空間、Email空間進行磁碟配額限制。
注意:Quota只能基於磁碟分割槽進行配額管理,不能基於目錄進行配額管理,因此只能把資料存放在有配額限制的分割槽,再用符號連結到實際應用的目錄。
參考文章:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9697/viewspace-1024961/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux磁碟配額Quota配置Linux
- Linux下的磁碟配額quotaLinux
- Linux磁碟配額(Quota)(轉)Linux
- quota 筆記筆記
- ext3格式下的quota的實現(轉)
- Linux環境下MySQL5.6Master-Slave配置實戰LinuxMySqlAST
- 【GNU/Linux實戰手記之安裝配置篇】 (轉)Linux
- linux實戰(1)Linux
- Oracle的表空間quota詳解Oracle
- oracle的表空間quota詳講Oracle
- Nuxt.js實戰和配置UXJS
- BIOS實戰之Memory配置iOS
- Flink實戰(102):配置(一)管理配置
- TSM LINUX 實驗配置Linux
- Flume NG 簡介及配置實戰
- 實戰:Nacos配置中心的Pull原理,附原始碼原始碼
- Linux 企業實戰篇Linux
- Linux入門到實戰Linux
- linux搭建webapp實戰LinuxWebAPP
- Netweaver和SAP雲平臺的quota管理
- Spring Boot 2 實戰:常用讀取配置的方式Spring Boot
- HBase多租戶-Namespace Quota管理namespace
- Spring Boot 外部化配置實戰解析Spring Boot
- Dubbo使用Apollo作為配置中心實戰
- Spring Boot外部化配置實戰解析Spring Boot
- # Spring Boot 外部化配置實戰解析Spring Boot
- ECS實戰之IPv6隧道配置
- Nginx實戰(三) 日誌配置與切割Nginx
- Spring Boot自動配置原理、實戰Spring Boot
- 實戰 SQL Server 2005 映象配置SQLServer
- webpack實戰(一):真實專案中一個完整的webpack配置Web
- 【linux】helloword原理分析及實戰Linux
- Linux效能優化實戰(一)Linux優化
- Linux效能優化實戰(二)Linux優化
- 理論+實驗:Linux的DHCP原理與配置Linux
- solaris 10_相關命令_quota_
- springboot使用redis(從配置到實戰)Spring BootRedis
- 【SpringBoot實戰】核心配置和註解Spring Boot