0

So, the thing is, if your system is totally block by a huge file, and there isn't anything you know you can delete, all those tutorials showing shiny tools to manage filesystem aren't all that useful.

Just so happens this is my case: I have a dev VM and I totally filled it with test data, but I am not sure where they are (too many layers of abstraction, I wasn't just plainly writing on disk). There isn't really much I know I can delete, just sourcecode and the base OS. Many commands don't work because there isn't any disk space.

How can I find where this test file ended up and remove it?

Tomáš Zato
  • 1,776
  • 1
    if it's a VM you should still be able to mount the filesystem image while the VM is turned off on your host operating system? That would solve the "can't install anything" problem. Also, if it's a VM, chances are it's easy to just increase disk size a bit. – Marcus Müller Nov 21 '22 at 21:44

3 Answers3

0

You should give a try to:

find /directory -type f -size +10G

Adapt 10G with the size you prefer

  • I tried this one before posting this question. It found some files but none of these could be deleted, and then it got stuck. Or at least didn't print anything for an hour. – Tomáš Zato Nov 22 '22 at 12:31
0

Another way to check where you are using up your disk space is with du.
With du, you can breakdown where the majority of the drive usage is with the following flags; -s is to summarize (e.g. just display a total for a target.) -h is for human-readable (e.g. 100K or 212M or 89G.) -c is to get a grand total of usage at the end. -x is to keep the search on one filesystem (e.g. on the OS drive, if you have a mounted filesystem somwhere in the search like I did under /mnt when I ran this.)

So, here's an example:

 ~ # du -shcx /*
11M     /bin
4.0K    /boot
0       /dev
24M     /etc
212G    /home
2.6G    /lib
18M     /lib64
16K     /lost+found
4.0K    /media
2.6G    /mnt
188G    /opt
du: cannot access '/proc/24898/task/24898/fd/4': No such file or directory
du: cannot access '/proc/24898/task/24898/fdinfo/4': No such file or directory
du: cannot access '/proc/24898/fd/4': No such file or directory
du: cannot access '/proc/24898/fdinfo/4': No such file or directory
0       /proc
15G     /root
2.4M    /run
16M     /sbin
0       /sys
1.1M    /tmp
131G    /usr
21G     /var
570G    total

And, where you find the most usage, just drill down to the next level of that directory and keep going until you find where the file(s) is/are that are using all of the drive space.

Hope that helps.

B.Kaatz
  • 265
0

You can get the disk usage with du and analyse it on another system where xdu or xdiskusage is installed with:

ssh user@vm 'du -xak / | gzip -1' | gunzip | xdiskusage

Assumes you don't have file/dir names with newline characters in them. If there may be:

ssh user@vm 'du -0xak / | gzip -1' | gunzip | tr '\0\n' '\n?' | xdiskusage

(newlines will be rendered as ? in xdiskusage).

Beware the disk space might be used by a file that has been deleted but is still in use by some process. See Find and remove large files that are open but have been deleted for those.