Introduction to Disk Usage Issues
I’ve seen disk usage issues plague even the most well-maintained Linux systems, often due to duplicate files and unnecessary logs. As of 2026, both Btrfs and Ext4 filesystems are widely used, each with their own set of tools and best practices for troubleshooting and resolving these issues. In this article, we’ll delve into practical steps for identifying and addressing duplicate files and unnecessary logs on both Btrfs and Ext4 filesystems, focusing on current tools and methodologies.
Identifying Disk Usage Issues
To begin troubleshooting disk usage issues, it’s essential to understand how to identify them. The df command is a straightforward tool for viewing disk usage statistics. For example:
df -h
This command provides a human-readable output of available disk space. However, to dive deeper into which files or directories are consuming the most space, du is more appropriate:
du -sh /path/to/directory
This command estimates disk usage for the specified directory. Don’t bother with df alone; du will give you the detailed breakdown you need.
Finding Duplicate Files
Duplicate files can significantly contribute to disk usage issues. A tool like fdupes can be used to find duplicate files:
fdupes -r /path/to/search
This command recursively searches for duplicate files within the specified path. Once duplicates are identified, you can decide whether to delete them or handle them according to your needs. Be cautious when using fdupes with rm to avoid accidentally deleting important files.
Managing Unnecessary Logs
Unnecessary logs can also consume a substantial amount of disk space. Regularly cleaning up logs is a good practice. For systems using systemd, the journalctl command can be used to manage log sizes:
journalctl --vacuum-size=1G
This command reduces the journal size to 1G, freeing up disk space. For other logging systems, refer to their specific documentation for log rotation and cleanup practices. This is where people usually get burned - forgetting to clean up logs can lead to disk space issues down the line.
Btrfs Specific Tools
For Btrfs filesystems, tools like btrfs filesystem du can provide detailed disk usage information:
btrfs filesystem du /path/to/btrfs
Additionally, btrfs balance can help in optimizing disk space usage by rebalancing the filesystem:
btrfs balance start /path/to/btrfs
It’s also worth noting that Btrfs has built-in support for deduplication, which can be enabled on a per-file or per-directory basis using tools like duperemove.
Ext4 Specific Considerations
While Ext4 does not have the same level of built-in features as Btrfs for deduplication or balancing, it’s still crucial to regularly check for and remove unnecessary files. Tools like find can be used to locate old or large files:
find /path/to/search -type f -size +100M -exec ls -lh {} \;
This command finds files larger than 100M in the specified path and lists them with their sizes. I usually start with this command to get an idea of what’s taking up space.
Security Considerations
When managing disk usage and removing files, it’s essential to do so securely. Ensure that you have appropriate backups before deleting files, especially system logs, as they can be crucial for auditing and security purposes. Regularly review which files and logs are being retained to avoid storing sensitive information unnecessarily. For more information on secure logging practices, refer to the systemd documentation.
Practical Trade-Offs
In practice, the choice between Btrfs and Ext4 depends on your specific needs. Btrfs offers advanced features like snapshotting and deduplication but may require more maintenance and has historically been less stable than Ext4. Ext4, on the other hand, is widely supported and stable but lacks some of the advanced features of Btrfs. Consider your system’s requirements and the trade-offs of each filesystem when deciding which to use. The real trick is finding the right balance between features and stability.
Troubleshooting Notes
- Always ensure you have a backup before making significant changes to your filesystem.
- Be cautious when using commands like
fdupesandfindwithrmto avoid accidentally deleting important files. - Regularly monitoring disk usage can help catch issues before they become critical. Don’t wait until it’s too late - stay on top of your disk usage.
See also
- Taming systemd-resolved: Troubleshooting DNS leaks and resolving domain name surprises on Linux desktops and servers
- Taming systemd-resolved: How to Configure DNS Settings for Split Horizon Environments
- Rescuing a Linux System Stuck in Emergency Mode: A Step-by-Step Recovery Guide
- Troubleshooting Failed Mounts at Boot Time with systemd and fstab
- Taming Disk-Hungry Logs with systemd-journald and logrotate