Learn how to create an additional disk 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 as well as your data to another instance.
Requirements
- access to the OVHcloud Control Panel
- a Public Cloud Instance in your OVHcloud account
- administrative (root) access to your instance via SSH (Linux) or RDP (Windows)
Topics
- Adding an additional disk
- Attaching an additional disk to an instance
- Configuring an additional disk on Linux
- Configuring an additional disk on Windows
- Detaching an additional disk on Linux
- Detaching an additional disk on Windows
Instructions
Adding an additional disk
From the OVHcloud Control Panel:
- Click
Public Cloud
from the top menu bar. - Navigate to your project.
- Under Storage click
Block Storage
. - Toward the center of the screen, click
Create a volume
.
On the following screen, select the location, volume type, volume capacity, and volume name. When finished, click Create the volume
.
Congratulations! You have an additional disk that is not attached to any instance.
Attaching an additional disk to an instance
To attach your new hard disk to an instance, click the more options ...
button next to your hard disk and select Attach
to instance
.
This will generate a pop-up menu. Choose the instance to which you wish to attach the hard drive and click Confirm
.
The process of attaching the disk to your instance will now begin. This may take a few minutes to complete.
Congratulations! You have successfully added a hard drive to an instance.
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.
~$ admin@server-1:~$ lsblk 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
sda
in this example refers to the default disk of the instance. The additional disk will then be labeled sdb
.Create a partition on the additional disk using the commands below.
~$ admin@server-1:~$ sudo fdisk /dev/sdb Welcome to fdisk (util-linux 2.38.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS (MBR) disklabel with disk identifier 0x7c8fd5e2.
Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): Created a new partition 1 of type 'Linux' and of size 10 GiB.
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Next, format the new partition sdb1
using the command below.
~$ admin@server-1:~$ sudo mkfs.ext4 /dev/sdb1 mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done Creating filesystem with 2621184 4k blocks and 655360 inodes Filesystem UUID: 9ae75b41-235d-49d3-a2e2-d9bd63d9ff1c Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
Mount the partition with the following commands:
admin@server-1:~$ sudo mkdir /mnt/disk admin@server-1:~$ sudo mount /dev/sdb1 /mnt/disk/
Finally, check the mount point using this command:
~$ admin@server-1:~$ df -h Filesystem Size Used Avail Use% Mounted on
/dev/sda1 49G 4.2G 45G 9% /
/dev/sdb1 9.8G 2.1M 9.3G 1% /mnt/disk
fstab
file needs to be edited.First, retrieve the UUID (block ID) of the new volume:
~$ admin@server-1:~$ sudo blkid
/dev/sda1: UUID="e32348de-db87-45b8-9e2e-524b1f92fa5d"
/dev/sdb1: UUID="9ae75b41-235d-49d3-a2e2-d9bd63d9ff1c"
Open /etc/fstab
with a text editor:
~$ sudo nano /etc/fstab
Add the line below to the file and replace the UUID with your own:
UUID=9ae75b41-235d-49d3-a2e2-d9bd63d9ff1c /mnt/disk ext4 nofail 0 0
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
.
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:
C:\> diskpart
Use the following series of DISKPART commands to set the disk to online
:
DISKPART> san SAN Policy : Offline Shared
DISKPART> san policy = OnlineAll DiskPart successfully changed the SAN policy for the current operating system . - Implementation of the strategy on the extra disk: [Code] DISKPART> list disk Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 200 GB 0 B * Disk 1 Offline 10 GB 1024 KB
DISKPART> select disk 1 Disk 1 is now the selected disk.
DISKPART> attributes disk clear readonly Disk attributes cleared successfully.
DISKPART> attributes disk Current Read-only State : No Read-only : No Boot Disk : No Pagefile Disk : No Hibernation File Disk : No Crashdump Disk : No Clustered Disk : No
DISKPART> online disk DiskPart successfully onlined the selected disk.
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.
On Linux
Establish an SSH connection to your instance, then use the command below to list the attached disks.
~$ admin@server-1:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 254:0 0 10G 0 disk └─sda1 254:1 0 10G 0 part / sdb 8:0 0 10G 0 disk └─sdb1 8:1 0 10G 0 part /mnt/disk
Unmount the partition using the command below:
~$ admin@server-1:~$ sudo umount /dev/sdb1
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.
~$ admin@server-1:~$ sudo nano /etc/fstab
Save and exit the editor.
Go to the Public Cloud
section of your OVHcloud Control Panel and, in the left-hand menu under Storage, click on Block Storage
.
Click on the more options ...
button next to the corresponding volume and select Detach from instance
.
Click on Confirm
in the pop-up window to start the process.
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.
Go to the Public Cloud
section of your OVHcloud Control Panel and, in the left-hand menu under Storage, click on Block Storage
.
Click on the more options ...
button next to the corresponding volume and select Detach from instance
.
Click on Confirm
in the pop-up window to start the process.
Go further
For more information and tutorials, please see our other Public Cloud Storage support guides or explore the guides for other OVHcloud products and services.