Initialize a volume from a VM
After attaching a volume to a VM (Virtual Machine), you must initialize it to make it usable.
- Linux
- Windows
Create the volume file system (new empty volume only)
-
Connect to your VM.
-
(optional) To obtain the device name of the volume you want to mount, run the following command to display the list of devices attached to the VM:
$ lsblkwarningInside the VM, a device that you named xvdX or xvdXX in your account is typically renamed sdY or sdYY.
-
(optional) To check that the volume is empty, run the following command:
$ sudo file -s /dev/DEVICE_NAMEIf the command returns only data, the volume has no file system and you must create one.
If the command returns anything else, the volume already has a file system.
-
To create and format an xfs file system on the whole volume, run the following command:
sudo mkfs -t xfs /dev/DEVICE_NAMEwarningWe recommend that you do not partition volumes or use LVM on the Numspot cloud, as these practices can degrade volume performance. It is preferable to use volumes directly as they are.
Mount the volume
- To create a directory that will serve as the mount point for the volume, run the following command:
$ sudo mkdir /MOUNT_POINT
- To mount the volume on the mount point, run the following command:
$ sudo mount /dev/DEVICE_NAME /MOUNT_POINTThe volume is initialized from your VM and ready to be used.info
To confirm that the mount was successful, you can run the df -hT command to display the list of all volumes mounted on the VM.
Make the mount permanent
For the volume mount to persist across reboots, you must edit the /etc/fstab file, which configures and mounts the VM volumes. To avoid any potential loss of access to your data, we recommend that you create a backup of this file before editing it, using the following command:
$ sudo cp /etc/fstab /etc/fstab.orig
-
Open the /etc/fstab file using the following command:
$ sudo vim /etc/fstab -
Press i to enable insert mode, then add the following line at the end of the file:
/dev/DEVICE_NAME /MOUNT_POINT xfs defaults,nofail 0 2To learn more about the possible configuration options, see for example the fstab page in the Ubuntu documentation.
-
Press Esc, then type :wq to save the file.
-
(optional) To check the validity of the file, run the following command to reload it:
$ sudo mount -aIf the command returns an error message, the options contained in the file are not valid. You must then restore the original file and reconfigure it.
infoTo restore the original /etc/fstab file, run the following command:
$ sudo mv /etc/fstab.orig /etc/fstab
- Connect to your VM.
- Click the Start menu, type "diskmgmt.msc" and click the program that appears.
- In the bottom left-hand panel, right-click the disk corresponding to the volume you want to mount, then click "Online".
- (new empty disk only) If you are mounting the disk for the first time, perform the following actions:
-
right-click the disk, then click "Initialize Disk";
-
click OK to confirm;
-
right-click the unallocated space of the disk, then click "New Simple Volume…" and follow the on-screen instructions.
The volume is initialized and ready to be used.