大网数据广告活动
服务器运维问答

Finding used space on CentOS

· 52CE 我爱测

I have a couple of servers that are approaching capacity, however I can't seem to find where the space is being consumed? When I run: [root@server /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root …

问题原文

原帖链接 · cpjones44 · CC BY-SA 4.0

I have a couple of servers that are approaching capacity, however I can't seem to find where the space is being consumed? When I run:

[root@server /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       40G   38G   76M 100% /
tmpfs                 929M     0  929M   0% /dev/shm
/dev/sda1             485M   32M  428M   7% /boot

I can see that the / mount is filling up, so I then run:

[root@server /]# sudo ls | xargs du -hs
5.8M    bin
22M     boot
192K    dev
25M     etc
36K     home
122M    lib
19M     lib64
16K     lost+found
4.0K    media
4.0K    mnt
4.0K    opt
0       proc
124K    root
14M     sbin
0       selinux
4.0K    srv
0       sys
54M     tmp
749M    usr
61M     var

and can't see any real directories that are using heaps of space. The biggest one is /usr at 749M.

Can someone please suggest how I can find out where all this space is being chewed up? Thanks.

已采纳解答

原帖链接 · guzzijason · CC BY-SA 4.0

Often times when something like this happens, it is due to some process keeping filehandles open on deleted (unlinked) files. If this is the case, you can find them by using lsof, for example:

$ sudo lsof +L1
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NLINK    NODE NAME
tuned   869 root    7u   REG  202,1     4096     0 4194380 /tmp/ffiGemRJt (deleted)
$

If you find deleted files are consuming much of your space, then it will probably be necessary to restart the offending process that is keeping the filehandles open.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-10-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。