Block device full - how do I clear space

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 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

2 Answers

/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 /.

3

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 .

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:

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like