📚 node [[clearing up drive space used by snap]]
Clearing up drive space used by snap
- 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/
.
📖 stoas
- public document at doc.anagora.org/clearing-up-drive-space-used-by-snap
- video call at meet.jit.si/clearing-up-drive-space-used-by-snap
🔎 full text search for 'clearing up drive space used by snap'