Disk full - how to find out why?

Unmasking the Mystery of a Full Disk: Troubleshooting Storage Issues on Manjaro Linux

Encountering a "disk full" notification when you know you haven't been hoarding files can be a frustrating experience. It's like a digital scavenger hunt where you're trying to locate the culprit hogging all your storage space. This article aims to shed light on how to effectively diagnose and resolve disk space issues in Manjaro Linux, even when graphical tools seem to fall short.

If you have faced the problem of slow performance on Manjaro, it might be related to disk usage. Here’s we will explore alternative solutions.

The Case of the Vanishing Gigabytes: Why is My Disk Full?

You're not alone if you've been puzzled by a sudden influx of "disk full" warnings. Often, the usual suspects (large media files, bulky downloads) aren't to blame. Instead, the storage drain might be caused by:

  • System Logs: System logs can grow unexpectedly, especially if there are recurring errors or verbose debugging enabled.
  • Cache Files: Temporary files stored by applications can accumulate over time and consume significant space.
  • Orphaned Packages: Leftover packages from software installations or updates can linger on your system.
  • Hidden Files: Some folders/files are hidden, so you might not see them in a regular folder browsing of file explorer.
  • Snap Packages: The Snap package manager's way of handling updates can lead to multiple versions of applications residing on your system.

Beyond the GUI: Command-Line Tools to the Rescue

Graphical disk usage analyzers are helpful, but they occasionally have limitations or don't paint the complete picture. Let's dive into terminal-based tools that provide a more comprehensive view.

  • du (Disk Usage): This command is your best friend when trying to pinpoint which directories are consuming the most space.
    • du -hsx /* | sort -rh | head -20 : This command will list the top 20 largest directories on your root partition, excluding files on other filesystems. Run it from the terminal to quickly identify space hogs. Here breakdown of commands:
      • du -hsx /*: Calculates the disk usage of each directory under the root directory (/), displaying the results in human-readable format (-h), summarizing directory sizes (-s), and staying within the same filesystem (-x).
      • sort -rh: Sorts the output from du numerically in reverse order (-r), based on the human-readable numbers (-h).
      • head -20: Displays the top 20 lines of the sorted output, showing the largest directories.
    • sudo du -sh /home/* will display the total size of each user's home directory. Very useful to find out which user is occupying the biggest space.
  • df (Disk Free): Shows overall disk space usage for all mounted file systems. Very helpful when the space is full
    • df -h : Displays disk space usage in a human-readable format.

Clearing the Clutter: reclaiming lost space

Once you've located the space-consuming culprits, you can start reclaiming lost storage:

  1. Clean Up System Logs: Locate the log directory (usually /var/log) and identify any excessively large log files. Use caution when deleting log files. Consider archiving older logs instead of deleting them outright.
  2. Clear Package Cache: Manjaro uses pacman as its package manager. Clean up the package cache with:
    • sudo pacman -Scc : This command removes all cached packages, freeing up space.
  3. Remove Orphaned Packages: Identify and remove orphaned packages (packages no longer required by any installed software):
    • pacman -Rns $(pacman -Qtdq) : This command removes orphaned packages. Be careful when using the -Rns flags, as they remove dependencies and configuration files.
  4. Taming Snap Packages: If you use Snap, consider removing older revisions of packages:
    • snap list --all : This command list installed snap packages and their revisions
    • sudo snap remove <package_name> --revision=<revision_number> Replace <package_name> and <revision_number> with the specific package and revision you want to remove.
  5. BleachBit: For a comprehensive cleanup of temporary files, caches, and browser data, BleachBit is a powerful open-source tool. Be cautious when using this utility, as it can remove files you might need.

Proactive Measures: Preventing Future Disk Space Issues

  • Regularly Monitor Disk Usage: Set up a system monitor widget or use command-line tools to keep an eye on your disk space.
  • Logrotate Configuration: Configure logrotate to automatically archive and compress old log files to prevent them from growing excessively.
  • Limit Cache Sizes: Configure applications to limit the amount of cache data they store.

By understanding the potential causes of disk space issues and mastering the command-line tools to diagnose and resolve them, you can regain control of your Manjaro system and keep those "disk full" notifications at bay. Remember to always exercise caution when deleting files and packages, and back up important data before making significant changes to your system.

. . .