我在 VMWare 虚拟机中运行 Ubuntu 16.04。
我的根分区/dev/mapper/vg_ldt-lv_root
几乎已满,它安装到/
:
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 797M 80M 718M 10% /run
/dev/mapper/vg_ldt-lv_root 33G 30G 1.9G 94% /
tmpfs 3.9G 54M 3.9G 2% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1.9G 160M 1.6G 10% /boot
tmpfs 797M 0 797M 0% /run/user/998
tmpfs 797M 88K 797M 1% /run/user/3841712
tmpfs 797M 0 797M 0% /run/user/999
所以我尝试调查磁盘空间的去向。我使用过sudo ncdu
,但只返回 14.2GB:
ncdu 1.11 ~ Use the arrow keys to navigate, press ? for help
--- / ----------------------------------------------------------------
6.1 GiB [##########] /usr
3.4 GiB [##### ] /home
2.0 GiB [### ] /var
1.2 GiB [## ] /opt
917.0 MiB [# ] /lib
372.7 MiB [ ] /root
156.7 MiB [ ] /boot
. 79.4 MiB [ ] /run
30.8 MiB [ ] /etc
14.6 MiB [ ] /sbin
12.8 MiB [ ] /bin
12.4 MiB [ ] /tmp
456.0 KiB [ ] /dev
e 16.0 KiB [ ] /lost+found
12.0 KiB [ ] /emul
8.0 KiB [ ] /isec
8.0 KiB [ ] /McAfee
8.0 KiB [ ] /mnt
8.0 KiB [ ] /media
4.0 KiB [ ] /lib64
e 4.0 KiB [ ] /srv
e 4.0 KiB [ ] /cdrom
e 4.0 KiB [ ] /Quarantine
. 0.0 B [ ] /proc
0.0 B [ ] /sys
@ 0.0 B [ ] initrd.img.old
@ 0.0 B [ ] initrd.img
@ 0.0 B [ ] vmlinuz.old
@ 0.0 B [ ] vmlinuz
e 0.0 B [ ] /net
Total disk usage: 14.2 GiB Apparent size: 13.9 GiB Items: 871532
我怎样才能找到剩下的 15GB 空间在哪里?
答案1
感谢 roaima,sudo lsof | grep -i deleted
给了我正确的提示:
...
ACPI\x20P 115235 115264 user 18w REG 252,0 71889 2090030 /home/user/.minikube/machines/minikube/minikube/Logs/VBox.log (deleted)
ACPI\x20P 115235 115264 user 19r REG 252,0 157843456 2090240 /home/user/.minikube/machines/minikube/boot2docker.iso (deleted)
ACPI\x20P 115235 115264 user 20u REG 252,0 16021913600 2090248 /home/user/.minikube/machines/minikube/disk.vmdk (deleted)
...
长话短说,我发现在我的 Linux 机器上,VirtualBox 在后台运行,这三个文件仍然打开。我不知道 Linux 会为打开但同时被删除的文件保留磁盘空间。
我杀死了 VirtualBox(“关闭并再次打开机器”可能也是个好主意),瞧:
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 797M 80M 718M 10% /run
/dev/mapper/vg_ldt-lv_root 33G 15G 17G 46% /
tmpfs 3.9G 12M 3.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1.9G 160M 1.6G 10% /boot
tmpfs 797M 0 797M 0% /run/user/998
tmpfs 797M 84K 797M 1% /run/user/3841712
tmpfs 797M 0 797M 0% /run/user/999