Can't mount volume to a machine

Hi - I’m not able to mount a volume to a machine.

I’m running this command:

fly m update MACHINE_ID -v vol_ID:/app/data:size=3

Error is:

Searching for image 'registry.fly.io/agent-hq-python:deployment-REDACTED' remotely...
Error You hit a Fly API error with request ID: 01GR6QH0C0GD4Z5NVDXWG2FFPX-chi

Any ideas?

If the volume doesn’t already exist, I would go ahead and create it separately:

fly volumes create ...

Then clone your existing machine while specifying the --attach-volume argument.

fly machines clone <existing-machine-id> --attach-volume <volume-id>
1 Like

It does already exist - should I still clone it?

Yeah, give it a shot.

Ok:


Cloning machine 9080552f653268 into region ord
Provisioning a new machine with image registry.fly.io/agent-hq-python:deployment-01GR6M4942T1GR08RQR84F9PDE...
  Machine 4d89660b6e7ed8 has been created...
  Waiting for machine 4d89660b6e7ed8 to start...
No health checks found
Machine has been successfully cloned!

But when I SSH in I don’t see the volume.

:wink: any other ideas? I tried this again after cloning but got the same error:

fly m update MACHINE_ID -v vol_ID:/app/data:size=3

:laughing:

So you’re right that fly m update won’t mount the volume. We have a known issue on that, but it’s possible that update isn’t the right place for any sort of volume mounting activity. This UX is in flux!

fly m clone with --attach-volume should mount the existing volume if it says it succeeded. If you do fly m list you should see whether there’s a volume associated with each machine.

You can see the machine’s JSON-formatted config with fly m status <machine-id> -d. Make sure you’re looking at the new machine, not the original! If the config has been updated properly, there should be a "mounts" section in there with a volume id matching the one you specified.

fly m list doesn’t show any volumes attached: Markup 2023-02-01 at 12.14.04.png - Droplr

although the clone command did succeed when I ran it.

fly m status -d with the cloned machine id gives:

{
  "env": null,
  "init": {
    "exec": null,
    "entrypoint": null,
    "cmd": null,
    "tty": false
  },
  "image": "registry.fly.io/agent-hq-python:deployment-01GR6M4942T1GR08RQR84F9PDE",
  "metadata": null,
  "restart": {
    "policy": ""
  },
  "guest": {
    "cpu_kind": "shared",
    "cpus": 1,
    "memory_mb": 256
  },
  "metrics": null
}

Which looks to me like there’s no volume mounted.

What’s the correct way to create a machine from scratch with a volume attached?

Thanks, I was curious about all that; I think we may have some missing links in fly m clone.

Now for maybe the good news: if you just want to create a machine with a volume attached, you can mount an existing volume on a newly created Machine using fly m run.

There are more things to think about if you’re using the prerelease flyctl and testing out Apps V2, but otherwise, that may be the simplest way to go.

So, fly m run --attach-volume VOLUME_ID?

Edit: it’s

fly m run . -v vol_ID:/app/data

I’m trying that now and will let you know if it works.

2 Likes

fly m run -v (fly m run -h prints the available flags)

(Also, I’m very much not sure that your :size=3 option does anything)

1 Like

Ok, that succeeded and the machine shows a mounted volume.

Note that the docs here: Run a Machines App Using flyctl · Fly Docs

show you creating the machine in region yyz which is confusing. I think I was having issues because the volume and the machines were not in the same region.

3 Likes