Tuesday, 11 January 2022

Hey Aptitude, where's my disk space gone ?

Whilst upgrading an Ubuntu 20.04.3 LTS box, I hit messages such as: -

...

Ign:25 http://ubuntu.example.net/ubuntu-ports focal-security/universe s390x Packages

Err:27 http://ubuntu.example.net/ubuntu-ports focal-security/universe s390x c-n-f Metadata

  Write error - write (28: No space left on device)

Ign:14 http://ubuntu.example.net/ubuntu-ports focal-updates/universe Translation-en

Get:28 http://ubuntu.example.net/ubuntu-ports focal-security/multiverse s390x Packages [3,232 B]

Get:26 http://ubuntu.example.net/ubuntu-ports focal-security/universe Translation-en [154 kB]

Err:26 http://ubuntu.example.net/ubuntu-ports focal-security/universe Translation-en

  

Err:9 http://ubuntu.example.net/ubuntu-ports focal-updates/main Translation-en

  Write error - write (28: No space left on device)

...

which was somewhat worrying.

I checked my available disk space: -

df -kmh

and noticed that /var was full: -

/dev/mapper/basevg-var   2.9G  2.8G  8.8M 100% /var

Noting that that file-system has 2.9 GB of space, I wanted to see what was eating it: -

du -hs /var/* | sort -h

0 /var/lock
0 /var/run
4.0K /var/local
12K /var/opt
16K /var/lost+found
32K /var/spool
40K /var/tmp
648K /var/mail
2.0M /var/backups
405M /var/log
1.2G /var/lib
1.3G /var/cache

I took a random guess, and assumed that /var/cache was somehow related to Aptitude ( apt ), given the error that I was seeing.

Thankfully, the internet ( as ever ) has the answer: -


The trick is to run: -

sudo apt-get clean

Given that I'm already running as root, I ran: -

apt-get clean

which returns nothing but ....

du -hs /var/* | sort -h

0 /var/lock
0 /var/run
4.0K /var/local
12K /var/opt
16K /var/lost+found
32K /var/spool
40K /var/tmp
648K /var/mail
2.0M /var/backups
8.6M /var/cache
405M /var/log
1.2G /var/lib

so /var/cache is now 8.6 MB rather than 1.3 GB, and /var is way smaller: -

df -kmh

/dev/mapper/basevg-var   2.9G  1.6G  1.3G  56% /var

and, perhaps, more importantly, my upgrade runs to completion : -

apt-get update && apt-get upgrade -y

Nice!

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...