I'm a relatively basic user, using the Ubuntu terminal for Windows. I have a failing deployment caused by a lack of disk space on the VM I'm connected to in the terminal:

df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        30G   30G     0 100% /

/dev/ exists as a regular directory. I then see sda1 as a block device file:

ls -l

brw-rw---- 1 root disk      8,   1 Aug 12 01:31 sda1

(See https://superuser.com/questions/1240857/is-dev-sda1-a-directory/1594704#1594704 for an explanation of a block file).

How do I investigate what's filling up the block, and remove unneccessary data?

If I cd sda1 I get Not a directory

  • 2
    sda1 will be your disk, /dev is a DEVICE directory and POSIX (or older UNIX) philosophy says everything is treated as a file. The first "b" in the directory shows it's a BLOCK device and you're chasing down the wrong places.. Look for files that are using space, not devices. (FYI: that device will use none of your disk space; it's more a logical item that represents the whole disk; if you find your keyboard - it likewise will use no disk space!) – guiverc Oct 16 '20 at 1:09
  • 2
    fyi: I should have said partition, sda would be the disk, sda1 is the partition on the disk – guiverc Oct 16 '20 at 1:25

/dev/sdaN is not a directory, but a reference to the Nth partition of your hard drive. df -h shows that /dev/sda1 is mounted on /. If you want to see what is taking up space on a device, you look in that device's mount point, in this case /.

  • Thanks @Pixelated Fish. If I try du -s /* in the root as described here - unix.stackexchange.com/a/125430/204761, I get a lot of cannot read directory ... Permission denied messages, and none of the directories that can be read appear to have significant disk usage. Any ideas? – Chris Halcrow Oct 16 '20 at 1:33
  • 1
    You can avoid the permission denied error by omitting the *, as it will search directories you, well... don't have permission to :) You can also try running it as root by placing sudo at the beginning of the command. You can also edit your answer and post the result there. – Pixelated Fish Oct 16 '20 at 1:35
  • Thanks @Pixelated Fish - this helped me locate the problem - I've updated the question – Chris Halcrow Oct 16 '20 at 2:52

I realised /dev/sda1 is mounted on / - @Pixelated Fish's answer explains this is the 1st partition of the hard drive. So now I can

sudo du -s /, which reveals that something in the \var\ directory is the culprit. Drilling down I find that \var\lib\docker is the issue - which made me suspect that old docker images from automated deployments aren't being removed, which is answered in https://stackoverflow.com/questions/32723111/how-to-remove-old-and-unused-docker-images.

I also did sudo -s, cd \ and df -h, which then showed the exact culprit directory (I'm not sure why this worked, when df -h without being the root user didn't). It turned out log files were the issue. I can cd to the folder and rm * to clear out the files.

The following question has approaches around locating what's taking up disk space:


  • When using docker, make a script that prunes unused images on a weekly basis. – Artur Meinild Oct 16 '20 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.