前言
df 指令顯示的可用空間與實際可用空間不符,這是因為 ext4 保留了一部分空間,預設為 5%,但是這個預設值對於現在的大容量硬碟來說已經不太合適了,可以透過 tune2fs 指令來調整。
查看保留區塊
| 1
2
3
4
5
 | $  df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/partition        198G  180G   14G  93% /
/dev/sda1              99M   41M   54M  44% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
 | 
| 1
2
 | $ tune2fs -l /dev/partition  | grep 'Reserved'
Reserved block count:     120542571
 | 
以百份比調整保留區塊
| 1
2
3
 | $ tune2fs -m2 /dev/partition
tune2fs 1.39 (29-May-2006)
Setting reserved blocks percentage to 2% (48223887 blocks)
 | 
你可以使用 tune2fs -m0 /dev/partition 來關閉保留區塊,但是這樣做是不安全的,因為當磁碟空間不足時,系統可能會因為無法寫入而發生錯誤。
以絕對值調整保留區塊
| 1
2
3
 | $ tune2fs -r 48223887 /dev/partition
tune2fs 1.39 (29-May-2006)
Setting reserved blocks percentage to 2% (48223887 blocks)
 |