How to Free Up Disk Space on Arch Linux
Categories:
6 minute read
Arch Linux is known for its minimalistic, rolling-release model and full user control over the system. However, like any Linux distribution, Arch systems can accumulate unnecessary files over time, consuming precious disk space. Whether you’re running low on storage or just want to keep your system lean and clean, it’s important to understand how to safely reclaim disk space.
This article will guide you through several practical ways to free up disk space on Arch Linux, including package management, journal cleanup, cache purging, orphaned files removal, and more. These techniques can help optimize your system and keep it running smoothly.
1. Check Disk Usage
Before making any changes, it’s essential to understand what’s using your disk space. Arch provides a few tools for this purpose.
Use df
to check overall usage
df -h
This command displays the disk space usage of all mounted filesystems in a human-readable format.
Use du
to identify large directories
sudo du -h --max-depth=1 / | sort -hr
This shows which top-level directories are taking up the most space. You can dig deeper by changing the path or increasing --max-depth
.
Use graphical tools (optional)
If you prefer GUI tools, install something like baobab
or filelight
:
sudo pacman -S baobab
2. Clean the Package Cache
Arch Linux (via pacman
) stores old versions of packages in /var/cache/pacman/pkg/
. Over time, this can consume several gigabytes of space.
View cache size
du -sh /var/cache/pacman/pkg/
Clean unused packages
sudo pacman -Sc
This command removes all cached packages not currently installed. It will prompt for confirmation.
Clean all cached packages
sudo pacman -Scc
Warning: This deletes all cached packages, including the most recent ones. Only do this if you’re sure you won’t need to downgrade packages or reinstall without downloading again.
Automate cache cleanup
Consider using a tool like paccache
from the pacman-contrib
package:
sudo pacman -S pacman-contrib
sudo paccache -r
By default, this keeps the three most recent versions of each package. You can customize how many versions to keep:
sudo paccache -rk1 # Keep only the latest version
3. Remove Orphaned Packages
Orphaned packages are no longer required by any installed package and can often be removed safely.
List orphans
pacman -Qdt
Remove orphans
sudo pacman -Rns $(pacman -Qdtq)
This command removes the orphaned packages along with their unused dependencies and configuration files.
4. Clear Journal Logs
Systemd stores log data in /var/log/journal/
. On busy systems or over time, these logs can grow large.
Check journal size
journalctl --disk-usage
Vacuum old logs
sudo journalctl --vacuum-time=2weeks
This deletes logs older than two weeks. You can change the time frame as needed (--vacuum-time=10d
, 1month
, etc.).
Or set a size limit
sudo journalctl --vacuum-size=100M
This reduces logs until they consume no more than 100 MB.
You can also configure persistent log size limits by editing /etc/systemd/journald.conf
.
5. Remove Unused Flatpak/Snap Packages
If you use Flatpak or Snap, they can also store old versions or unused runtimes.
Flatpak
List installed apps and runtimes:
flatpak list
Remove unused versions:
flatpak uninstall --unused
Snap
Snap retains old versions by default (up to 3). You can remove older versions:
sudo snap list --all
Then, manually remove old revisions:
sudo snap remove <package> --revision=<old_revision>
Or automate with:
sudo snap set system refresh.retain=2
This limits Snap to retain only the latest two versions.
6. Clean Temporary Files
Temporary files can be stored in various locations like /tmp
, /var/tmp
, or user-specific .cache
directories.
Clean system temp
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
Clean user cache
rm -rf ~/.cache/*
Be careful not to delete specific directories you might still need (like browser profiles or game configs).
Use tmpwatch
(optional)
sudo pacman -S tmpwatch
sudo tmpwatch --mtime --all 72 /tmp
This removes files in /tmp
not modified in the last 72 hours.
7. Use Stacer or BleachBit (GUI Cleaners)
If you prefer graphical system cleaners:
Install Stacer
yay -S stacer
Stacer provides a GUI to clean logs, cache, and manage startup apps.
Install BleachBit
sudo pacman -S bleachbit
BleachBit is similar to CCleaner on Windows. It helps clean cache files, logs, temporary files, and more.
8. Find and Remove Large Unnecessary Files
Use ncdu
(NCurses Disk Usage)
sudo pacman -S ncdu
sudo ncdu /
ncdu
gives an interactive console-based view of disk usage, letting you explore and delete large files easily.
Use find
to locate large files
sudo find / -type f -size +100M
This lists all files larger than 100MB. Review carefully before deleting.
9. Remove Unused Kernels (If Using linux-lts
, etc.)
Arch keeps multiple kernels if you install variants like linux-lts
, linux-zen
, etc. Old versions may linger in /boot
.
List installed kernels
pacman -Q | grep linux
Ensure you’re not using a kernel before removing it.
Remove with:
sudo pacman -Rns linux-lts
Do not remove the currently running kernel.
10. Check for Duplicate Files (Optional)
Duplicate files, especially media, can consume space unnecessarily.
Install fdupes
sudo pacman -S fdupes
Scan for duplicates
fdupes -r /home/youruser/
Review the output and manually delete duplicates you don’t need.
11. Clean Up Build Dependencies (For AUR Users)
When building AUR packages with yay
or paru
, temporary build files accumulate in /home/username/.cache
.
Clean yay
cache
yay -Sc
Clean paru
cache
paru -Sc
These commands remove cached package files and reduce storage use from builds.
12. Optional: Remove Unused Locales and Man Pages
You can reduce disk usage slightly by removing unused locales or documentation.
Remove unused locales
Install localepurge
(not available in official repos, but in AUR):
yay -S localepurge
Use it to delete unused language packs.
Remove unused man pages
Some users opt for minimalist setups by removing man pages:
sudo rm -rf /usr/share/man/*
Note: This is not recommended unless you’re really tight on space and are confident you won’t need man pages for offline documentation.
Conclusion
Freeing up disk space on Arch Linux involves a mix of command-line tools and good housekeeping habits. Regularly clearing your package cache, removing orphaned dependencies, cleaning journal logs, and deleting temporary or large unnecessary files can keep your system lean and responsive.
Here’s a quick summary of useful commands:
Task | Command |
---|---|
Clean package cache | sudo pacman -Sc or sudo paccache -r |
Remove orphaned packages | sudo pacman -Rns $(pacman -Qdtq) |
Clear journal logs | sudo journalctl --vacuum-time=2weeks |
Clean temp files | sudo rm -rf /tmp/* and rm -rf ~/.cache/* |
Clean AUR build cache | yay -Sc or paru -Sc |
Find large files | ncdu / or find / -type f -size +100M |
Managing disk space on Arch Linux doesn’t have to be complex—it just requires regular attention and the right tools. Whether you’re maintaining a personal desktop or managing a server, these strategies can help keep your Arch installation efficient and clutter-free.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.