disk.pt

Disk health and cleanup guide

Commands for Windows, macOS and Linux, from safest to riskiest. Each says what it does and whether it deletes anything.

Before you start: back up what matters. Each command carries a label: read-only (changes nothing), changes (safe) or deletes (cannot be undone). disk.pt runs nothing on your computer: you copy the command and run it yourself. Read each description before pasting.

First of all: a backup

Before repairing or deleting, follow the 3-2-1 rule: three copies, on two kinds of media, one off-site. A failing drive can die under the stress of a repair.

SSD: keep 10-20 % free

A very full SSD gets slower and wears faster because it has fewer free blocks to manage writes. Do not defragment it. TRIM is automatic on all current systems.

SSD: what to watch

Wear percentage (Percentage Used / Wear), available spare blocks and data integrity errors. An SSD at 100 % wear still works for a while but is out of warranty territory: replace it.

HDD: warning signs

Clicking or scraping, files that take long to open, the system freezing when accessing the drive, and SMART showing Reallocated_Sector_Ct, Current_Pending_Sector or Offline_Uncorrectable above zero. Copy what matters now.

SMART "OK" is not a guarantee

Many drives fail without warning. SMART helps but does not replace backups.

Commands by system

Open PowerShell. For commands that need it, use "Run as administrator" (right-click the icon).

Free space per drive Read-only

Shows used and free space. Windows labels GiB (1024-based) as "GB".

Get-PSDrive -PSProvider FileSystem | Select-Object Name, @{n='Usado(GiB)';e={[math]::Round($_.Used/1GB,1)}}, @{n='Livre(GiB)';e={[math]::Round($_.Free/1GB,1)}}

Drive health status Read-only

Type (SSD or HDD), health and operational status as Windows reports it.

Get-PhysicalDisk | Select-Object FriendlyName, MediaType, BusType, HealthStatus, OperationalStatus, @{n='Tamanho(GiB)';e={[math]::Round($_.Size/1GB)}}

Wear, temperature and power-on hours Read-only

Reliability counters (needs administrator). Some drives and USB adapters do not expose them and the columns stay empty. Wear is the SSD wear percentage.

Get-PhysicalDisk | Get-StorageReliabilityCounter | Select-Object DeviceId, Wear, Temperature, PowerOnHours, ReadErrorsTotal, WriteErrorsTotal

Check the file system (no repair) Read-only

Without options chkdsk only reads and reports. Do not use /f or /r before you have a backup: on a failing drive, repair can make things worse.

chkdsk C: /scan

Size of the temp folder Read-only

How many GiB your temp folder takes.

[math]::Round((Get-ChildItem $env:TEMP -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum / 1GB, 2)

Analyse the component store (WinSxS) Read-only

Tells you whether cleaning is worthwhile. WinSxS looks huge in Explorer but much of it is hard links. Needs administrator.

Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

Re-optimise an SSD (TRIM) Changes (safe)

Tells the SSD which blocks are free. Windows already does this weekly; you only need it if in doubt. Replace C with the drive letter. Needs administrator.

Optimize-Volume -DriveLetter C -ReTrim -Verbose

Defragment (HDD only) Changes (safe)

Only useful on mechanical hard drives. On an SSD it is unnecessary and wastes write cycles: Windows handles it by itself.

⚠ Do not run this on an SSD.

Optimize-Volume -DriveLetter D -Defrag -Verbose

Clean up old update components Deletes

Removes superseded versions of Windows components. Afterwards you cannot uninstall updates already applied. Needs administrator.

⚠ Not reversible.

Dism.exe /Online /Cleanup-Image /StartComponentCleanup

Turn off hibernation (frees hiberfil.sys) Changes (safe)

Frees several GB but disables hibernation and Fast Startup. To undo: powercfg /h on. Needs administrator.

powercfg /h off

Delete temporary files Deletes

Deletes the contents of your temp folder. Close apps first; files in use are skipped.

⚠ Deletes permanently (does not go to the Recycle Bin).

Remove-Item "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue

Empty the Recycle Bin Deletes

Deletes everything in the Recycle Bin on all drives.

⚠ Look inside the Recycle Bin first.

Clear-RecycleBin -Force

Tip: to see visually what takes space, use the 3D explorer.