65 lines
2.5 KiB
PowerShell
65 lines
2.5 KiB
PowerShell
# NAS full /volume1/ scan with sudo (English-only)
|
|
# Step 1: User runs `sudo -v` first (password stays local, never enters Claude)
|
|
# Step 2: This script reuses that 15-min sudo session
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
$outputFile = "$PSScriptRoot\nas_volumes.txt"
|
|
|
|
chcp 65001 | Out-Null
|
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
|
|
Write-Host "===================================" -ForegroundColor Cyan
|
|
Write-Host " NAS Full Scan (with sudo)" -ForegroundColor Cyan
|
|
Write-Host "===================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "PREREQUISITE: open another terminal and run:" -ForegroundColor Yellow
|
|
Write-Host " ssh simon@100.85.152.112" -ForegroundColor White
|
|
Write-Host " sudo -v <- enter simon's password here, password NOT sent to Claude" -ForegroundColor White
|
|
Write-Host " (keep that SSH session open for 15 min, sudo session cached)" -ForegroundColor White
|
|
Write-Host ""
|
|
Read-Host "Press Enter after you have done sudo -v above"
|
|
|
|
# Force allocation so sudo can read password from terminal if needed
|
|
$cmd = @"
|
|
sudo bash <<'NAS_EOF'
|
|
echo '===== [1] All top-level entries under /volume1/ ====='
|
|
ls -la /volume1/ 2>&1
|
|
echo ''
|
|
echo '===== [2] Direct children sizes (1-3 minutes) ====='
|
|
du -sh /volume1/*/ 2>/dev/null | sort -rh
|
|
echo ''
|
|
echo '===== [3] Disk space ====='
|
|
df -h /volume1 2>&1 | head -3
|
|
echo ''
|
|
echo '===== [4] /volume1/homes/ ====='
|
|
ls -la /volume1/homes/ 2>&1 | head -20
|
|
echo ''
|
|
echo '===== [5] /volume1/homes/simon/ top dirs by size ====='
|
|
du -sh /volume1/homes/simon/*/ 2>/dev/null | sort -rh | head -20
|
|
echo ''
|
|
echo '===== [6] /volume1/docker/ top dirs by size (likely big) ====='
|
|
du -sh /volume1/docker/*/ 2>/dev/null | sort -rh | head -20
|
|
echo ''
|
|
echo '===== [7] Largest top-level dirs (top 15) ====='
|
|
du -sh /volume1/* 2>/dev/null | sort -rh | head -15
|
|
echo ''
|
|
echo '===== [8] Mounts / storage pools ====='
|
|
mount | grep -E 'volume|tank' 2>&1 | head -10
|
|
echo ''
|
|
echo '===== DONE ====='
|
|
NAS_EOF
|
|
"@
|
|
|
|
ssh -t simon@100.85.152.112 "$cmd" 2>&1 | Tee-Object -FilePath $outputFile -Encoding UTF8
|
|
|
|
Write-Host ""
|
|
Write-Host "===================================" -ForegroundColor Green
|
|
Write-Host " Done. Output saved to:" -ForegroundColor Green
|
|
Write-Host " $outputFile" -ForegroundColor White
|
|
Write-Host "===================================" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Please paste the ENTIRE contents of nas_volumes.txt back" -ForegroundColor Yellow
|
|
Write-Host "(or just tell me which top-level dir is largest)" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Read-Host "Press Enter to close"
|