Why can't I detach my volume?
3 min read
Summary
Detaching is a detachVolume field on the compute instance patch action (PATCH /v1/compute-instances/{name}, body {"detachVolume": "<volume-name>"}) — the same endpoint the dashboard's Detach Volume button calls. The API only checks that the volume exists and is actually attached to that instance; it has no idea whether the volume's filesystem is mounted and busy inside the instance, so that's almost always where a "stuck" detach really comes from.
Common causes
- The volume's filesystem is still mounted inside the instance. This is the most common cause. The API doesn't check for this — it just removes the volume from the instance's spec — so a mounted, in-use filesystem is an OS-level problem the API won't warn you about.
- Wrong volume name, or it's not attached to this instance. The API resolves the name you pass and returns a 404 (
Volume '<name>' is not attached to instance '<name>') if it can't find that volume among the instance's current attachments. - Both
addVolumeanddetachVolumein the same request. Only one is allowed per patch — this returns a 400.
How to resolve it
- SSH into the instance and check what's using the mount point before you touch the API:
sonic ssh web-01
sudo fuser -vm /mnt/data
This lists any processes with open files on that mount. Stop or kill them, then unmount:
sudo umount /mnt/data
If umount reports "target is busy," repeat fuser -vm — something is still holding it open.
- Once it's unmounted, detach it through the dashboard (select the instance's row → Detach Volume → pick the volume → Confirm), or call the field directly:
PATCH /v1/compute-instances/web-01
{"detachVolume": "vol-8842"}
Still stuck?
Search the Knowledge Base for your exact error, or reach out from your dashboard's support panel. See also Attach a volume to a compute instance for the reverse flow.