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
Section titled “Prerequisites”- Access to an evroc organization and project
- evroc CLI installed and configured
Create a boot disk
Section titled “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. Run evroc compute diskimage list to see available images, or see Available disk images for a quick reference.
evroc compute disk create mybootdisk \ --zone=a \ --image=ubuntu.24-04.1You can also create a boot disk from:
- A snapshot. This is useful for restoring a VM from a previous state or creating multiple VMs with the same base configuration.
- A custom disk image. This is useful when using a boot image outside the set provided by evroc
See Create a Disk in the API reference.
Create a data disk
Section titled “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 \ --size-amount=5 \ --size-unit=GBAttach a disk to an existing VM
Section titled “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=mydiskStop the VM to apply the changes:
evroc compute virtualmachine update myvm --running=falseWait for the VM to stop, then start it again:
evroc compute virtualmachine update myvm --running=trueDetach a disk from a VM
Section titled “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/fstabon 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:
-
Remove the disk entry from
/etc/fstabon the VM -
Stop the VM:
Terminal window evroc compute virtualmachine update myvm --running=false -
Update the VM with only the disks you want to keep:
Terminal window evroc compute virtualmachine update myvm --disk=mybootdisk --boot-from=true --disk=disk1 --boot-from=false -
Start the VM:
Terminal window evroc compute virtualmachine update myvm --running=true
List disks
Section titled “List disks”List all disks in your project:
evroc compute disk listUse evroc compute disk get <name> for detailed information about a specific disk.
See List Disks in the API reference.
Delete a disk
Section titled “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 mydiskSee Delete a Disk in the API reference.
Next steps
Section titled “Next steps”- Learn how to create and use snapshots to back up and restore disks
- Learn how to create and use custom disk images to create disks from custom boot images
- Learn how to restore a VM from a snapshot
- Learn how to format and mount data disks on your virtual machines
- Learn how to attach disks to running VMs without stopping them