In this article, you will learn how to use Compute disks and shared filesystems on virtual machines (VMs).
This article only covers additional volumes: non-boot disks and shared filesystems. You add a boot disk when you create a VM.
After creating a disk or a shared filesystem, you need to do the following to use it on a VM:
- Attach it to the VM by using Nebius AI Cloud interfaces.
- Mount it to the VM inside the VM’s operating system.
A VM and its volumes must be located in the same project. For more details about projects and resource hierarchy in Nebius AI Cloud, see How resources, identities and access are managed in Nebius AI Cloud.
Prerequisites
CLI
Go SDK
Python SDK
JavaScript SDK
How to attach volumes to VMs
To attach disks or shared filesystems to a VM:
Web console
CLI
Go SDK
Python SDK
JavaScript SDK
-
New VM
In the VM creation wizard (
Compute → Virtual machines → Create resource → Virtual machine), on the Storage step, do the following:
-
Click Attach disk or Attach shared filesystem.
-
Set up the volume:
-
Select whether you want to add a new or existing volume.
If an existing disk is already added to another VM, you cannot add it to the new VM. A filesystem can be shared by multiple VMs.
-
For a new volume, set its parameters.
-
Set a device ID if you are adding a disk, or a mount tag if you are attaching a filesystem. Device IDs and mount tags are used to mount volumes to VMs.
-
Click the attach-volume button at the end of the window.
When you click Create and add disk or Create and attach filesystem, the disk or filesystem is created immediately and charged separately even if you remove it from the VM later or do not proceed with creating the VM.
-
If you want to manually mount the filesystem that you added to the VM, turn off the Auto mount option for the filesystem.
By default, Compute automatically mounts filesystems that you add to VMs via the web console.
If you add a disk, you always need to mount it manually.
-
Existing VM
Disks
-
In the sidebar, go to
Compute → Virtual machines.
-
On the Standalone VMs tab, open the page of the required VM.
-
Switch to the Disks tab.
-
Click Attach resource → Disk.
-
Select whether you want to attach a new or existing disk.
If an existing disk is already attached to another VM, you cannot attach it to a new VM until you detach it from the current VM.
-
For a new disk, set its parameters.
-
Set a device ID for the disk. Device IDs are used to mount disks to VMs.
-
Click the attach-volume button at the end of the window.
Shared filesystems
-
In the sidebar, go to
Compute → Virtual machines.
-
On the Standalone VMs tab, open the page of the required VM.
-
If the VM is not in the
Stopped status, click Stop VM and then confirm the action.
-
After the VM has the
Stopped status, switch to the Filesystems tab.
-
Click Attach resource → Filesystem.
-
Select whether you want to attach a new or existing filesystem.
A filesystem can be shared by multiple VMs.
-
For a new filesystem, set its parameters.
-
Set a mount tag for the filesystem. Mount tags are used to mount filesystems to VMs.
-
Click the attach-volume button at the end of the window.
-
Create the volumes.
-
Create the following files locally:
-
secondary_disk.json to attach disks:
Where:
-
Write permission,
READ_WRITE (default) or READ_ONLY.
-
existing_disk.id: Disk ID to be added. To get the ID, run nebius compute disk list.
-
device_id: Disk device ID. This parameter is different from existing_disk.id, as device_id is used for mounting a disk to a VM.
Create your own device ID, such as my-disk. Make sure that it is unique within a VM.
If you do not specify the device ID, it takes the disk-N default value where N is an integer. For example, disk-0.
-
filesystem.json to attach shared filesystems:
Where:
-
Write permission,
READ_WRITE (default) or READ_ONLY.
-
existing_filesystem.id: Filesystem ID to be attached. To get the ID, run nebius compute filesystem list.
-
mount_tag: Tag for mounting a filesystem to a VM.
Create your own tag, such as my-filesystem. Make sure that it is unique within a VM.
If you do not specify the tag, it takes the filesystem-N default value where N is an integer. For example, filesystem-0.
-
Create or update a VM with the volumes configured:
-
To create a VM, run the following command:
-
To attach disks to an existing VM, run the following command:
To get the ID of an existing VM, run
nebius compute instance list.
The --patch parameter allows you to only update the specified parameters. Without it, the command resets the VM settings to their default values.
-
To attach shared filesystems to an existing VM, stop the VM first:
Then update the VM:
After the update, start the VM:
-
Create the volumes.
-
Set the attachment parameters in the code examples:
In the code examples, set the attachment parameters:
- For disks, set the attach mode, existing disk ID and device ID.
- For shared filesystems, set the attach mode, existing filesystem ID and mount tag.
Create your own mount tag, such as my-filesystem. Make sure that it is unique within a VM. If you do not specify the tag, it takes the filesystem-N default value where N is an integer. For example, filesystem-0.
-
Create or update a VM with the volumes configured:
-
To create a VM, use the following code:
-
To attach disks to an existing VM, use the following code:
To get the ID of an existing VM:
When updating an existing VM, preserve the disks or shared filesystems that must stay attached. The examples replace the corresponding attachment list in the VM specification.
-
To attach shared filesystems to an existing VM, stop the VM first:
Then update the VM:
When updating an existing VM, preserve the disks or shared filesystems that must stay attached. The examples replace the corresponding attachment list in the VM specification.
After the update, start the VM:
-
Create the volumes.
-
Set the attachment parameters in the code examples:
In the code examples, set the attachment parameters:
- For disks, set the attach mode, existing disk ID and device ID.
- For shared filesystems, set the attach mode, existing filesystem ID and mount tag.
Create your own mount tag, such as my-filesystem. Make sure that it is unique within a VM. If you do not specify the tag, it takes the filesystem-N default value where N is an integer. For example, filesystem-0.
-
Create or update a VM with the volumes configured:
-
To create a VM, use the following code:
-
To attach disks to an existing VM, use the following code:
To get the ID of an existing VM:
When updating an existing VM, preserve the disks or shared filesystems that must stay attached. The examples replace the corresponding attachment list in the VM specification.
-
To attach shared filesystems to an existing VM, stop the VM first:
Then update the VM:
When updating an existing VM, preserve the disks or shared filesystems that must stay attached. The examples replace the corresponding attachment list in the VM specification.
After the update, start the VM:
-
Create the volumes.
-
Set the attachment parameters in the code examples:
In the code examples, set the attachment parameters:
- For disks, set the attach mode, existing disk ID and device ID.
- For shared filesystems, set the attach mode, existing filesystem ID and mount tag.
Create your own mount tag, such as my-filesystem. Make sure that it is unique within a VM. If you do not specify the tag, it takes the filesystem-N default value where N is an integer. For example, filesystem-0.
-
Create or update a VM with the volumes configured:
-
To create a VM, use the following code:
-
To attach disks to an existing VM, use the following code:
To get the ID of an existing VM:
When updating an existing VM, preserve the disks or shared filesystems that must stay attached. The examples replace the corresponding attachment list in the VM specification.
-
To attach shared filesystems to an existing VM, stop the VM first:
Then update the VM:
When updating an existing VM, preserve the disks or shared filesystems that must stay attached. The examples replace the corresponding attachment list in the VM specification.
After the update, start the VM:
You can also attach a VM-managed boot disk to another VM, so you can investigate and troubleshoot this boot disk. For more information, see How to inspect a VM and attach its boot disk to another VM.
How to mount volumes to VMs
Disks
-
Attach the disk to a VM.
-
If you have not saved the disk’s device ID, for example, when adding it to the VM, get it from the information about the VM:
CLI
Go SDK
Python SDK
JavaScript SDK
To get the VM ID, run nebius compute instance list. To get the disk ID, run nebius compute disk list. To get the VM ID, run:For the disk ID, use the ID of the disk that you attached. To get the VM ID, run:For the disk ID, use the ID of the disk that you attached. To get the VM ID, run:For the disk ID, use the ID of the disk that you attached.
-
Connect to the VM over SSH.
-
Switch to the
root user:
-
Partition the device. For example, you can use
cfdisk. In the example below, we assume that you have named the device disk-0; for disks, all device IDs are prefixed with virtio-:
-
Run
cfdisk:
Referring to a device by its name, e.g., /dev/vdb, does not guarantee it will function properly. Use the device ID instead, e.g., /dev/disk/by-id/virtio-disk-0.
-
Under Select label type, select gpt and press Enter.
-
Select New (partition) and press Enter.
-
Enter the partition size and press Enter. This will create a
/dev/disk/by-id/virtio-disk-0-part1 partition.
-
Select Write (the partition table to the device) and press Enter, then type
yes and press Enter.
-
Select Quit and press Enter.
-
Format the partition:
-
Mount the partition and configure permissions for it by using
chmod. In the example below, the partition is mounted at /mnt/disk-0, and all VM users are granted write access to it:
-
If you want the partition to be mounted automatically after every VM restart, add it to
/etc/fstab by its UUID:
Do not omit nofail. If it is not specified and the VM cannot find the partition on restart (for example, the disk has been repartitioned), the VM will not boot.
-
Exit the
root user shell:
Shared filesystems
If you create a VM in the web console, you can automatically attach and mount a shared filesystem to the VM by using the Auto mount option. If you do not use it, mount the filesystem manually. To do this:
-
Attach the shared filesystem to a VM.
-
If you have not saved the filesystem’s mount tag, for example, when adding it to the VM, get the mount tag from the information about the VM:
CLI
Go SDK
Python SDK
JavaScript SDK
To get the VM ID, run nebius compute instance list. To get the filesystem ID, run nebius compute filesystem list. To get the VM ID, run:For the filesystem ID, use the ID of the filesystem that you attached. To get the VM ID, run:For the filesystem ID, use the ID of the filesystem that you attached. To get the VM ID, run:For the filesystem ID, use the ID of the filesystem that you attached.
-
Connect to the VM over SSH.
-
Switch to the
root user:
-
Mount the filesystem as a
virtiofs device and configure permissions for it by using chmod. In the example below, a filesystem has the mount tag filesystem-0 and is mounted at /mnt/fs. All VM users are granted write access to it:
-
If you want the filesystem to be mounted automatically after every VM restart, add it to
/etc/fstab:
Do not omit nofail. If it is not specified and the VM cannot find the filesystem on restart (for example, it has been deleted), the VM will not boot.
-
Exit the
root user shell:
See also