> ## Documentation Index
> Fetch the complete documentation index at: https://docs.deepest.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Reclaim storage after deleting files

> Clean up disposable files and snapshots on a Computer, stop it explicitly, reclaim reusable blocks, and verify Account Storage usage.

Deleting a file inside Linux and freeing Account Storage (`storage_used_bytes`) are distinct events. Attached [disk snapshots](https://docs.deepest.dev/computers/snapshots-and-restore.md) can keep deleted blocks allocated, and the disk image may retain reusable blocks until you run **Storage Reclaim**.

Storage Reclaim operates on a **stopped Computer** (`computer(id).storage.reclaim()`), preserves your Computer ID, visible files, and retained snapshots, and reports Account usage before and after reclamation. It is available for Computers only (not Sandboxes) and does not shrink virtual disk geometry or automatically delete files.

## Distinguish Guest space from Account Storage

| Observation | What it measures |
| - | - |
| Guest `df -h` / `du` | Filesystem capacity and visible files inside one Computer |
| `resources.get()` (`storage_used_bytes`) | Account-wide Storage across all Computers, clones, and snapshots |

When `storage_status` is `over_limit`, growth operations (**Create, Clone, Snapshot**) fail with `STORAGE_LIMIT_EXCEEDED`. You can still Start an existing Computer to clean up data (subject to active entitlement and running Memory), and Reclaim itself is allowed while `over_limit`.

**1. Inspect and clean disposable files inside the Guest**

Connect over SSH or Exec and inspect actual usage before removing specific files you own:

```bash theme={null}
df -h
du -h --max-depth=1 "$HOME"
```

Delete only verified disposable artifacts (`rm -- '<REVIEWED_FILE>'`). When supported inside the Guest, `fstrim -av` hints unused filesystem blocks—though `fstrim` output is not an Account quota credit; `resources.get()` remains the authoritative measurement. Review obsolete snapshots separately and delete only checkpoints you no longer need.

**2. Explicitly Stop the Computer**

Save work and Stop the Computer (in the Console, **Stop**, then open **Settings → Advanced → Reclaim disk space → Reclaim deleted space**).

**3. Run Storage Reclaim and verify Account usage**

```js theme={null}
import { Deepest } from "@deepest/sdk";

const deepest = new Deepest({
  baseUrl: process.env.DEEPEST_API_URL,
  apiKey: process.env.DEEPEST_API_KEY,
});
const computer = deepest.computer(process.env.DEEPEST_COMPUTER_ID);

const stopped = await computer.stop();
if (!stopped.ok || stopped.result.state !== "stopped") {
  throw new Error("Stop not confirmed; query the original Computer first.");
}

const reclaimed = await computer.storage.reclaim();
if (!reclaimed.ok) throw new Error(`${reclaimed.error.code} (${reclaimed.retry})`);
console.log({
  outcome: reclaimed.result.outcome,
  beforeBytes: reclaimed.result.storage_used_before_bytes,
  afterBytes: reclaimed.result.storage_used_after_bytes,
});

const poolAfter = await deepest.resources.get();
if (!poolAfter.ok) throw new Error(poolAfter.error.code);
console.log(poolAfter.result.storage_status, poolAfter.result.storage_used_bytes);
```

**4. Start again only if needed**

Reclaim leaves the Computer `stopped` (releasing running Memory). Call `computer.start()` when you are ready to cold-boot and verify retained files, or leave it stopped to keep disk files without consuming running RAM.

## Interpret `outcome` accurately

* **`completed`:** Supported reclamation ran and reports observed Account bytes before/after (not a guaranteed percentage or fixed byte savings).
* **`no_change`:** Confirmed no-change outcome—not an instruction to delete more files automatically.
* **Snapshots & concurrent writes:** Because `storage_used_before_bytes` and `storage_used_after_bytes` measure the **whole Account**, retained snapshots or concurrent writes on another Machine can keep usage flat or even raise it.

## Failure and recovery

| Code | Recovery |
| - | - |
| `STOPPED_REQUIRED` | Save work, explicitly Stop, and confirm `stopped` state |
| `RESOURCE_CONFLICT` | Resolve concurrent lifecycle dependency; query original assets |
| `STORAGE_RECLAIM_UNSUPPORTED` | Layout does not support reclaim; disk is preserved—contact Support |
| `STORAGE_RECLAIM_INSUFFICIENT_SPACE` | Reclaim needs working headroom; clean authorized data or upgrade capacity |
| `STORAGE_RECLAIM_FAILED` | Failure preserves the disk; contact Support rather than manual destructive workarounds |
| `LIFECYCLE_BUSY` / `RUNTIME_UNAVAILABLE` (`retry: "safe"`) | Wait `error.retry_after_seconds` (when 429) or capacity recovery and retry explicitly |
| `UNKNOWN` (`retry: "query-first"`) | Query `computer.get()` and `resources.get()` before repeating; never create replacement Computers to escape uncertainty |

See [Account resources](https://docs.deepest.dev/concepts/account-resources.md), [Disk snapshots and restore](https://docs.deepest.dev/computers/snapshots-and-restore.md), and [Errors](https://docs.deepest.dev/api-and-sdk/errors.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.