Create and attach disks

This guide shows you how to create boot disks and data disks, attach them to virtual machines, and manage them using the evroc CLI.

For information about disks and how they work, see Disks.

Prerequisites

  • Access to an evroc organization and project
  • evroc CLI installed and configured

Create a boot disk

A boot disk contains an operating system image that a virtual machine boots from. You must specify a disk image when creating a boot disk. See Available disk images for the list of supported images and their CLI names.

evroc compute disk create mybootdisk \
  --zone=a \
  --image=ubuntu.24-04.1 \
  --storage-class=persistent

See Create a Disk in the API reference.

Create a data disk

Data disks provide additional persistent storage for virtual machines. Data disks don't require a disk image, but you must specify the disk size.

evroc compute disk create mydisk \
  --zone=a \
  --storage-class=persistent \
  --size-amount=5 \
  --size-unit=GB

Attach a disk to an existing VM

You can attach data disks to an existing virtual machine. The VM must be stopped before attaching or detaching disks.

Important: The disk and VM must be in the same zone.

Add a disk to an existing VM:

evroc compute virtualmachine update myvm --append --disk=mydisk

Stop the VM to apply the changes:

evroc compute virtualmachine update myvm --running=false

Wait for the VM to stop, then start it again:

evroc compute virtualmachine update myvm --running=true

Detach a disk from a VM

You can detach data disks from a virtual machine. The VM must be stopped before detaching disks.

Important: Before detaching a disk, remove its entry from /etc/fstab on the VM to prevent boot errors.

To detach a disk, update the VM with a complete list of disks that excludes the disk you want to detach. For example, if your VM has disks mybootdisk, disk1, and disk2, and you want to detach disk2:

  1. Remove the disk entry from /etc/fstab on the VM

  2. Stop the VM:

    evroc compute virtualmachine update myvm --running=false
    
  3. Update the VM with only the disks you want to keep:

    evroc compute virtualmachine update myvm --disk=mybootdisk --boot-from=true --disk=disk1 --boot-from=false
    
  4. Start the VM:

    evroc compute virtualmachine update myvm --running=true
    

List disks

List all disks in your project:

evroc compute disk list

Use evroc compute disk get <name> for detailed information about a specific disk.

See List Disks in the API reference.

Delete a disk

Delete disks you no longer need. A disk must not be attached to any virtual machine before you can delete it.

evroc compute disk delete mydisk

See Delete a Disk in the API reference.

Next steps