Last active
February 15, 2021 01:13
-
-
Save asmattic/84b70c3343a34c0401092f966084d21a to your computer and use it in GitHub Desktop.
Free up space on Linux root partition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check disk usage by journal | |
journalctl --disk-usage | |
# Mark current journal files as archived so they are no longer being written to | |
sudo journalctl --rotate | |
# Delete journal logs older than X days | |
sudo journalctl --vacuum-time=1day | |
# Delete log files until the disk space taken falls below the specified size | |
sudo journalctl --vacuum-size=100M | |
# Delete old logs and limit file number to X | |
sudo journalctl --vacuum-files=5 | |
# Edit journal log configuration | |
sudo vim /etc/systemd/journald.conf | |
# Change SystemMaxUse=100M or whatever size needed | |
# Reload systemd daemon | |
systemctl daemon-reload | |
# Credit: https://ubuntuhandbook.org/index.php/2020/12/clear-systemd-journal-logs-ubuntu/ | |
################################################### | |
# Clean apt cache | |
################################################### | |
# Check apt cache size | |
sudo du -sh /var/cache/apt-archives/ | |
# Clean apt cache | |
sudo apt-get clean | |
# Removes only packages that are not possible to download from available repositories | |
sudo apt-get autoclean | |
################################################### | |
# Remove stored older versions of snap packages | |
################################################### | |
# Check size of extra stored snaps | |
du -h /var/lib/snapd/snaps | |
# 4.0K /var/lib/snapd/snaps/partial | |
# 5.6G /var/lib/snapd/snaps | |
# Shell script to clean all of the older version of snap apps | |
########################## | |
# START SNAP CLEAN SCRIPT | |
########################## | |
#!/bin/bash | |
# Removes old revisions of snaps | |
# CLOSE ALL SNAPS BEFORE RUNNING THIS | |
set -eu | |
snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do | |
snap remove "$snapname" --revision="$revision" | |
done | |
########################## | |
# END SNAP CLEAN SCRIPT | |
########################## | |
################################################### | |
# Remove thumbnail cache | |
################################################### | |
# Check the size of thumbnail cache | |
du -sh ~/.cache/thumbnails | |
# Clear thumbnail cache | |
rm -rf ~/.cache/thumbnails/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment