Linux 刪除檔案而沒釋放空間
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos_gp8-root 52401156 52401136 20 100% /
# rm -rf /var/log/nv-hostengine.log
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos_gp8-root 52401156 52401136 20 100% /
有時候沒有正確停止該停掉的程序,會遇到刪除某個檔案而沒有釋放出該檔案所佔用的空間,這時候就要清除該檔案相關的程序才能正確釋放空間。
# lsof|grep deleted
nv-hosten 17859 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
nv-hosten 17859 17870 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
nv-hosten 17859 17871 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
cache_mgr 17859 18131 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
nv-hosten 17859 18139 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
cache_mgr 17859 18143 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
dcgm_ipc 17859 18145 root 22w REG 253,0 12665814398 118637824 /var/log/nv-hostengine.log (deleted)
然後 kill -9 上面的結果,這樣就能釋放出檔案的空間
# kill -9 17859
這個範例 其實應該要正確地停止服務才能有效地移除檔案
# systemctl stop prometheus-dcgm
但是有時候會腦殘忘記