Learn how to add a block storage volume to your public cloud project and configure it on your instance.
It is possible to create additional disks for your Public Cloud instances. This can be useful in cases where:
- You want to increase your storage capacity without changing the instance model.
- You want to have highly available, high-performance storage.
- You want to move your storage and data to another instance.
- You want to prepare the environment if you want to use Terraform.
Requirements
- Access to the OVHcloud Control Panel
- A Public Cloud instance in your account
- Administrative (sudo) access to your instance via SSH (Linux) or RDP (Windows)
Instructions
The different types of volumes
OVHcloud offers three types of Block Storage volumes, each tailored to specific needs in terms of performance, capacity, and cost. These solutions enable you to attach persistent storage volumes to your instances, guaranteeing a high-level of reliability and availability.
More information about the types of volumes is available on our website.
Adding a new volume
Via the OVHcloud Control Panel
From the OVHcloud Control Panel:, navigate to the Block Storage
section via the Public Cloud
menu.
Click Create a volume
.
Select the location for your block storage volume and click Next
. For more information about Local Zones, see this guide.
NOTE: Your volume must be created in the same region as the instance to which you wish to attach it. If you create it in another region, you can delete it and recreate it in the correct region, or you can migrate the region by following this guide.
Choose your volume type and click Next
. More information about the types of volumes is available on our website.
From here, complete your volume's configuration by selecting the Volume capacity and Volume name, and then clicking Create the volume
.
Once your new disk is available, click the more options ...
button to the right of the disk and select Attach to instance
.
In the pop-up window, choose an available instance and click Confirm
. If no instances are available it is because you do now have an instance in a region matching that of the additional disk.
The process may take a few minutes to complete.
NOTE: Navigating away from the page during creation may interrupt the process.
Via Terraform
To create a simple block storage volume, you need three elements:
- The name of the volume
- The region
- The size of the volume in GB
In our example, we will create a block storage in the US-EAST-VA region with a size of 10 GB. Add the following lines to a file named simple_blockstorage.tf:
Then we will attach it to the target instance.
The instance and the volume must be in the same region.
Add the following lines below the previous ones:
You can create your block storage volume and attach it to the desired instance by entering the following command:
The output should look like this:
Configuring the new disk
The examples below presume you are logged in as a user with elevated permissions.
Using Linux
Establish an SSH connection to your instance, then use the command below to list the attached disks.
sda
in this example refers to the default disk of the instance. The additional disk will then be labeled sdb
.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 50G 0 disk
└─sda1 8:1 0 49.9G 0 part /
sdb 8:16 0 10G 0 disk
Create a partition on the additional disk using the commands below.
If your additional disk is less than 2TB:
If your additional disk is larger than 2TB:
Next, format the new partition sdb1
using the command below.
Mount the partition with the following commands:
Finally, check the mount point using this command:
The mounting is not persistent because the disk will be detached when the instance reboots. To automate the mounting process, the fstab
file needs to be edited.
First, retrieve the UUID (block ID) of the new volume:
Open /etc/fstab
with a text editor:
Add the line below to the file and replace the UUID with your own:
Save and exit the editor. The disk should be automatically mounted after every reboot from now on.
Using Windows
Establish a remote desktop (RDP) connection to your Windows instance.
Once logged in, right-click on the Start Menu
button and open Disk Management
.
The new disk will be displayed as an unknown volume with unallocated space.
If the disk is marked as offline here, it needs to be initialized first. You can use the Windows GUI or the DISKPART utility to achieve this. Otherwise, proceed with formatting the disk in Disk Management.
Initializing the disk in Disk Management
Right-click on the disk and select Online
.
If the disk is marked as offline here, this is likely due to a policy in place on the instance. To fix this, right-click on the disk and select Online
.
Then right-click it again and this time select Initialize Disk
.
Next, select MBR (Master Boot Record)
and click OK
.
[primary]If your disk is more than 2TB, select GPT (GUID Partition Table).
Initializing the disk with DISKPART
Right-click on the Start Menu
button and open Run
.
Type cmd
and click OK
to open the command line application.
At the command prompt, open DISKPART:
Use the following series of DISKPART commands to set the disk to online
:
Formatting the disk
In Disk Management
, right-click on the new disk and select New Simple Volume...
.
In the wizard, click Next
to specify the volume size. It should be set to maximum by default. Click Next
to continue.
Leave the new drive letter at default or select a different one, then click Next
.
Label the volume (optional) and confirm the formatting options by clicking Next
.
In the last window, click Finish
to format the disk.
The disk will be available as a drive in File Explorer after the operation.
Detach a volume
If you wish to detach a volume from your instance, the best practice is to unmount the volume in the operating system before detaching it from the instance.
NOTE: An error message may appear if you have software or processes running on the additional disk. In this case, it is recommended to stop all processes before continuing.
Here is how to unmount the volume from the operating system before detaching it from the instance:
On Linux
Establish an SSH connection to your instance, then use the command below to list the attached disks.
Unmount the partition using the command below:
Remove the device ID from the fstab to complete the unmount process, if this is not done, the partition will be mounted right back after a reboot.
Save and exit the editor.
On Windows
Establish a remote desktop (RDP) connection to your Windows instance.
Once logged in, right-click on the Start Menu
button and open Disk Management
.
Right-click on the volume you wish to unmount and select Change Drive Letter and Paths...
.
Click on Remove
to remove the drive.
Next, click on Yes
to confirm the disk removal.
When finished, you can close the Disk Management window.
Finally, we will detach the volume from the instance:
Via OVHcloud Control Panel
Go to the Public Cloud
section of your OVHcloud Control Panel and click on Block Storage
in the left-hand menu under Storage.
Click the ...
button next to the corresponding volume and select Detach from instance
.
NOTE: You can also cancel your Block Storage volume using this menu.
Click Confirm
in the pop-up window to start the process.
Via Terraform
Start by deleting the lines previously created in your Terraform file:
Enter the following command to check whether the correct resource will be deleted:
The output should look like this:
Then apply the changes by entering this command:
The output should look like this:
Go further
For more information and tutorials, please see our other Public Cloud support guides or explore the guides for other OVHcloud products and services.