Clearing up drive space used by snap
*planted: 27/03/2025last tended: 28/03/2025
- Find things that are taking up a lot of space in
/snap
. - Check if they have any dependent snaps. (surely there should be a built in way of checking this?)
#!/bin/bash # Check if a target snap is provided if [ -z "$1" ]; then echo "Usage: $0 <target-snap>" exit 1 fi TARGET_SNAP="$1" # Get list of all installed snaps INSTALLED_SNAPS=$(snap list | awk 'NR>1 {print $1}') # Check connections and base for each snap echo "Checking dependencies for: $TARGET_SNAP" echo "----------------------------------------" for snap in $INSTALLED_SNAPS; do # Check connections if snap connections "$snap" | grep -q "$TARGET_SNAP"; then echo "[Connection] $snap depends on $TARGET_SNAP" fi # Check base declaration if snap list "$snap" | awk -v target="$TARGET_SNAP" 'NR>1 {if ($5 == target) print}' | grep -q .; then echo "[Base Snap] $snap uses $TARGET_SNAP as its base" fi done
- Remove them with
snap remove package-name
. - Clear
/var/lib/snapd/cache/
.
1. Elsewhere
1.1. In my garden
Notes that link to this note (AKA backlinks).