Xfs

xfs:在前 1 TB 上查找文件

  • January 14, 2013

我被 xfs’No space left on device擊中了。根據常見問題解答:

http://xfs.org/index.php/XFS_FAQ#Q:_Why_do_I_receive_No_space_left_on_device_after_xfs_growfs.3F

解決此問題的唯一方法是移動數據以釋放 1TB 以下的空間。找到最舊的數據(即在第一次增長之前就已經存在)並將其移出文件系統(移動,而不是複制)。然後,如果您將其複制回去,數據塊最終將超過 1TB,這將為您留出足夠的空間用於 1TB 以下的 inode。

但是我如何辨識要移動的數據呢?我不能按年齡計算,因為前 10 TB 是在同一天使用rsync.

我試過了:

xfs_db -r -c "blockget -i 1 -n -v" /dev/md3

但我似乎只得到文件的基本名稱,而不是文件的完整路徑。而且由於我的很多文件都被稱為相同的(但在不同的目錄中),所以這不是很有用。此外,它似乎給了我更多的資訊,只是 inode 1。

我有一種感覺,我可以使用xfs_db它來告訴我前 1 TB 中哪些文件正在使用塊,但我一直無法看到如何使用。

(通過使用掛載選項inode64,文件系統不會給出No space left on device,但是如果您以後忘記使用 mount 選項inode64,那麼您將再次得到No space left on device。我想避免掛載選項inode64,因為文件系統可能被其他人安裝在其他系統上,他們忘記這一點,從而得到一個令人驚訝的No space left on device)。

Quick & Dirty 範例(刪除內聯註釋,調整數字):

# select filesystem
find / -xdev -type f -print0 | \
 xargs -0r -I{} \
   # execute xfs_bmap on every file (and prefix output with path for later processing)
   sh -c "xfs_bmap -v {} | awk '{gsub(/\.\./,\" \"); print \"{}: \" \$0}'" | \
   # remove some cruft
   awk -F: '$4 != ""{print $1 " " $4}' | \
   # print line if last block < 1TB/512B/block and size (in 512B blocks) > 100.
   awk '$3 < 1024*1024*1024*1024/512 && $7 > 100{print}'

嘗試使用該-o inode64選項(重新)掛載您的文件系統,看看這是否已經解決了您的問題,但請注意man mount

inode64
Indicates  that XFS is allowed to create inodes at any location in the filesystem, including those
which will result in inode numbers occupying more than 32 bits of significance.  This is  provided
for  backwards compatibility, but causes problems for backup applications that cannot handle large
inode numbers.

引用自:https://serverfault.com/questions/463940