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

du -sh * show significant more used space that ls -lah

· 52CE 我爱测

I am having trouble with running out of diskspace of one of my clients servers. The output of the commands ls -lah in /var/lib/mysql shows: drwx------ 2 mysql mysql 16K Dec 30 2015 database_xyz But when I check the filesize in th…

问题原文

原帖链接 · Orphans · CC BY-SA 3.0

I am having trouble with running out of diskspace of one of my clients servers.

The output of the commands ls -lah in /var/lib/mysql shows:

drwx------  2 mysql mysql  16K Dec 30  2015 database_xyz

But when I check the filesize in the same catalogue with the command du -sh *, the output shows:

22G     database_xyz

Why does the output of thoose commands shows two completely different results?

I have only 2.2GB left on the drive.

root@jon-cust-lifeincity:/var/lib/mysql# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg-root    49G   44G  2.2G  96% /
tmpfs                1007M     0 1007M   0% /lib/init/rw
udev                 1002M  108K 1002M   1% /dev
tmpfs                1007M     0 1007M   0% /dev/shm
/dev/sda1             228M   16M  200M   8% /boot

EDIT:

Turns out that database_xyz is in fact a catalogue, not a file. So the confusion was made up by my brain.

已采纳解答

原帖链接 · user9517 · CC BY-SA 3.0

It seems that you have a misunderstanding about what you are being told. The ls -lah command lists the contents of the current directory. In this particular case that's /var/lib/mysql. Amongst other things you were told this

drwx------  2 mysql mysql  16K Dec 30  2015 database_xyz

You are misunderstanding what this is telling you.

You can consider a directory to be like a flat file containing a list of directory entries. (simply) A directory entry is a file name and a pointer to where that file resides on disk. This information takes up disk space.

What

drwx------  2 mysql mysql  16K Dec 30  2015 database_xyz

is telling you is that there is a directory entry in /var/lib/mysql called database.xyz. That entry is for a file type d which indicates it is a directory and amongst other things the size of the directory 'file' is 16K.

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

资料来源与适用范围

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

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

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