System Maintenance
Regular maintenance keeps an Arch system healthy and prevents issues during updates.
Regular Maintenance Checklist
Weekly
# Update system
sudo pacman -Syu
# Check for failed services
systemctl --failed
# Review journal errors
journalctl -p 3 -xb
Monthly
# Clean package cache
sudo paccache -rk2
# Remove orphaned packages
sudo pacman -Rns $(pacman -Qtdq) 2>/dev/null || echo "No orphans"
# Check for .pacnew/.pacsave files
sudo find /etc -name "*.pacnew" -o -name "*.pacsave" 2>/dev/null
# Update mirrorlist
sudo reflector --country US --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
Package Cache Management
Configuration File Management
.pacnew and .pacsave Files
When pacman updates a package with modified config:
* .pacnew - New default config (your changes preserved)
* .pacsave - Your old config (new defaults applied)
# Find all .pacnew files
sudo find /etc -name "*.pacnew" 2>/dev/null
# Compare and merge
sudo diff /etc/somefile /etc/somefile.pacnew
sudo vim /etc/somefile # Merge changes
sudo rm /etc/somefile.pacnew
System Health Checks
Check for Issues
# Failed systemd services
systemctl --failed
# Recent errors in journal
journalctl -p err -b
# Errors since last boot
journalctl -p 3 -xb
# Disk space
df -h
Journal Maintenance
Update Troubleshooting
PGP Signature Errors (Marginal Trust)
When system has been offline, keyring becomes stale:
error: package: signature from "Someone" is marginal trust
:: File ... is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
Fix: Delete corrupted packages (Y), then update keyring first:
sudo pacman -Sy archlinux-keyring && sudo pacman -Syu
Keyring Fully Broken
If keyring update also fails:
# Remove and reinstall keyring
sudo rm -rf /etc/pacman.d/gnupg
sudo pacman-key --init
sudo pacman-key --populate archlinux
sudo pacman -Sy archlinux-keyring
sudo pacman -Syu
nvidia to nvidia-open Migration
Arch now defaults to nvidia-open. When prompted:
:: Replace nvidia with extra/nvidia-open? [Y/n]
Answer: Y - this is expected. nvidia-open is the open-source kernel module variant.
After reboot, verify:
nvidia-smi
lsmod | grep nvidia
nvidia-open Issues After Update
If display issues after nvidia-open migration:
# Check if module loaded
lsmod | grep nvidia
# Check for errors
dmesg | grep -i nvidia
journalctl -b | grep -i nvidia
# Verify kernel and driver match
pacman -Q linux nvidia-open
uname -r
If mismatch, rebuild:
sudo mkinitcpio -P
sudo reboot
Broken System Recovery
Boot from USB
If system won’t boot:
# Boot from Arch USB
# Mount system
mount /dev/sdX2 /mnt
mount /dev/sdX1 /mnt/boot
# Chroot
arch-chroot /mnt
# Fix issues, then
exit
umount -R /mnt
reboot
Automation Script
Create a maintenance script at ~/bin/arch-maintenance:
#!/bin/bash
set -e
echo "=== Arch Linux Maintenance ==="
echo -e "\n[1/6] Updating system..."
sudo pacman -Syu
echo -e "\n[2/6] Cleaning package cache..."
sudo paccache -rk2
sudo paccache -ruk0
echo -e "\n[3/6] Removing orphans..."
orphans=$(pacman -Qtdq 2>/dev/null) || true
if [[ -n "$orphans" ]]; then
echo "$orphans" | sudo pacman -Rns -
else
echo "No orphans found"
fi
echo -e "\n[4/6] Checking failed services..."
systemctl --failed
echo -e "\n[5/6] Checking for .pacnew files..."
sudo find /etc -name "*.pacnew" 2>/dev/null || echo "None found"
echo -e "\n[6/6] Cleaning journal..."
sudo journalctl --vacuum-time=2weeks
echo -e "\n=== Maintenance Complete ==="
Make executable:
chmod +x ~/bin/arch-maintenance