101 lines
3.2 KiB
Bash
Executable File
101 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Force Purge System Data (351GB)
|
|
# The 351GB is likely "purgeable" space that macOS won't release until forced
|
|
|
|
set -e
|
|
|
|
echo "=== Force Purge System Data (351GB) ==="
|
|
echo ""
|
|
echo "The 351GB in System Data is likely PURGEABLE space."
|
|
echo "macOS shows it as 'used' but it's actually available."
|
|
echo "We'll force macOS to release it by creating a large file."
|
|
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 "🔧 Method: Create a large file to force purge..."
|
|
echo ""
|
|
echo " This will:"
|
|
echo " 1. Create a 50GB file (forces macOS to purge space)"
|
|
echo " 2. Delete it immediately"
|
|
echo " 3. This should release the purgeable space"
|
|
echo ""
|
|
|
|
read -p "Proceed? This is safe - file will be deleted immediately. (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Cancelled."
|
|
exit 0
|
|
fi
|
|
|
|
echo ""
|
|
echo "Creating 50GB test file to force purge..."
|
|
echo " (This may take a few minutes)"
|
|
echo ""
|
|
|
|
# Create large file to force purge
|
|
TEST_FILE="$HOME/test_force_purge_$(date +%s).tmp"
|
|
if dd if=/dev/zero of="$TEST_FILE" bs=1g count=50 2>/dev/null; then
|
|
echo " ✅ Created 50GB file"
|
|
echo ""
|
|
echo " Checking space after creation..."
|
|
sleep 2
|
|
FREE_DURING=$(df / | tail -1 | awk '{print $4}')
|
|
FREE_DURING_GB=$(echo "scale=2; $FREE_DURING / 1024 / 1024" | bc)
|
|
echo " Free space during: ${FREE_DURING_GB}GB"
|
|
echo ""
|
|
|
|
echo " Deleting test file..."
|
|
rm -f "$TEST_FILE"
|
|
echo " ✅ Deleted"
|
|
else
|
|
echo " ⚠️ Could not create file (not enough space or permission issue)"
|
|
echo " This means the purgeable space may not be available"
|
|
fi
|
|
|
|
echo ""
|
|
echo "⏳ Waiting for system to update..."
|
|
sleep 10
|
|
|
|
# Check final 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!"
|
|
echo " The purgeable space was released!"
|
|
elif (( $(echo "$FREED_GB > 0" | bc -l) )); then
|
|
echo " ✅ Freed: ${FREED_GB}GB"
|
|
else
|
|
echo " ⚠️ No space freed"
|
|
fi
|
|
echo ""
|
|
|
|
echo "=== Understanding System Data (351GB) ==="
|
|
echo ""
|
|
echo "If System Data still shows 351GB but you have free space,"
|
|
echo "this is NORMAL macOS behavior:"
|
|
echo ""
|
|
echo " - System Data includes PURGEABLE space"
|
|
echo " - Purgeable space is AVAILABLE but shown as 'used'"
|
|
echo " - macOS will release it automatically when needed"
|
|
echo " - The space is actually available for use"
|
|
echo ""
|
|
echo "To verify space is available:"
|
|
echo " 1. Try creating a large file (you just did)"
|
|
echo " 2. Check Activity Monitor → Disk → Purgeable"
|
|
echo " 3. The space will be released when you actually need it"
|
|
echo ""
|
|
echo "The 351GB in System Data is misleading - much of it"
|
|
echo "is purgeable and available when needed."
|
|
echo ""
|