Synopsis
Description
Thecleanup command removes stale or auto-created VMs and their associated resources. By default, it targets VMs with the vm- prefix and any VMs that have been reconciled as stale.
Options
Delete all VMs, not just stale or auto-created ones.
Auto-VM prefix to clean. Only VMs starting with this prefix (or marked as stale) will be targeted.
Print targets without deleting. Useful for previewing what would be cleaned up.
Examples
Clean auto-created VMs (default prefix)
Remove VMs with IDs starting withvm- and any stale VMs:
Preview cleanup targets
See what would be deleted without actually deleting:Clean VMs with custom prefix
Remove VMs starting with a custom prefix:Delete all VMs
Cleanup Process
The cleanup command performs the following steps:- Reconciliation: Identifies stale VMs (VMs with state entries but no running processes)
- Target Selection: Based on
--allor--prefix, selects VMs to delete - Resource Cleanup: For each target VM:
- Stops the VM process (if running)
- Removes TAP network devices
- Cleans up nftables rules
- Removes state database entries
Exit Codes
| Code | Description |
|---|---|
0 | Success - all targets cleaned successfully |
1 | Partial failure - some VMs could not be deleted |
Standalone Command
The cleanup command is also available as a standalone script:smolvm cleanup.
Related Commands
smolvm doctor- Diagnose system setup before cleanup