# Find the instance a volume is attached to

Follow an INUSE volume's claimRef to its volume attachment and from there to the instance that holds it, with one CLI command or API query.

A volume that reports `INUSE` names what holds it in `claimRef`: the id of a volume attachment. Follow that attachment to find the instance, for example before you detach the volume to delete it.

## Before you begin [#before-you-begin]

<BeforeYouBegin>

- The volume’s URN and the URN of the project it belongs to.
- Permission `compute.instance.list` on the project, the same permission that lets you list the project’s instances. See [Roles](/docs/iam/roles).

</BeforeYouBegin>

## Find the instance [#find-the-instance]

1. Read the volume’s `claimRef`.

   ```sh
   origin storage get-volume --volume-urn <volume-urn>
   ```

1. List the attachments that reference the volume.

   ```sh
   origin compute list-volume-attachments \
     --project-urn <project-urn> --volume-urn <volume-urn>
   ```

   With the API, use the `volumeAttachments` query:

   ```graphql
   query {
     compute {
       volumeAttachments(input: {
         projectUrn: "<project-urn>"
         volumeUrn: "<volume-urn>"
       }) {
         id
         instanceUrn
         deviceName
         status
       }
     }
   }
   ```

1. Take the entry whose `id` equals the volume’s `claimRef`. Its `instanceUrn` is the instance, and `deviceName` is the device name the guest sees.
1. Confirm by reading the instance. Its `volumeAttachments` include the volume.

   ```sh
   origin compute get-instance --instance-urn <instance-urn>
   ```

## Reading the attachment list [#reading-the-attachment-list]

Normally the list has one entry, with status `ATTACHED`. Other entries appear while an attach or detach is in progress and after an attach that `FAILED`. An entry with status `RELEASE_ABANDONED` may still hold the volume: the platform has stopped trying to release it. Detached attachments aren’t listed.

A volume from another project returns an empty list, exactly like a volume that doesn’t exist.

## Next steps [#next-steps]

- [Attach and detach volumes](/docs/compute/instance-storage/attach-detach)
- [Delete a volume](/docs/storage/volumes/delete)

## Related [#related]

- [`list-volume-attachments` command](/docs/compute/reference/cli#list-volume-attachments)
- [Volume states](/docs/storage/volumes/volume-states)

