Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active October 27, 2024 14:06
Show Gist options
  • Save yuvalif/88f97f4f947e879ba040d87d182441b7 to your computer and use it in GitHub Desktop.
Save yuvalif/88f97f4f947e879ba040d87d182441b7 to your computer and use it in GitHub Desktop.

Fedora28-32

Current status:

df -h

Find large files in the system:

sudo find / -type f -size +1000M -exec ls -lh {} \;

Remove old kernels (keep 2 latest):

sudo dnf remove $(dnf repoquery --installonly --latest-limit=-2 -q)

DNF Cleanups:

sudo dnf autoremove
sudo dnf remove --duplicates
sudo dnf remove --oldinstallonly

Move libvirt from root partition to home partition:

sudo cp -r /var/lib/libvirt /home
sudo rm -rf /var/lib/libvirt
sudo ln -s /home/libvirt /var/lib/libvirt

Fix SELinux issues with the symlink:

sudo su -
ausearch -c 'qemu-system-x86' --raw | audit2allow -M my-qemusystemx86
semodule -X 300 -i my-qemusystemx86.pp
ausearch -c 'libvirt_leasesh' --raw | audit2allow -M my-libvirtleasesh
semodule -X 300 -i my-libvirtleasesh.pp

Move docker from root partition to home partition:

sudo cp -r /var/lib/docker /home
sudo rm -rf /var/lib/docker
sudo ln -s /home/libvirt /var/lib/docker

Docker image cleanup:

docker image prune
docker rmi $(docker images -f "dangling=true" -q)

...more docker cleanup:remove all stopped containers

docker container prune

and then prune images again. cleanup everyting not currently used by docker:

docker system prune -a -f

Find the 30 heaviest installed packages:

rpm -qa --queryformat '%{name} %{size}\n' | sort -n -k 2 -r | head -n 30

Make sure that /tmp is cleaned on reboot:

systemctl unmask tmp.mount

Old kernels:

rpm -q kernel-core

Then run:

sudo dnf remove <kernel-core-xxx>

Log Files: See how much is used:

sudo journalctl --disk-usage

Make sure that conf is right SystemMaxUse=50M:

sudo vi /etc/systemd/journald.conf
sudo systemctl restart systemd-journald.service

Immdeiate cleanup:

sudo journalctl --vacuum-size=50M
@yuvalif
Copy link
Author

yuvalif commented Nov 21, 2023

after upgrade:

dnf system-upgrade clean
dnf clean packages
sudo dnf install remove-retired-packages
remove-retired-packages
sudo dnf install symlinks
sudo symlinks -r /usr | grep dangling
sudo symlinks -r -d /usr
dnf remove $(dnf repoquery --installonly --latest-limit=-1 -q)

@yuvalif
Copy link
Author

yuvalif commented Nov 26, 2023

git clean -xfdf

@yuvalif
Copy link
Author

yuvalif commented Oct 27, 2024

podman system prune -a --volumes

@yuvalif
Copy link
Author

yuvalif commented Oct 27, 2024

per directory analysis:

sudo du -sh * 2>/dev/null | sort -h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment