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

調整 ext 文件系統保留空間:tune2fs 釋放 5% 預留區塊提升可用容量

編輯:Linux 教學

現象解釋

df -h 顯示已用 + 可用 < 總容量,差額即為保留空間。ext2/3/4 預留 5% 給 root 用戶,確保系統滿載時仍能寫入關鍵日誌、進行救援操作。

查看保留空間詳情

tune2fs -l /dev/sda2 | grep -i block
# 輸出範例:
Block count: 4641536
Reserved block count: 232076   # 正好 5%
Free blocks: 2762496
Block size: 4096
Reserved blocks uid: 0 (root)
Reserved blocks gid: 0 (root)

調整保留比例

按百分比調整(推薦)

# 將保留空間從 5% 降為 1%
tune2fs -m 1 /dev/sda2
# 輸出:Setting reserved blocks percentage to 1% (46415 blocks)

# 立即生效,df -h 可見可用空間增加

指定固定區塊數

# 保留固定 1000 個區塊(約 4MB)
tune2fs -r 1000 /dev/sda2

調整策略建議

分區類型建議保留比例理由
根分區 (/)1-2%系統關鍵,需保留緩衝
/var, /home1%資料分區,降低浪費
資料專用分區0% (-m 0)純資料存儲,無系統風險
小容量分區 (<10GB)5% 或固定值避免保留過少導致碎片化

注意事項

  • 調整後立即生效,無需重啟或卸載
  • 僅適用 ext2/3/4,XFS、Btrfs 無此機制
  • 保留空間過低可能導致磁碟滿時系統無法寫入關鍵日誌,謹慎評估
  • 生產環境建議根分區保留至少 1%
Copyright © Windows教程網 All Rights Reserved