Wednesday, January 11, 2023

Why is my droplet consuming a lot of disk space?

by Joseph Anthony C. Hermocilla, Principal Consultant


I've been using Digital Ocean to provision web servers through Droplets. However, I noticed that a server's available disk space is reduced after some time. I found out that the culprit is Systemd's Journald service.

Having worked on Linux servers for a time, I know the most likely directory containing large files is /var. I started looking for large files there using the following command line:

$sudo du -h --max-depth=1 /var

The result is that /var/log is occupying GB of space! I rerun the command line:

$sudo du -h --max-depth=1 /var/log

This time, the largest folder is /var/log/journal

To reclaim the disk space occupied by the logs, I used the command line below:

$sudo journalctl --vacuum-size=50M

The above fix is only temporary. To make it permanent, I set the following parameter in /etc/systemd/journald.conf:

SystemMaxUse=50M

I then restarted the service:

$sudo systemctl restart systemd-journald

Hopefully, next time my web servers will not run out of disk space. 


Contact us if you want need help in setting up your Linux servers. We'd be glad to help.

(Image: Gabriel Heinzer on Unsplash)