#!/bin/bash # Free System Data (351GB) # Most of this is purgeable space held by snapshots set -e echo "=== Free System Data (351GB) ===" echo "" echo "System Data is 351GB, but visible components only add up to ~20GB." echo "This means ~330GB is PURGEABLE SPACE held by snapshots." echo "" FREE_SPACE_BEFORE=$(df / | tail -1 | awk '{print $4}') FREE_SPACE_GB_BEFORE=$(echo "scale=2; $FREE_SPACE_BEFORE / 1024 / 1024" | bc) echo "Current free space: ${FREE_SPACE_GB_BEFORE}GB" echo "" echo "🔧 Step 1: Aggressively thin all snapshots..." sudo tmutil thinlocalsnapshots / 1000000000 1 2>&1 echo " ✓ Completed" echo "" echo "🔧 Step 2: Purge system memory and caches..." if command -v purge &> /dev/null; then sudo purge echo " ✓ Purged" else echo " ⚠️ Purge command not available" fi echo "" echo "🔧 Step 3: Remove Time Machine destination (CRITICAL)" echo "" echo " ⚠️ IMPORTANT: You MUST remove Time Machine destination to" echo " prevent new snapshots from being created!" echo "" echo " Do this now:" echo " 1. System Settings → General → Time Machine" echo " 2. Click '-' to remove backup disk" echo " 3. Confirm removal" echo "" read -p " Have you removed Time Machine destination? (y/n) " -n 1 -r echo "" if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo " ⚠️ Please remove it first, then run this script again." exit 1 fi echo "" echo "🔧 Step 4: Wait for system to release purgeable space..." echo " This may take a few minutes..." sleep 10 echo "" echo "🔧 Step 5: Try to delete stuck snapshot..." SNAPSHOT=$(tmutil listlocalsnapshots / 2>/dev/null | grep -v "Snapshots for disk" | grep -v "^$" | head -1) if [ -n "$SNAPSHOT" ]; then SNAP_DATE=$(echo "$SNAPSHOT" | sed 's/.*\.\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}\)\.backup/\1/') echo " Attempting to delete: $SNAPSHOT" if sudo tmutil deletelocalsnapshots "$SNAP_DATE" 2>/dev/null; then echo " ✅ Deleted!" else echo " ⚠️ Still stuck (ghost entry - will clear on restart)" fi else echo " ✅ No snapshots found" fi echo "" echo "⏳ Waiting for space to be released..." sleep 10 # Check results FREE_SPACE_AFTER=$(df / | tail -1 | awk '{print $4}') FREE_SPACE_GB_AFTER=$(echo "scale=2; $FREE_SPACE_AFTER / 1024 / 1024" | bc) FREED_GB=$(echo "scale=2; $FREE_SPACE_GB_AFTER - $FREE_SPACE_GB_BEFORE" | bc) echo "" echo "=== Results ===" echo " Before: ${FREE_SPACE_GB_BEFORE}GB free" echo " After: ${FREE_SPACE_GB_AFTER}GB free" if (( $(echo "$FREED_GB > 100" | bc -l) )); then echo " ✅ Successfully freed: ${FREED_GB}GB!" elif (( $(echo "$FREED_GB > 0" | bc -l) )); then echo " ✅ Freed: ${FREED_GB}GB" echo " (More space may be released over time)" else echo " ⚠️ No space freed yet" fi echo "" if (( $(echo "$FREE_SPACE_GB_AFTER < 50" | bc -l) )); then echo "⚠️ Still low on space. Additional steps:" echo "" echo "1. **Restart your Mac** - This is the most effective way" echo " to release purgeable space from snapshots." echo "" echo "2. Use macOS Storage Management:" echo " Apple Menu → About This Mac → Storage → Manage" echo " Click 'Optimize' to release purgeable space" echo "" echo "3. Wait 15-30 minutes - macOS may need time to" echo " release the purgeable space" echo "" echo "4. The 351GB in System Data is mostly purgeable space" echo " that will be released when snapshots are cleared." echo "" fi echo ""