Attaching file storage to a VM
Written by
-
If a virtual machine has been launched and is running (the
RUNNING
status), stop it. -
Attach file storage to the VM in Compute Cloud:
Management consoleAPI-
In the management console, select the folder where you created the file store.
-
Select Compute Cloud.
-
On the left-hand panel, select File storage.
-
Select the desired storage.
-
Go to the Virtual machines tab.
-
Click Attach to VM.
-
In the window that opens:
- Select the VM.
- Specify the Device name for accessing file storage in the VM.
- Click Attach to VM.
Use the InstanceService/AttachFilesystem gRPC API method or the attachFilesystem method of the REST API Instance resource.
-
-
Mount file storage to the VM:
-
Run the command:
sudo mount -t virtiofs <device name> <mount path>
-
To check that your file store is mounted, run the command:
df -T
Result:
Filesystem Type 1K-blocks Used Available Use% Mounted on udev devtmpfs 988600 0 988600 0% /dev tmpfs tmpfs 203524 780 202744 1% /run /dev/vda2 ext4 13354932 1909060 10861420 15% / tmpfs tmpfs 1017604 0 1017604 0% /dev/shm tmpfs tmpfs 5120 0 5120 0% /run/lock tmpfs tmpfs 1017604 0 1017604 0% /sys/fs/cgroup tmpfs tmpfs 203520 0 203520 0% /run/user/1000 filesystem virtiofs 66774660 0 66774660 0% /mnt/vfs0
-
In order for file storage to be mounted every time the VM is started, add a line to the
/etc/fstab
file in the following format:<device name> <mount path> virtiofs rw 0 0