---
title: "Attach storage to a virtual machine"
method: POST
path: "/vm/{rid}/storage"
tags: ["VM"]
---

# Attach storage to a virtual machine

`POST /vm/{rid}/storage`

Create or import and attach a storage device to a shut-off virtual machine

## Path parameters

- `rid` integer, required

## Request body

- GithubComAlchemillahqSylveInternalInterfacesServicesLibvirtStorageAttachRequest
  - `attachType` 'import' | 'new', required
  - `bootOrder` integer
  - `dataset` string
  - `downloadUUID` string
  - `emulation` 'virtio-blk' | 'virtio-9p' | 'ahci-hd' | 'ahci-cd' | 'nvme', required
  - `filesystemTarget` string
  - `name` string
  - `pool` string
  - `rawPath` string
  - `readOnly` boolean
  - `recordSize` integer
  - `size` integer
  - `storageType` 'raw' | 'zvol' | 'image' | 'filesystem' | 'none', required
  - `volBlockSize` integer

## Response `201`

Created

- GithubComAlchemillahqSylveInternalAPIResponseGithubComAlchemillahqSylveInternalDbModelsVmStorage
  - `data` GithubComAlchemillahqSylveInternalDbModelsVmStorage
    - `bootOrder` integer
    - `dataset` GithubComAlchemillahqSylveInternalDbModelsVmVMStorageDataset
      - `guid` string
      - `id` integer
      - `name` string
      - `pool` string
    - `datasetId` integer
    - `emulation` 'virtio-blk' | 'virtio-9p' | 'ahci-hd' | 'ahci-cd' | 'nvme'
    - `enable` boolean
    - `filesystemTarget` string
    - `id` integer
    - `name` string
    - `pool` string
    - `readOnly` boolean
    - `recordSize` integer
    - `size` integer
    - `type` 'raw' | 'zvol' | 'image' | 'filesystem'
    - `uuid` string
    - `vmId` integer
    - `volBlockSize` integer
  - `error` string
  - `message` string
  - `status` string

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `409` — Conflict
- `413` — Request Entity Too Large
- `500` — Internal Server Error
- `503` — Service Unavailable

---

[API](https://skmtc.net/alchemillahq/apis/sylve-api.md) · [All operations](https://skmtc.net/alchemillahq/apis/sylve-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/alchemillahq/sylve-api/revisions/7a7bea85004e/schema)
