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

# Cleanup

> Remove every byte mxnode wrote. Stop and disable units, delete workdirs, wipe the binstore, drop state and config.

Remove every byte mxnode wrote. Stop and disable units, delete workdirs, wipe the binstore, drop state and config.

## Shortest commands

```bash theme={"system"}
mxnode cleanup --yes                       # dry-run (default)
mxnode cleanup --yes --execute             # actually delete
```

`--yes` is required regardless — cleanup is destructive enough that it requires for explicit intent.

## Options

| Flag              | Effect                                                                                                    |
| ----------------- | --------------------------------------------------------------------------------------------------------- |
| `--yes`           | Required to proceed past dry-run.                                                                         |
| `--execute`       | Switch from dry-run to actual deletion.                                                                   |
| `--keep-binaries` | Preserve `<custom_home>/mxnode/` (binstore + git build cache). Re-install reuses cached binaries.         |
| `--keep-config`   | Preserve `~/.config/mxnode/config.toml`. Next install starts from your existing config without auto-init. |

## What gets removed

| Path                                                                                | Why                                               |
| ----------------------------------------------------------------------------------- | ------------------------------------------------- |
| Systemd units (`/etc/systemd/system/elrond-node-*.service`, `elrond-proxy.service`) | Stopped, disabled, then removed (with `sudo`)     |
| `<custom_home>/elrond-nodes/`                                                       | Per-node workdirs                                 |
| `<custom_home>/elrond-utils/`                                                       | The shared `keygenerator` binary                  |
| `<custom_home>/elrond-proxy/`                                                       | Proxy workdir, if installed                       |
| `<custom_home>/mxnode/`                                                             | Versioned binstore + git build cache (300–500 MB) |
| `<state>/mxnode/`                                                                   | `state.toml`, `state.toml.lock`, `inflight.toml`  |
| `<config>/mxnode/config.toml`                                                       | The auto-init'd config                            |

## Sample dry-run

```bash theme={"system"}
$ mxnode cleanup --yes
cleanup plan (dry-run):
  stop elrond-node-0.service
  disable elrond-node-0.service
  sudo rm /etc/systemd/system/elrond-node-0.service
  rm -rf /home/<you>/elrond-nodes/node-0
  ...
  rm -rf /home/<you>/mxnode
  rm -rf /home/<you>/.local/state/mxnode
  rm /home/<you>/.config/mxnode/config.toml

No changes made. Re-run with --execute to actually delete.
```

## Cleanup with no state

If `state.toml` is missing but managed directories still exist (e.g. partial install), cleanup still works:

```bash theme={"system"}
mxnode cleanup --yes --execute
```

It scans for `<custom_home>/elrond-{nodes,utils,proxy}` and the mxnode footprint, removes whatever it finds, and exits cleanly.

## What cleanup does **not** touch

* The `mxnode` binary itself (use `sudo rm /usr/local/bin/mxnode` to also remove the CLI)
* `/usr/local/go/` (even if mxnode installed it)
* Other validator zips parked in `<node_keys>` outside the workdirs
* Apt packages mxnode installed during bootstrap (`build-essential`, `git`, etc.) — those are system tools

## When to use what

| Situation                                              | Command                                                                                                             |
| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
| Done with this host                                    | `mxnode cleanup --yes --execute`                                                                                    |
| Switching from validator → multikey                    | `mxnode cleanup --yes --execute` then re-install                                                                    |
| Re-installing after a botched try, want cached rebuild | `mxnode cleanup --yes --execute --keep-binaries`                                                                    |
| Just clearing workdirs to free disk, want same config  | `mxnode cleanup --yes --execute --keep-config --keep-binaries`                                                      |
| Stale `inflight.toml` blocking an upgrade              | **Don't use cleanup** — the next `upgrade` auto-clears stale locks. See [troubleshooting](/mxnode/troubleshooting). |
