
今天,我的一台 VPS 上的索引節點用完了。
我刪除了一堆多餘的小文件,釋放了足夠的索引節點以使系統再次運行:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/simfs 586K 529K 58K 91% /
我還編寫了一個簡短的命令來給出已用 inode 的數量(本質上列出所有文件及其 inode 編號,過濾掉重複項併計算結果的行數):
sudo find / -xdev -type f -printf '%i~%P\n' > files.txt
<files.txt | sort -u -t'~' -k1,1 > inodes.txt
wc -l files.txt inodes.txt
1513608 files.txt
275320 inodes.txt
因此,看起來檔案/
僅佔 275k inode,但df
報告已使用 529k。
怎麼可能?
(我甚至重新啟動系統以釋放任何仍被進程鎖定的 inode,但這根本沒有改變已使用的 inode 數量。)
答案1
使用綁定安裝而不是-xdev
.此外,目錄也使用索引節點。
mkdir /mnt/somewhere
mount -o bind / /mnt/somewhere
find /mnt/somewhere -printf '%i\n' | sort -u | wc -l