#!/bin/bash # Deep Space Analysis - Find where the 20GB actually went # When deleted files don't free space even after restart set -e echo "=== Deep Space Analysis ===" echo "" # Container vs Volume space echo "📊 Container vs Volume Space:" echo " Container Total: $(diskutil info / | grep 'Container Total' | awk '{print $4, $5}')" echo " Container Free: $(diskutil info / | grep 'Container Free' | awk '{print $4, $5}')" echo " Volume Used: $(diskutil info / | grep 'Volume Used Space' | awk '{print $4, $5, $6}')" echo "" # Calculate discrepancy CONTAINER_TOTAL=$(diskutil info / | grep 'Container Total' | awk '{print $3}' | tr -d 'GB') CONTAINER_FREE=$(diskutil info / | grep 'Container Free' | awk '{print $3}' | tr -d 'GB') VOLUME_USED=$(diskutil info / | grep 'Volume Used Space' | awk '{print $4}' | tr -d 'GB') CONTAINER_USED=$(echo "$CONTAINER_TOTAL - $CONTAINER_FREE" | bc) DISCREPANCY=$(echo "$CONTAINER_USED - $VOLUME_USED" | bc) echo " Container Used: ~${CONTAINER_USED}GB" echo " Volume Used: ~${VOLUME_USED}GB" if (( $(echo "$DISCREPANCY > 5" | bc -l) )); then echo " ⚠️ Discrepancy: ~${DISCREPANCY}GB unaccounted for!" echo " This space may be in:" echo " - Other APFS volumes" echo " - APFS snapshots" echo " - Reserved space" echo " - System files" fi echo "" # Check all APFS volumes echo "📦 APFS Volumes:" diskutil apfs list 2>/dev/null | grep -E "Volume Name|Used Space|Free Space" | head -20 | sed 's/^/ /' echo "" # Check snapshots echo "📸 APFS Snapshots:" SNAP_COUNT=$(diskutil apfs listSnapshots / 2>/dev/null | grep -c "Name:" || echo "0") echo " Found $SNAP_COUNT snapshot(s)" if [ "$SNAP_COUNT" -gt 0 ]; then diskutil apfs listSnapshots / 2>/dev/null | grep -E "Name|Purgeable" | head -6 | sed 's/^/ /' fi echo "" # Check for large directories that might have been missed echo "🔍 Large Directories Check:" echo " Home directory: $(du -sh ~ 2>/dev/null | awk '{print $1}')" echo " Documents: $(du -sh ~/Documents 2>/dev/null | awk '{print $1}')" echo " Library: $(du -sh ~/Library 2>/dev/null | awk '{print $1}')" echo " Downloads: $(du -sh ~/Downloads 2>/dev/null | awk '{print $1}')" echo " Movies: $(du -sh ~/Movies 2>/dev/null | awk '{print $1}')" echo "" # Check if files were actually deleted echo "❓ Verification:" echo " You mentioned deleting 20GB from Movies/Videos folder" echo " Current Movies folder: $(du -sh ~/Movies 2>/dev/null | awk '{print $1}')" echo "" echo " Questions:" echo " 1. Did you delete from ~/Movies or another location?" echo " 2. Did you empty Trash after deleting?" echo " 3. Are the files still in Trash?" echo "" # Check trash TRASH_SIZE=$(du -sh ~/.Trash 2>/dev/null | awk '{print $1}' || echo "0") echo " Trash size: $TRASH_SIZE" echo "" # Summary echo "=== Analysis ===" echo "" if (( $(echo "$DISCREPANCY > 15" | bc -l) )); then echo "⚠️ Found ${DISCREPANCY}GB+ unaccounted space in container!" echo "" echo " This suggests:" echo " 1. Files may not have been actually deleted" echo " 2. Space is in another APFS volume" echo " 3. APFS snapshots are holding space" echo " 4. System reserved space" echo "" echo " Next steps:" echo " 1. Verify files were actually deleted (not just moved to Trash)" echo " 2. Empty Trash: rm -rf ~/.Trash/*" echo " 3. Check other volumes: diskutil apfs list" echo " 4. Check for large files: find ~ -size +1G -type f 2>/dev/null" echo "" else echo " Space accounting looks normal." echo " The 20GB may have been:" echo " - Used by other files growing" echo " - Actually still present (not deleted)" echo " - In Trash (not emptied)" echo "" fi echo ""