Linux磁盤空間占滿故障處理
Linux磁盤占滿
當磁盤被某大文件占滿時,而且此大文件正在被某些進程讀寫並占用著,此時無法刪除和置空此文件,只能先找到占用大文件的進程,然後終止進程,最後置空此文件。
實例如下:在/boot分區中創建大文件test,將boot分區的磁盤占滿,通過另外一個終端進入主機,vim編輯此test文件,模擬大文件被vim進程占用,然後刪除和清空此test文件。
終端1 [[email protected] ~]# df -h /boot/ #查看boot分區大小 Filesystem Size Used Avail Use% Mounted on /dev/sda1 997M 110M 887M 12% /boot [[email protected] ~]# dd if=/dev/zero of=/boot/test bs=1M count=900 #創建900M文件,占滿磁盤 dd: error writing ‘/boot/test’: No space left on device 887+0 records in 886+0 records out 930058240 bytes (930 MB) copied, 13.166 s, 70.6 MB/s [[email protected] ~]# |
終端2在創建好大文件後,啟用終端2,vim編輯此文件,模擬此文件被占用
[[email protected]]# vim test 1 ~ ~ |
回到終端1中進行刪除文件
[[email protected] ~]# rm -rf/boot/test # [[email protected] ~]# df -h /boot #發現此大文件並沒有被刪除 Filesystem Size Used Avail Use% Mounted on /dev/sda1 997M 997M 20K 100% /boot [[email protected] ~]# >/boot/test #置空此大文件並沒有被置空 -bash: /boot/test: No spaceleft on device [[email protected] ~]# df -h /boot Filesystem Size Used Avail Use% Mounted on /dev/sda1 997M 997M 20K 100% /boot [[email protected] ~]# lsof |grep/boot/test vim 6562 root 3r REG 8,1 930045952 456127 /boot/test [email protected] ~]# kill 6562 #殺死此vim的進程 [[email protected] ~]# >/boot/test #置空此文件 [[email protected] ~]# df -h /boot #驗證發現此文件已經被清空 Filesystem Size Used Avail Use% Mounted on /dev/sda1 997M 110M 887M 12% /boot [[email protected] ~]# rm -rf/boot/test #然後刪除此文件 [[email protected] ~]# ll/boot/test ls: cannot access/boot/test: No such file or directory |
本文出自 “11831715” 博客,請務必保留此出處http://11841715.blog.51cto.com/11831715/1958463
Linux磁盤空間占滿故障處理