Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

CentOS 6 啟用 EXT4 磁盤配額 完整配置流程

編輯:Linux 教學

在 CentOS 6 上為 EXT4 文件系統啟用用戶/組磁盤配額,限制用戶磁盤使用量,防止單用戶佔滿磁盤導致服務異常。

1. 修改 /etc/fstab 掛載選項

為需配額的分區添加 usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 參數:

/dev/sda3 / ext4 defaults,noatime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0 1
/dev/sda6 /home ext4 defaults,noatime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0 1

2. 重新掛載文件系統

mount -o remount /
mount -o remount /home

3. 創建配額索引文件並啟用

quotacheck -avugm    # 掃描並創建 aquota.user/group 文件
quotaon -avug        # 啟用配額

4. 設置用戶/組配額限制

# 設置用戶配額(軟限制/硬限制,單位:KB)
edquota -u username
# 或批量設置
setquota -u username 1048576 1153433 0 0 /home  # 1GB 軟 / 1.1GB 硬

# 設置組配額
setquota -g groupname 2097152 2202009 0 0 /home  # 2GB 軟 / 2.1GB 硬

5. 查看配額報告

repquota -a          # 所有分區報告
quota -u username    # 單用戶查看
quota -g groupname   # 單組查看

6. cPanel 環境一鍵修復

若運行 cPanel/WHM,可直接使用內建腳本:

/scripts/fixquotas

關鍵參數說明

參數含義
usrjquota=aquota.user用戶配額索引文件名
grpjquota=aquota.group組配額索引文件名
jqfmt=vfsv0配額格式版本(vfsv0 支持 >2TB 分區)
noatime不更新訪問時間,提升性能

常見問題

  • quotacheck 報錯「Cannot find filesystem to check」:確認 /etc/fstab 參數正確且已重新掛載
  • 配額不生效:檢查內核是否支持 CONFIG_QUOTA、CONFIG_QUOTACTL(CentOS 6 默認支持)
  • 軟限制寬限期:默認 7 天,可用 edquota -t 修改

總結

EXT4 磁盤配額通過 jqfmt=vfsv0 支持大分區,配合 quotacheck 初始化、quotaon 啟用、setquota 分配限額,構建完整的磁盤資源管控體系。cPanel 用戶可直接用 /scripts/fixquotas 自動化處理。

Copyright © Windows教程網 All Rights Reserved