#!/bin/bash # Free Photo Cache Space # The photo volume is taking 179GB - likely a local cache set -e echo "=== Free Photo Cache Space ===" echo "" echo "Found: /System/Volumes/Data/Volumes/photo is 179GB" echo "This is a mounted NAS share that's being cached locally." 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 "" # Check if it's the same as /Volumes/photo echo "🔍 Checking mount points:" MOUNT_POINT=$(mount | grep photo | awk '{print $3}') echo " Network mount: $MOUNT_POINT" echo " Cache location: /System/Volumes/Data/Volumes/photo" echo "" # Check sizes CACHE_SIZE=$(sudo du -sh /System/Volumes/Data/Volumes/photo 2>/dev/null | awk '{print $1}') MOUNT_SIZE=$(sudo du -sh "$MOUNT_POINT" 2>/dev/null | awk '{print $1}' || echo "N/A") echo " Cache size: $CACHE_SIZE" echo " Mount size: $MOUNT_SIZE" echo "" echo "⚠️ The 179GB in /System/Volumes/Data/Volumes/photo is likely:" echo " - A local cache of the network share" echo " - Or files that were copied locally" echo "" echo "🔧 Solution:" echo "" echo "Option 1: Unmount the network share (if not needed right now)" echo " diskutil unmount /Volumes/photo" echo " This will free the space immediately" echo "" echo "Option 2: Clear the cache (if it's a cache)" echo " ⚠️ WARNING: Make sure files are on NAS first!" echo " sudo rm -rf /System/Volumes/Data/Volumes/photo/*" echo "" echo "Option 3: Check if files are duplicated" echo " Compare /Volumes/photo vs /System/Volumes/Data/Volumes/photo" echo " If they're the same, you can safely remove the cache" echo "" read -p "Do you want to unmount /Volumes/photo to free space? (y/n) " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then echo "" echo "Unmounting /Volumes/photo..." if diskutil unmount /Volumes/photo 2>/dev/null; then echo "✅ Successfully unmounted" echo "" echo "⏳ Waiting for space to be released..." sleep 5 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 > 150" | bc -l) )); then echo " ✅ Freed: ${FREED_GB}GB (179GB cache released!)" elif (( $(echo "$FREED_GB > 0" | bc -l) )); then echo " ✅ Freed: ${FREED_GB}GB" else echo " ⚠️ Space not freed yet (may need to clear cache manually)" fi else echo "⚠️ Could not unmount (may be in use)" echo " Try: sudo umount /Volumes/photo" fi fi echo ""