磁盘空间满了解决办法
Posted faithh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了磁盘空间满了解决办法相关的知识,希望对你有一定的参考价值。
案例:df -h 磁盘空间还剩余很多,但是还是报错 no space left on device 。
1、 磁盘空间满了之 block满了
block是用来存储数据的,每个block的大小一般有1k、2k、4k几种,其中引导分区等为1k,其他普通分区多为4k。
[root@linux ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 8.8G 1.6G 6.8G 19% / tmpfs 931M 0 931M 0% /dev/shm /dev/sda1 190M 40M 141M 22% /boot /dev/sdc 73K 14K 55K 21% /app/logs [root@linux ~]# cd /app/logs/ [root@linux logs]# ls -lh /bin/ls -rwxr-xr-x. 1 root root 115K Mar 23 02:52 /bin/ls [root@linux logs]# cp /bin/ls /app/logs/ cp: writing `/app/logs/ls‘: No space left on device [root@linux logs]# cp /bin/awk /app/logs/ cp: writing `/app/logs/awk‘: No space left on device [root@linux logs]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 8.8G 1.6G 6.8G 19% / tmpfs 931M 0 931M 0% /dev/shm /dev/sda1 190M 40M 141M 22% /boot /dev/sdc 73K 70K 0 100% /app/logs [root@linux logs]# cd /app/logs/ [root@linux logs]# ls -lh total 68K -rwxr-xr-x 1 root root 0 May 20 12:39 awk drwx------ 2 root root 12K May 20 12:36 lost+found -rwxr-xr-x 1 root root 56K May 20 12:39 ls
解决办法:删除一些大文件
[root@linux logs]# m -f ls [root@linux logs]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 8.8G 1.6G 6.8G 19% / tmpfs 931M 0 931M 0% /dev/shm /dev/sda1 190M 40M 141M 22% /boot /dev/sdc 73K 14K 55K 21% /app/logs
2、磁盘空间满了之 inode用光了
inode 称为索引节点(编号)<=>相当于人的身份证,家庭住址,全国唯一(在不同的分区中是独一无二的)作用存放文件的属性信息及block的位置。
[root@linux logs]# pwd /app/logs [root@linux logs]# touch {1..6}.txt touch: cannot touch `6.txt‘: No space left on device [root@linux logs]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 8.8G 1.6G 6.8G 19% / tmpfs 931M 0 931M 0% /dev/shm /dev/sda1 190M 40M 141M 22% /boot /dev/sdc 73K 14K 55K 21% /app/logs [root@linux logs]# touch test.txt touch: cannot touch `test.txt‘: No space left on device [root@oldboy-40 logs]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda3 593344 57034 536310 10% / tmpfs 238282 1 238281 1% /dev/shm /dev/sda1 51200 39 51161 1% /boot /dev/sdc 16 16 0 100% /app/logs [root@oldboy-40 logs]# ls -l total 12 -rw-r--r-- 1 root root 0 May 20 12:43 1.txt -rw-r--r-- 1 root root 0 May 20 12:43 2.txt -rw-r--r-- 1 root root 0 May 20 12:43 3.txt -rw-r--r-- 1 root root 0 May 20 12:43 4.txt -rw-r--r-- 1 root root 0 May 20 12:43 5.txt drwx------ 2 root root 12288 May 20 12:36 lost+found
解决办法:删除一些小文件
[root@linux logs]# m -f *.txt [root@linux logs]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda3 593344 57034 536310 10% / tmpfs 238282 1 238281 1% /dev/shm /dev/sda1 51200 39 51161 1% /boot
3、block文件没有彻底删除 - 硬链接数为0,进程调用不为o lsof |grep delete
[root@linux logs]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 18G 16.2G 2G 90% / tmpfs 931M 0 931M 0% /dev/shm tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 56M 433M 12% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup tmpfs 98M 0 98M 0% /run/user/0 [root@linux-node1 ~]# du -sh /* 0 /bin 103M /boot 0 /dev 36M /etc 0 /home 0 /lib 0 /lib64 0 /media 0 /mnt 974M /opt du: cannot access ‘/proc/80695/task/80695/fd/4’: No such file or directory du: cannot access ‘/proc/80695/task/80695/fdinfo/4’: No such file or directory du: cannot access ‘/proc/80695/fd/4’: No such file or directory du: cannot access ‘/proc/80695/fdinfo/4’: No such file or directory 0 /proc 2.6M /root 50M /run 0 /sbin 0 /srv 0 /sys 4.0K /tmp 4.7G /usr 502M /var
解决办法: lsof |grep delete查找没有关闭的调用进程 重启该进程 [root@linux ~]# lsof |grep deleted rsyslogd 1248 root 1w REG 8,3 4888889152 140769/var/log/messages (deleted) [root@linux ~]# /etc/init.d/rsyslog restart Shutting down system logger: [ OK ] Starting system logger: [ OK ] [root@linux logs]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 18G 6.3G 12G 35% / tmpfs 931M 0 931M 0% /dev/shm tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 56M 433M 12% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup tmpfs 98M 0 98M 0% /run/user/0
以上是关于磁盘空间满了解决办法的主要内容,如果未能解决你的问题,请参考以下文章