As mentioned in this comment, “you can’t use m update to change which volume is mounted to a VM”.
I noticed that the same seems to be valid for the machines API, where I get a pretty misleading response when updating a machine by simply replacing the volume id in its config with the id of a new volume already created in the same region as the machine. Response: {"error":"invalid_argument: volume does not exist"}
Is there any way to change the volume attached to a machine?
The volume and the machine need to be on the same physical host. So what happened was you created a new volume in the same region but on a different host.
If you want to use the API to change the volume a Machine is attached to, you can just destroy the Machine and create a new one, attaching the new volume on create. Destroying the Machine won’t destroy the old volume. If you don’t want the old volume, you’ll need to explicitly destroy it.
When you’re using Fly Launch commands (fly launch + fly deploy), this is still true, but it’s less visible. If you create an app from scratch with volumes, Fly Launch puts Machines and volumes on the same host. If your app is already running Machines, and then you add volumes and run fly deploy, those Machines actually get replaced by Machines on the same hosts as the volumes.