How to Minimize Large Log Files under /var/log/journal Directory in Linux Mint 20

3494
Share:
how-to-minimize-large-log-files-in-var-log-journal-directory-in-ubuntu-20-04

Today I was just poking around with my Linux Mint 20 desktop and opened "Disk Usage Analyzer". It's shown that I have rather large directories under /var. Top two directories are lib and log. We'll cover about log directory in this article.

Disk Usage Analyzer

Based on pie chart above, we can figure out quickly that journal directory is taking our precious space, 3.9 GB. So, what's actually the content of this directory and its use?

The content of /var/log/journal directory is systemd-journald log files. The log files could be useful if we're experiencing issues with our Linux system. Our example case is a standard Linux Mint 20 Installation with extra PHP development environment packages took 3.9 GB. The size is large enough for a small SSD. Most daily users won't need a large log files in their system.

Cleaning Journal Log Files

For a quick solution, we can cleaning up journald log files by vacuuming them.

To remove the oldest archived journal files until the disk space they use falls below the specified size we can use this command:

$ sudo journalctl --vacuum-size=100M

We use 100M as an example above. Possible values for the suffixes are K for Kilo, M for Mega, G for Giga, and T for Tera.

If we want to remove all archived journal files contain no data older than the specified time span, we can use this command:

$ sudo journalctl --vacuum-time=7d

This time we're using 7d (7 days) as an example. Possible values for the suffixes are s for seconds, m for minutes, h for hour, d for days, etc.

Minimize Journal Log Files

To make our preference permanent, we can define it in journald configuration file, /etc/systemd/journald.conf. Let's check what's the current value of our system first:

$ systemctl status systemd-journald

Systemctl Output

From above output, we can confirm that by default, Linux Mint 20 capped log file to 3.9 GB. That's also the reason we have 3.9 GB disk usage in our pie chart at the beginning of article.

Now, we don't want to have 3.9 GB worth of log files. We want to keep it as low as 100 MB max. To achieve this target we need to update our journald configuration file.

For example, if we want to keep 100M as maximum storage being used, we can add this line at the bottom of the /etc/systemd/journald.conf file:

SystemMaxUse=100M

Editing SystemD Configuration

After saving the file, we must restart the daemon to apply our new configuration.

$ sudo systemctl restart systemd-journald

Let's check if our update is applied.

Systemctl Output

Great. Now we can have more space in our system.

Final Words

Well, that's it. I might still need to figure why the number is still above our set value.

I hope that you now know how to minimize large log files under /var/log/journal directory in Linux Mint 20. If you run into any issues or have any feedback feel free to drop a comment below.


Tags Linux
Share:

0 comment

Leave a reply

Your email address will not be published. Required fields are marked *