System maintenance

Related articles

Regular system maintenance is necessary for the proper function of Arch over a period of time. Timely maintenance is a practice many users get accustomed to.

Error checking

Failed systemd services

Check if any systemd services have entered in a failed state:

$ systemctl --failed

See Systemd#Analyzing the system state for more information.

Logfiles

/var/log

Look for errors in the log files located at /var/log.

Systemd journal

Look for high priority errors in the systemd journal:

# journalctl -p 0..3 -xn

See Systemd#Journal for more information.

Package tasks

Regularly upgrade the system

It is recommended to perform full system upgrades regularly, at least weekly, both to enjoy the latest bugfix and security updates, and also to avoid having to deal with too many package updates that require manual intervention at once.

In rare cases Arch Linux has even seen critical changes like the switch from SysV to systemd: it is important to deal with cases like this at the same time the rest of the community does, so as to be able to easily find documentation and assistance in case of problems.

See Pacman#Upgrading packages for details.

If the system has packages from the AUR, carefully upgrade all of them.

Note: For best practices to follow during system updates see the article Enhance system stability#Read before upgrading the system.

Update mirrorlist

Update pacman's mirrorlist, as the quality of mirrors can vary over time, and some might go offline or their download rate might degrade.

See mirrors for details.

Remove orphaned packages

Remove unwanted packages that are orphans to free up wasted disk space.

See Pacman tips#Removing orphaned packages for details.

Remove unused packages

Remove old, unused packages from the system to free up disk space and simplify maintenance.

See Pacman tips#Removing unused packages for details.

Clean the package cache

Remove unwanted .pkg files from /var/cache/pacman/pkg/to free up disk space.

See Pacman#Cleaning the package cache for more information.

This task may be automated with systemd/Timers.

Optimize pacman database

Optimize access to the pacman database to speed up pacman operations.

See Improve pacman performance#Improving database access speeds.

This task may be automated with systemd/Timers.

Clean filesystem

When looking for files to remove, it is important to find the files that take up the most disk space. Programs that help with this are found in:

Identify files not owned by any package

Remove unwanted files not listed in the pacman database. Various reasons exist why this may occur.

See Pacman tips#Identify files not owned by any package.

Clean /var

Remove old files from /var to free up disk space. That is the location where logs and other constantly changing data are kept.

See Filesystem Hierarchy Standard#/var: Variable files for more information.

Clean the home directory

Remove old files in the $HOME directory to simplify finding configuration and other useful files. Look for the following folders:

  • ~/.config/ -- where apps stores their configuration
  • ~/.cache/ -- cache of some programs may grow in size
  • ~/.local/share/ -- old files may be lying there
Note: These paths are defaults for $XDG_CONFIG_HOME, $XDG_CACHE_HOME and $XDG_DATA_HOME environment variables respectively. Check your configuration if you use different paths.

See Filesystem Hierarchy Standard#/home: User directories for more information.

To keep the home directory clean in the long term, it is a good idea to manage a list of unwanted files and clean them regularly. There are some helper scripts available: rmshit-gitAUR or rmshit.py.

General cleaning

After some activity, an Arch system may get cluttered in some places. This section aims to clean or reset some of the mess.

Mimetype associations

After using File Managers for a while, some mimetypes might get associated with an application that isn't installed anymore; another common scenario is when there are several applications with equivalent functionality (example: text editors) installed, but the mimetypes aren't associated with the one that you want.

To reset your mimetypes list, investigate the ~/.local/share/applications/ directory, and the following files within it:

  • mimeapps.list
  • mimeinfo.cache

You might delete them, or simply a few lines of them, removing unwanted associations.

See Default applications#Using MIME types and desktop entries for details.

Remove broken symlinks

Old, broken symbolic links might be sitting around your system; you should remove them. Examples on achieving this can be found here and here.

To quickly list all the broken symlinks of your system, use:

 # find . -type l -! -exec test -e {} \; -print

Then inspect and remove unnecessary entries from this list.

Backup

Data

Create backups of important data at regular intervals. Directories to consider are /etc, /home and /var, and, for server installations, also /srv.

See Backup programs for many alternative applications that may better suit your case. Other articles that may be of interest are Full system backup with rsync, Full System Backup with tar and Disk cloning

Backups can also be executed automatically, see systemd/Timers.

This guide uses tar to backup /etc as an example. Execute the following command as root:

# tar -cjf /path/to/chosen/directory/etc-backup.tar.bz2 /etc
Tip: If you want to back up much faster (using parallel compression, SMP), you should use pbzip2 (Parallel bzip2).

First back up the files to a plain tarball with no compression:

# tar -cvf /path/to/chosen/directory/etc-backup.tar /etc

Then use pbzip2 to compress it in parallel:

$ pbzip2 /path/to/chosen/directory/etc-backup.tar.bz2

Store etc-backup.tar.bz2 on one or more offline media, such as a USB stick, external hard drive, or CD-R. Occasionally verify the integrity of the backup process by comparing original files and directories with their backups. Possibly maintain a list of hashes of the backed up files to make the comparison quicker.

Restore corrupted /etc files by extracting the etc-backup.tar.bz2 file in a temporary working directory, and copying over individual files and directories as needed. To restore the entire /etc directory with all its contents, move the etc-backup.tar.bz2 files into the / directory. As root, execute the following command:

tar -xvjf etc-backup.tar.bz2

List of installed packages

Maintain a list of all installed packages, so that if a complete re-installation is inevitable, it is easier to re-create the original environment. This task may be automated with systemd/Timers.

See Pacman tips#Backing up and retrieving a list of installed packages for details.

Pacman database

The following command can be used to back up the local pacman database:

$ tar -cjf pacman_database.tar.bz2 /var/lib/pacman/local

Store the backup pacman database file on one or more offline media, such as a USB stick, external hard drive, or CD-R. This task may be automated with systemd/Timers. See also Pacman tips#Backing up Local database with systemd for an alternative method.

The database can be restored by moving the pacman_database.tar.bz2 file into the / directory and executing the following command:

# tar -xjvf pacman_database.tar.bz2
Note: If the pacman database files are corrupted, and there is no backup file available, there exists some hope of rebuilding the pacman database. Consult Pacman tips#Restore pacman's local database.