在linux下,使用df -h
命令查看磁盘空间使用量,显示已使用了100%,而实际用到的远没有那么多。
root@iZ94yakhyenZ:/# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 20G 0 100% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 990M 4.0K 990M 1% /dev
tmpfs 201M 384K 200M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1001M 0 1001M 0% /run/shm
none 100M 0 100M 0% /run/user
用du -h
查看,根目录下的用量为6.8G。
root@iZ94yakhyenZ:/# du --max-depth=1 -h
4.0K ./opt
9.6M ./bin
384K ./run
4.0K ./srv
4.0K ./lib64
0 ./sys
8.5M ./sbin
34M ./boot
4.0K ./home
4.0K ./dev
du: cannot access './proc/12212/task/12212/fd/4': No such file or directory
du: cannot access './proc/12212/task/12212/fdinfo/4': No such file or directory
du: cannot access './proc/12212/fd/4': No such file or directory
du: cannot access './proc/12212/fdinfo/4': No such file or directory
0 ./proc
283M ./lib
24K ./tmp
28K ./root
4.0K ./media
2.1G ./mnt
803M ./usr
16K ./lost+found
3.7G ./var
4.7M ./etc
6.8G .
系统为ubuntu14.04,是运行在阿里云上的虚拟机。
是什么原因导致这种现象呢?
A feature of Linux is that if you delete a file that is being opened by a running program, although it seems that the file is no longer there, it still takes up disk space.
You can run
lsof|grep delete
to see a list of all open but deleted files and find out which one is the log file.Usually it is the log of apache or nginx. At this time, you need to restart apache or nginx.
You deleted the log in use. . .
So, find the corresponding process and restart it.