Ubuntu 18.04 中空間不足(並刪除一些檔案)後無法復原磁碟空間

Ubuntu 18.04 中空間不足(並刪除一些檔案)後無法復原磁碟空間

這真讓我抓狂!我的伺服器空間不足。我透過刪除資料夾清理了一些檔案。可用空間量沒有增加(以百分比計算)。這就是我現在看到的:

在此輸入影像描述

如您所見,它顯示 315GB 大小,其中 298GB 正在使用。那為什麼顯示100%已使用呢?我有 1.1GB 空閒空間的唯一原因是,您可以看到是否由於刪除了更多檔案而導致重新啟動。儘管我之前刪除了 15+GB 的檔案:/

我已經嘗試了很多事情,例如lsof +L1

    COMMAND    PID      USER   FD   TYPE DEVICE SIZE/OFF NLINK  NODE NAME
php-fpm7.  726      root    3u   REG    8,0        0     0   605 /tmp/.ZendSem.sRUIJj (deleted)
mysqld     863     mysql    5u   REG    8,0        0     0  2938 /tmp/ibj2MjTy (deleted)
mysqld     863     mysql    6u   REG    8,0        0     0 10445 /tmp/ibgsRaLu (deleted)
mysqld     863     mysql    7u   REG    8,0        0     0 76744 /tmp/ibx2g3Cq (deleted)
mysqld     863     mysql    8u   REG    8,0        0     0 76750 /tmp/ib7D93oi (deleted)
mysqld     863     mysql   12u   REG    8,0        0     0 77541 /tmp/ibSr0xre (deleted)
dovecot   1278      root  139u   REG   0,23        0     0  2021 /run/dovecot/login-master-notify6ae65d15ebbecfbf (deleted)
dovecot   1278      root  172u   REG   0,23        0     0  2022 /run/dovecot/login-master-notify4b18cb63ddb75aab (deleted)
dovecot   1278      root  177u   REG   0,23        0     0  2023 /run/dovecot/login-master-notify05ff81e3cea47ffa (deleted)
cron      2239      root    5u   REG    8,0        0     0  1697 /tmp/#1697 (deleted)
cron      2240      root    5u   REG    8,0        0     0 77563 /tmp/#77563 (deleted)
sh        2243      root   10u   REG    8,0        0     0  1697 /tmp/#1697 (deleted)
sh        2243      root   11u   REG    8,0        0     0  1697 /tmp/#1697 (deleted)
sh        2244      root   10u   REG    8,0        0     0 77563 /tmp/#77563 (deleted)
sh        2244      root   11u   REG    8,0        0     0 77563 /tmp/#77563 (deleted)
imap-logi 2512  dovenull    4u   REG   0,23        0     0  2023 /run/dovecot/login-master-notify05ff81e3cea47ffa (deleted)
imap-logi 3873  dovenull    4u   REG   0,23        0     0  2023 /run/dovecot/login-master-notify05ff81e3cea47ffa (deleted)
pop3-logi 3915  dovenull    4u   REG   0,23        0     0  2021 /run/dovecot/login-master-notify6ae65d15ebbecfbf (deleted)
pop3-logi 3917  dovenull    4u   REG   0,23        0     0  2021 /run/dovecot/login-master-notify6ae65d15ebbecfbf (deleted)
php-fpm7. 4218    fndesk    3u   REG    8,0        0     0   605 /tmp/.ZendSem.sRUIJj (deleted)
php-fpm7. 4268 executive    3u   REG    8,0        0     0   605 /tmp/.ZendSem.sRUIJj (deleted)

但我看不到任何鎖定文件的東西

答案1

在刪除某些內容之前,找出正在佔用磁碟空間的內容,然後找出原因。

要顯示“前 10 個目錄”,您可以使用du -Sh / | sort -rh | head -10.

要顯示“前 10 個”文件”,您可以使用find / -type f -exec du -Sh {} + | sort -rh | head -n 10.

通常,您會發現巨大的或未旋轉的日誌文件,或快速填充的日誌文件。根據您的發現,有時刪除一些較舊的日誌檔案、設定日誌輪替或設定服務的日誌設定就足夠了。

關於你的計算:這不必讓你發瘋:-)

檔案系統通常會保留 5% 的空間供 root 使用者使用。您的磁碟大小為 315G,因此 5% 約為 16G 保留空間。有一篇很好的文章解釋了背景:https://blog.tinned-software.net/utility-df-shows-inconsistency-calculation-for-ext-filesystems/

相關內容