![Linux 上的磁碟空間不足](https://rvso.com/image/1475805/Linux%20%E4%B8%8A%E7%9A%84%E7%A3%81%E7%A2%9F%E7%A9%BA%E9%96%93%E4%B8%8D%E8%B6%B3.png)
我的磁碟空間不足(10GB 中使用了 71%)
df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 9.8G 6.5G 2.8G 71% /
udev 10M 0 10M 0% /dev
tmpfs 3.0G 128K 3.0G 1% /run
/dev/disk/by-uuid/af9b99b8-9f61-4eee-aa51-d5113368814d 9.8G 6.5G 2.8G 71% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 6.0G 0 6.0G 0% /run/shm
tmpfs 1.0G 6.1M 1018M 1% /mnt/tmp
但是當我運行這個命令來檢查時,我只使用了 1.5G
sudo du --all --one-file-system / | awk '{if($1 > 102400) print int($1/1024) "MB" " " $2 }'
117MB /var/cache/apt/archives
164MB /var/cache/apt
168MB /var/cache
132MB /var/lib/apt/lists
132MB /var/lib/apt
148MB /var/lib
416MB /var
115MB /lib/modules/3.16.0-0.bpo.4-amd64/kernel/drivers
159MB /lib/modules/3.16.0-0.bpo.4-amd64/kernel
163MB /lib/modules/3.16.0-0.bpo.4-amd64
163MB /lib/modules
175MB /lib
223MB /usr/lib
146MB /usr/local/lib
106MB /usr/local/share
267MB /usr/local
199MB /usr/share
754MB /usr
1541MB /
有任何想法嗎?
答案1
如果一個進程有一個已刪除的大檔案的開啟檔案句柄,那麼它仍然會出現在磁碟使用情況中,但該檔案將無法存取並且不會出現在du
.
# Create large file
$ df .
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 1951845952 284650968 1666682984 15% 35645369 208335373 15% /
$ du -s
2604488 .
# Remove the file -note how the du result decreases
$ rm junk
$ df .
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 1951845952 285526568 1665807384 15% 35754819 208225923 15% /
$ du -s
61728 .
# Kill the process holding the file - now the df usage decreases
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 1951845952 282561000 1668772952 15% 35384123 208596619 15% /
$ du -s
61736 .