SDB:Cleanup system

Jump to: navigation, search

If your root file system is running out of space, try these commands. You may get back 10 GB or more free space.

Cleanup journal logs

Journal logs can grow fast and use up several GB disk space. Unless you want to troubleshoot your system, these logs are not very useful.

You can safely clean up journal logs and keep only logs from yesterday:

sudo journalctl --vacuum-time=1d

Cleanup downloaded RPM packages

This command will delete all downloaded RPM packages.

sudo zypper clean

Cleanup old kernels

This command will delete the old kernels based on configuration at /etc/zypp/zypp.conf

sudo zypper purge-kernels

Cleanup Btrfs snapshots

Tell snapper to delete old snapshots based on configuration at /etc/snapper/configs/root

sudo snapper cleanup number

By default, snapper allows:

  1. Maximum 50% of root file system space for snapshots. (20 GB of 40 GB root file system)
  2. Minimum 2 and maximum 10 normal snapshots.
  3. Minimum 4 and maximum 10 important snapshots.

You can reduce it using the following command:


Which means

  1. Maximum 20% of root file system space for snapshots. (8 GB of 40 GB root file system)
  2. Minimum 2 and maximum 6 normal snapshots.
  3. 4 important snapshots.

Cleanup /tmp

EDIT: As of August 2020 (Snapshot 20200806), fresh installations will use tmpfs for /tmp by default, meaning /tmp would be cleared after each reboot. See openSUSE:Tmp_on_tmpfs

Warning: Manual cleanup of /tmp directory may cause loss of unsaved data or application crashes. Be sure to save all your work and quit all applications.

Usually, applications should delete temporary files when they quit or set an expiring date. However, not all applications do it correctly and many files will stay there forever.

Simple solution is:

sudo rm /tmp/* -rf

Operating system and applications will not be broken by removing these files. But you should keep in mind, some running applications may have unsaved data stored here. For example, screenshot, office documents, files in downloading progress. Deleting files may interrupt the application and you will lose unsaved data. That's why you must quit all applications before running this command.