《LINUX学习:Linux磁盘空间占满故障解决方法》要点: 本文介绍了LINUX学习:Linux磁盘空间占满故障解决方法,希望对您有用。如果有疑问,可以联系我们。
当磁盘被某大文件占满时,并且此大文件正在被某些进程读写并占用着,此时无法删除和置空此文件,只能先找到占用大文件的进程,然后终止进程,最后置空此文件.
实例如下:在/boot分区中创建大文件test,将boot分区的磁盘占满,通过另外一个终端进入主机,vim编纂此test文件,模拟大文件被vim进程占用,然后删除和清空此test文件.
终端1 [root@CentOS7 ~]# df -h? /boot/? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #查看boot分区大小 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? ? ? #创建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在创建好大文件后,启用终端2,vim编纂此文件,模拟此文件被占用
[root@centos7boot]# vim test 1 ~? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ~? ?
回到终端1中进行删除文件
[root@centos7 ~]# rm -rf/boot/test? ? ? ? ? ? ? ? ? ? ? ? ? ? #无法删除此年夜文件 [root@centos7 ~]# df -h /boot? ? ? ? ? ? ? ? ? ? ? ? ? ? #发现此年夜文件并没有被删除 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? ? ? ? ? ? ? ? ? ? ? ? ? #验证发现此文件已经被清空 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培训学院每天发布《LINUX学习:Linux磁盘空间占满故障解决方法》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|