《LINUX學習:Linux磁盤空間占滿故障解決方法》要點:
本文介紹了LINUX學習:Linux磁盤空間占滿故障解決方法,希望對您有用。如果有疑問,可以聯(lián)系我們。
當磁盤被某大文件占滿時,并且此大文件正在被某些進程讀寫并占用著,此時無法刪除和置空此文件,只能先找到占用大文件的進程,然后終止進程,最后置空此文件.
實例如下:在/boot分區(qū)中創(chuàng)建大文件test,將boot分區(qū)的磁盤占滿,通過另外一個終端進入主機,vim編纂此test文件,模擬大文件被vim進程占用,然后刪除和清空此test文件.
終端1
[root@CentOS7 ~]# df -h? /boot/? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #查看boot分區(qū)大小
Filesystem? ? ? Size? Used Avail Use% Mounted on
/dev/sda1? ? ? 997M? 110M? 887M? 12% /boot
[root@centos7 ~]# dd? if=/dev/zero of=/boot/test bs=1M count=900? ? ? #創(chuàng)建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
[root@centos7 ~]#
?
終端2在創(chuàng)建好大文件后,啟用終端2,vim編纂此文件,模擬此文件被占用
[root@centos7boot]# vim test
1
~? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
~? ?
回到終端1中進行刪除文件
[root@centos7 ~]# rm -rf/boot/test? ? ? ? ? ? ? ? ? ? ? ? ? ? #無法刪除此年夜文件
[root@centos7 ~]# df -h /boot? ? ? ? ? ? ? ? ? ? ? ? ? ? #發(fā)現(xiàn)此年夜文件并沒有被刪除
Filesystem? ? ? Size Used Avail Use% Mounted on
/dev/sda1? ? ? 997M 997M? 20K 100% /boot
[root@centos7 ~]# >/boot/test? ? ? ? ? ? ? ? ? ? ? ? ? #置空此年夜文件并沒有被置空
-bash: /boot/test: No spaceleft on device
[root@centos7 ~]# df -h /boot
Filesystem? ? ? Size Used Avail Use% Mounted on
/dev/sda1? ? ? 997M 997M? 20K 100% /boot
[root@centos7 ~]# lsof |grep/boot/test
vim? ? ? 6562? ? ? ? root? 3r? ? ? REG? ? ? ? ? ? ? ? 8,1 930045952? ? 456127 /boot/test
root@centos7 ~]# kill 6562? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #殺死此vim的進程
[root@centos7 ~]# >/boot/test? ? ? ? ? ? ? ? ? ? ? ? ? #置空此文件
[root@centos7 ~]# df -h /boot? ? ? ? ? ? ? ? ? ? ? ? ? #驗證發(fā)現(xiàn)此文件已經被清空
Filesystem? ? ? Size Used Avail Use% Mounted on
/dev/sda1? ? ? 997M 110M? 887M? 12% /boot
[root@centos7 ~]# rm -rf/boot/test? ? ? ? ? ? ? ? ? ? #然后刪除此文件
[root@centos7 ~]# ll/boot/test
ls: cannot access/boot/test: No such file or directory
本文永遠更新鏈接地址:
維易PHP培訓學院每天發(fā)布《LINUX學習:Linux磁盤空間占滿故障解決方法》等實戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/9010.html