Maintenance and peripherals

Maintenance and peripherals

System maintenance and troubleshooting is a reoccurring task to take care of your system and be able to analyze and solve technical issues. In addition, peripherals1 sometimes require some tinkering, which supports in the process of learning the details and quirks of your system. For this reason, the sections in this guide focus on the following tasks:

  1. General #Maintenance tasks and automation
  2. Setting up #Peripherals
    1. #Bluetooth controller
    2. #Printer and scanner
    3. Additional encrypted #Storage

Maintenance

Ensure the intended system functionality over a period of time: constantly check for errors by using the following command to identify failed systemd services:

sudo systemctl --failed

Use the Systemd journal to read logfiles as follows:

sudo journalctl -p 3 -b

Xorg troubleshooting also starts by checking the Systemd journal. Its own logfiles are created in case of any errors inside your user directory. The filename scheme is in the form of Xorg.n.log with n designating the display number. Search your user directory for such files by using this command:

grep -e Log -e tty Xorg.0.log

Search the forumsand ask questions, lookup terms in the ArchWiki, and consult a search engine of your choice for debugging errors and interpreting warnings.

Backup

Most important is to maintain a backup2 of your system. Filesystem level backup can be done via rsync and disk cloning is a task for the ddrescue copmmand. It supports block devices including (optical) disks and SD cards. Install the following packages:

sudo pacman -Sy ddrescue rsync

Full system backup from $SRC to $DST excluding directory contents of devices and typical mount points is achieved using this command:

sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} $SRC/ $DST/

Note that the trailing slash is mandatory for synchronizing the folder contents! You probably want to write a backup script for automation. I like to backup my the filesystems of my machines into a directory named after the hostname on a physical HDD3 and clean the filesystem in advance to save space:

full-sys-bkp.sh
#!/bin/bash
#
# Full system backup using rsync with deletion of non-existent files in $DST
# https://wiki.archlinux.org/title/Rsync#Full_system_backup

SRC=/
HST=$(hostnamectl hostname)
DST=$(pwd)/$HST

# Remove old local packages to save space
sudo pacman -Scc

# Clean user data cache
rm -rf ~/.cache/*

# Synchronize
sudo rsync \
  -aAXHv \
  --delete \
  --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
  $SRC \
  $DST

Logfile limit

I like to keep Systemd’s journal size limit below 200 MB. For this setting, I uncomment and adapt a line in the /etc/systemd/journald.conf file to match:

/etc/systemd/journald.conf
SystemMaxUse=200M

Afterwards I need to restart the Journald service:

sudo systemctl restart systemd-journald.service

Filesystem cleanup

Files which are not owned by any package can be listed and written to a text file with lostfiles. Additionally, the rmlint tool finds (and optionally removes) duplicate files. I install both packages as follows:

sudo pacman -Sy lostfiles rmlint

Lostfiles command is executed via #sudo:

sudo lostfiles > ~/lostfiles.txt

And in addition, The following command finds broken symlinks4 and writes them into another .txt file for easier post-processing:

sudo find / -xtype l -print | sudo tee broken_symlinks.txt
⚠️
If a file is not owned by a package or a symlink is broken does not mean that it is useless! Custom configurations and files copied to system directories are not identified by lostfiles and broken symlinks can have a purpose, see this Stackexchange post for more information!

Additionally, I ocasionally create a list of installed packages to investigate potentionally unused or legacy applications by invoking the following command:

sudo pacman -Qqe > /etc/pkglist.txt

Automation

You may want to automate some of the aforementioned tasks to happen on a regular basis.

Job scheduler

The cronie package is a cron functionality provider on a per-user crontab file and can be installed using:

sudo pacman -Sy cronie
⚠️
Be careful to not automate the removing of any lost files to prevent missing configurations or other important system-related files!

Package update notifier

I use Kalu as a notifier for package updates available in the official repositories and the AUR. It can be installed with:

yay kalu

I execute kalu & to start the notifier. Though I still need to manually run the upgrade process, Kalu can regularly check new packages and offers a 1-click system upgrade.

ℹ️
If you are using an AUR helper and Kalu complains about missing -debug packages, ommit debug files.

Peripherals

Bluetooth

ℹ️

Before continuing, ensure that the bluetooth device is not blocked by rfkill. I issue the following command and identify the SOFT and HARD state:

sudo rfkill

There is an increasing amount of peripherals for short-range wireless connection via bluetooth. The basic bluetooth capabilities are provided by bluez and bluez-utils. These packages are installed as follows:

sudo pacman -Sy bluez bluez-utils

Afterwards I enable and start bluetooth.service:

sudo systemctl enable bluetooth.service
sudo systemctl start bluetooth.service

Follow pairing instructions in the ArchWiki to setup bluetooth devices.

Headset

Connecting a headset via PipeWire, as configured in #Sound system, requires the pipewire-pulse package. Proceed with the section Configuration via CLI similar to pairing other bluetooth devices. Or to ease this process, a full- featured management GUI is Blueman. I install the package via:

sudo pacman -Sy blueman

Start the application by invoking blueman-applet & and configure bluetooth devices according to the usage documentation.

Known bugs

If the controller is not available or bluetooth seems to crash regularly, disable USB autosuspend to prevent reloading of the btusb module. Create a /etc/modprobe.d/btusb.conf file with the following content to achieve this behavior:

/etc/modprobe.d/btusb.conf
options btusb enable_autosuspend=n

Printer and scanner

CUPS

Printing is realized with CUPS. After installing the package cups:

sudo pacman -Sy cups

I start and enable its service:

sudo systemctl enable cups.service
sudo systemctl start cups.service
ℹ️
Printer drivers may be required depending on your brand and model.

Any further configuration of printers can be done graphically via the web interface available at http://localhost:631. One exception is setting the default paper size. However, appending it to the file /etc/papersize solves this issue due to CUPS’s support lipaper. In Germany the ISO 216 (DIN A4) paper size defines the standard. To set a4 for lipaper I execute the following command:

sudo echo "a4" | sudo tee -a /etc/papersize

SANE

For scanning, I install the sane package to use the SANE library. As a graphical frontend XSane provides vast functionality. I install both packages by executing:

sudo pacman -Sy sane xsane
ℹ️
Scanner drivers may be required for your device.

Storage

Additional removable storage such as an USB flash drive5 or an external HDD/ SSD may be necessary for archiving data at rest. While I tend to use data at rest encryption such filesystems can be mounted automatically by using a key stored in and read from the root filesystem for convenience.

Device identification

First, I identify the disk device using:

sudo fdisk -l

Encryption and opening

Assuming that your disk is /dev/sda the next steps are straightforward and similar to #Encryption and LVM as documented in the System preparation guide.

I encrypt and open the block device as follows:

sudo cryptsetup luksFormat /dev/sda
sudo cryptsetup open /dev/sda csd
⚠️

Be careful not to use the disk of your installed system if this disk is at /dev/sda! Double check the mount point of your root filesystem by invoking:

df | grep -w '/'

Filesystem creation

Other than in the System preparation a single ext4 filesystem inside the LUKS container is sufficient and will be formatted using the command:

sudo mkfs.ext4 /dev/mapper/csd

Tuning and labeling

Reserved blocks (for root) are not necessary on a removable device. For this reason, I use tune2fs and set a label using the e2label utility before closing the mapper device:

sudo tune2fs -m 0 /dev/mapper/csd
sudo e2label /dev/mapper/csd csd
sudo cryptsetup close csd

Unlock and mount automation

I use unlocking with a keyfile to automatically mount the device at boot. A keyfile is created and added to slot 1 of my block device (/dev/sda in this example):

sudo mkdir /etc/cryptsetup-keys.d
sudo dd if=/dev/urandom of=/etc/cryptsetup-keys.d/csd.key bs=512 skip=4 count=8
sudo cryptsetup luksAddKey /dev/sda /etc/cryptsetup-keys.d/csd.key --key-slot 1

Next, I identify and save the UUIDs of /dev/sda and /dev/mapper/csd in order to append it to the /etc/crypttab file using the following commands:

DevUuid=$(sudo blkid | grep /dev/sda | cut --delimiter=' ' --field=2 | sed 's/[^a-z0-9\\-]//g')
echo "csd UUID=$DevUuid /etc/cryptsetup-keys.d/csd.key noauto" | sudo tee -a /etc/crypttab
ℹ️
The noauto parameter prevents Systemd trying to automatically mounting the encrypted file system at boot leading to a long timeout, if the device is not plugged in. If you are working with non-removable media you must also edit /etc/fstab and create mountpoints as necessary.

Finally, I reload the Systemd daemon using:

sudo systemctl daemon-reload

And I re-plug my storage device to proceed as usual in Thunar using removable media.

Proceed with the configuration of basic multimedia and web capabilities or go back to the overview and follow instructions for specific use cases.


  1. Peripheral in the Wikipedia ↩︎

  2. Backup in the Wikipedia ↩︎

  3. Hard disk drive in the Wikipedia ↩︎

  4. Symbolic link in the Wikipedia ↩︎

  5. USB flash drive in the Wikipedia ↩︎

Last updated on