How to Free Up Disk Space on a Full Linux System
Table of contents
Check Disk Usage
~ Run the following command to identify which partitions are full:df -h
~ Look for the partition with 100% usage, usually /.
Clear Temporary Files
~ Free up space by clearing temporary files:sudo rm -rf /var/tmp/* sudo rm -rf /tmp/*
Remove Unused Package Files
~ Clear cached.deb
files stored byapt
:sudo apt-get clean
Locate Large Files
~ Identify large files in your filesystem:sudo du -ah / | sort -rh | head -n 20
~ Delete unnecessary large files or move them to another storage location.
Check Log Files
~ Logs can often grow excessively large. Truncate or delete old logs:sudo journalctl --vacuum-size=50M sudo rm -rf /var/log/*.gz /var/log/*.1 sudo truncate -s 0 /var/log/syslog sudo truncate -s 0 /var/log/auth.log
Uninstall Unused Applications
~ Remove unnecessary applications to reclaim space:sudo apt-get remove --purge <package_name> sudo apt-get autoremove
Retry the Update/Installation
~ After clearing space, reattempt the operation:sudo dpkg --configure -a sudo apt-get install -f
Long-Term Prevention
Monitor Disk Space: Regularly check disk usage with
df -h
anddu
.Set Log Rotation: Use tools like
logrotate
to manage log sizes.Partition Optimization: Allocate adequate space to
/var
or use separate partitions for logs and temporary files.
By following these steps, you should be able to resolve the error and free up space for system operations.
Subscribe to my newsletter
Read articles from Harendra Barot directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Harendra Barot
Harendra Barot
I'm an IT professional and business analyst, sharing my day-to-day troubleshooting challenges to help others gain practical experience while exploring the latest technology trends and DevOps practices. My goal is to create a space for exchanging ideas, discussing solutions, and staying updated with evolving tech practices.