#!/bin/bash # search and destroy garbage files in root find / -type f -iname "thumbs.db" -exec rm {} \; 2> /dev/null & find / -type f -iname ".ds_store" -exec rm {} \; 2> /dev/null & find / -type f -name '._*' -exec rm -rf {} \; 2> /dev/null & # fstrim and defragment ext4 for filesystem in $(mount -t ext4 | awk '{print $3}'); do fstrim "$filesystem" e4defrag "$filesystem" done # rebalance and trim SSD btrfs (HDD are too slow and should be done manually) for filesystem in $(mount -t btrfs | grep "ssd" | awk '{print $3}'); do btrfs balance start -musage=11 dusage=10 "$filesystem" fstrim "$filesystem" done # cleanup journalctl journalctl --vacuum-time=5d --vacuum-size=500M