0

I have a VPS which is a little starved for disk space. Long term plans call for moving to a system with a bigger disk but in the meantime I need to take a look at the existing disk use and clear up unnecessary stuff (e.g. old database dumps).

So far I've been using du -hc --max-depth=<n> to look at directories like /var/www and /home, but this is a pretty intensive process and it's not always easy to pick up the depth that will spot the disk use. I'd like to find something like Disk Inventory X that will show me a nice graph of what's taking the space, and there are such tools for Linux, but is there one which will either run over SSH or get some data (maybe even from a big du run) and visualize that offline?

3 Answers 3

1

I don't know of a good command-line disk usage visualization application, but it would be a good project with curses or similar :)

I usually use something like the following, and then page through the output file with less:

find / -type f -exec du -k {} + | sort -nr | cut -f2 | xargs -d '\n' du -sh > /tmp/usage.txt

Files are sorted from largest to smallest so it's easy to pinpoint the culprits...

782M    /ftp/1.zip
321M    /ftp/2.zip
321M    /ftp/3.zip
211M    /ftp/4.zip
193M    /ftp/5.wmv
183M    /ftp/6.zip
175M    /ftp/7.pdf
156M    /ftp/8.MPG
133M    /ftp/9.exe
111M    /ftp/10.pdf
104M    /ftp/11.MPG
96M     /ftp/12.rvt

You could go even further and use grep to grab certain filetypes:

grep  "\.zip" /tmp/usage.txt

and voila:

782M    /ftp/1.zip
321M    /ftp/2.zip
321M    /ftp/3.zip
211M    /ftp/4.zip
183M    /ftp/6.zip
1
  • I like David Spillet's answer but this is what I'm actually using.
    – pjmorse
    Commented Sep 15, 2010 at 15:12
1

If you are running a Linux desktop (or something else with an X server) at your end you could try running your preferred X application over SSH like so. How efficient and responsive this will be depends on the bandwidth (and latency) leaving your server and coming into your current location (unless the server is on the local LAN, in which case bandwidth and latency are not going to be much of an issue). You might need to make sure that the SSH client's compression option is used, as I don't think the X protocol compresses anything by default.

Three are several options for Windows too, you just need extra stuff installed. You could install cygwin and use its X server and SSH client which I've used before, or you could try Xming+puTTY which I've not got around to trying yet.

Unlike controlling a machine via VNC, you don't need a full X install on the server - you just need the X client libraries that the tools you run need.

3
  • This is a good technique, but the tools I'd use require either KDE or Gnome as well as X, so it won't work for this application.
    – pjmorse
    Commented Sep 15, 2010 at 3:38
  • You would still be able to do this without running X on the server. If you are installing on Debian or Ubuntu run `aptitude install chosen-app" and you'll see the extra packages it'll add are just the libraries needed not all the rest of X and the gnome/kde desktop environment and related services. Though if you are already running very short of space on the VM this may still be more than you want to install at this point. Commented Sep 15, 2010 at 10:03
  • The command in the comment above should have been aptitude --simulate install chosen-app (though unless you have a custom aptitude config it would prompt you before taking action anyway). There will be a similar incantation for yum if you use a distro that uses it for package management. Commented Sep 15, 2010 at 10:11
0

Interactive

du -x --max-depth 1 | sort -n

is pretty good. Just cd into different directories. John T's answer is quicker at finding huge files quickly. If you don't have huge files (or rather, lots of big files), this might be better.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .