How to detach fly volume

I want to detach and remove a volume.

I tried to detach by removing it from fly.toml and redeploying, but got this error:

Error: machine 178190db4e0e89 [app] has a volume mounted but app config does not specify a volume; remove the volume from the machine or add a [mounts] section to fly.toml

I cannot find a command to “remove the volume from the machine”. I tried fly destroy, but got this error:

Error: failed destroying volume: failed to destroy volume vol_5vgjkj3enmn90mpv: failed_precondition: volume is currently bound to machine: 6e8226ec272187

Even if I stop the machine I cannot destroy the volume. How do I detach the volume? I can’t seem to find the answer in the docs.

1 Like

hi @jmuncaster

fly volumes destroy <volume id> is the correct command to destroy a volume. (You will lose all data stored on the volume when you do this.) To “unmount” a volume without destroying it, you would destroy the Machine it’s attached to.

I think the issue you’re having now stems from deploying without mounts first and that updated the machine/volume incorrectly. I can reproduce it. And wasn’t able to destroy the volume without destroying the machine first.

1. Destroy the machine:

fly m destroy <machine id>

2. Then destroy the volume:

fly vol destroy <volume id>

Note: If you have more than one machine with attached volume, you’ll need to repeat this with the second machine and volume.

3. Remove the mounts section from your fly.toml.

4. Then, run fly deploy and your app will deploy with new machines and no volumes attached.

I’m sorry this wasn’t an ideal experience, and we’ll look into making it better.

1 Like

I did this and it worked. Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.