Skip to content

Commit 7d4ae16

Browse files
authored
Merge pull request #7345 from ovh/feat-tf-additional-disk
Feat(additional disk): add TF example + update guide presentation
2 parents 5f7b40d + 7f9ad1d commit 7d4ae16

File tree

9 files changed

+2628
-727
lines changed

9 files changed

+2628
-727
lines changed

pages/public_cloud/compute/create_and_configure_an_additional_disk_on_an_instance/guide.en-asia.md

+293-75
Large diffs are not rendered by default.

pages/public_cloud/compute/create_and_configure_an_additional_disk_on_an_instance/guide.en-au.md

+293-75
Large diffs are not rendered by default.

pages/public_cloud/compute/create_and_configure_an_additional_disk_on_an_instance/guide.en-ca.md

+293-75
Large diffs are not rendered by default.

pages/public_cloud/compute/create_and_configure_an_additional_disk_on_an_instance/guide.en-gb.md

+291-73
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
---
22
title: Creating and configuring an additional disk on an instance
33
excerpt: Find out how to attach a new volume to your Public Cloud instance
4-
updated: 2023-10-16
4+
updated: 2024-12-24
55
---
66

7+
<style>
8+
details>summary {
9+
color:rgb(33, 153, 232) !important;
10+
cursor: pointer;
11+
}
12+
details>summary::before {
13+
content:'\25B6';
14+
padding-right:1ch;
15+
}
16+
details[open]>summary::before {
17+
content:'\25BC';
18+
}
19+
</style>
20+
721
## Objective
822

923
It is possible to create additional disks for your Public Cloud instances.
@@ -12,13 +26,14 @@ This can be useful in cases where:
1226
- You want to increase your storage capacity without changing the instance model.
1327
- You want to have a highly available, high-performance storage.
1428
- You want to move your storage as well as your data to another instance.
29+
- You want to prepare the environment if you want to use [Terraform](/pages/public_cloud/compute/how_to_use_terraform).
1530

1631
**This guide explains how to create an additional disk and configure it on your instance.**
1732

1833
## Requirements
1934

2035
- Access to the [OVHcloud Control Panel](/links/manager)
21-
- A [Public Cloud Instance](https://www.ovhcloud.com/en-gb/public-cloud/) in your OVHcloud account
36+
- A [Public Cloud Instance](/pages/public_cloud/compute/public-cloud-first-steps) in your OVHcloud account
2237
- Administrative (sudo) access to your instance via SSH (Linux) or RDP (Windows)
2338

2439
> [!warning]
@@ -30,6 +45,126 @@ This can be useful in cases where:
3045

3146
### Attaching a new volume
3247

48+
> [!tabs]
49+
> **Via the OVHcloud Control Panel**
50+
>>
51+
>> Log in to the [OVHcloud Control Panel](/links/manager) and open your `Public Cloud`{.action} project. Then open `Block Storage`{.action} in the left-hand menu.
52+
>>
53+
>> In this section, click on the button `Create a volume`{.action}.
54+
>>
55+
>> ![select project](images/avolume01.png){.thumbnail}
56+
>>
57+
>> Follow the configuration steps in order to select options for location, disk type and disk capacity. Then enter a name for the volume and confirm by clicking on `Create the volume`{.action}.
58+
>>
59+
>> ![create disk](images/avolume02.png){.thumbnail}
60+
>>
61+
>> The new disk will now be displayed in the Control Panel.
62+
>>
63+
>> ![configure disk](images/avolume03.png){.thumbnail}
64+
>>
65+
>> To the right of the volume, click on the `...`{.action} button, then select `Attach to instance`{.action}.
66+
>>
67+
>> ![attach disk 01](images/avolume04.png){.thumbnail}
68+
>>
69+
>> In the popup window, choose an instance from the list and click on `Confirm`{.action} to attach the disk.
70+
>>
71+
>> ![attach disk 02](images/avolume05.png){.thumbnail}
72+
>>
73+
>> The process of attaching the disk to your instance will now begin. This may take a few minutes to complete.
74+
>>
75+
>> > [!warning]
76+
>> > Make sure to not leave the current page in your OVHcloud Control Panel while the disk is being attached. This might interrupt the process.
77+
>> >
78+
>>
79+
> **Via Terraform**
80+
>>
81+
>> To create a simple block storage volume, you need 3 elements:
82+
>>
83+
>> * The name of the volume
84+
>> * The region
85+
>> * The size of the volume in GB
86+
>>
87+
>> In our example, we will create a block storage in the **GRA11** region with a size of **10 GB**. Add the following lines to a file named *simple_blockstorage.tf*:
88+
>>
89+
>> ```python
90+
>> # Creation of a block storage volume
91+
>> resource "openstack_blockstorage_volume_v3" "terraform_blockstorage" {
92+
>> name = "terraform_blockstorage" # Name of the block storage volume
93+
>> size = 10 # Volume size
94+
>> region = "GRA11" # Region where the volume must be created
95+
>> }
96+
>> ```
97+
>>
98+
>> Then we will attach it to the target instance.
99+
>>
100+
>> > [!warning]
101+
>> > The instance and the volume must be in the same region.
102+
>> >
103+
>>
104+
>> Add the following lines below the previous ones:
105+
>>
106+
>> ```python
107+
>> # Attach the volume to the instance
108+
>> resource "openstack_compute_volume_attach_v2" "volume_attach" {
109+
>> instance_id = "<your_instance_id>"
110+
>> volume_id = openstack_blockstorage_volume_v3.terraform_volume.id
111+
>> }
112+
>> ```
113+
>>
114+
>> You can create your block storage volume and attach it to the desired instance by entering the following command:
115+
>>
116+
>> ```console
117+
>> terraform apply
118+
>> ```
119+
>>
120+
>> The output should look like this:
121+
>>
122+
>> ```console
123+
>> $ terraform apply
124+
>> Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
125+
>> + create
126+
>>
127+
>> Terraform will perform the following actions:
128+
>>
129+
>> # openstack_blockstorage_volume_v3.terraform_blockstorage will be created
130+
>> + resource "openstack_blockstorage_volume_v3" "terraform_blockstorage" {
131+
>> + attachment = (known after apply)
132+
>> + availability_zone = (known after apply)
133+
>> + id = (known after apply)
134+
>> + metadata = (known after apply)
135+
>> + name = "terraform_blockstorage"
136+
>> + region = "GRA11"
137+
>> + size = 10
138+
>> + volume_type = (known after apply)
139+
>> }
140+
>>
141+
>> # openstack_compute_volume_attach_v2.volume_attach will be created
142+
>> + resource "openstack_compute_volume_attach_v2" "volume_attach" {
143+
>> + device = (known after apply)
144+
>> + id = (known after apply)
145+
>> + instance_id = "11cc1279-xxxx-xxxx-xxxx-3ace4c954780"
146+
>> + region = (known after apply)
147+
>> + volume_id = (known after apply)
148+
>> }
149+
>>
150+
>> Plan: 2 to add, 0 to change, 0 to destroy.
151+
>>
152+
>> Do you want to perform these actions in workspace "test_terraform"?
153+
>> Terraform will perform the actions described above.
154+
>> Only 'yes' will be accepted to approve.
155+
>>
156+
>> Enter a value: yes
157+
>>
158+
>> openstack_blockstorage_volume_v3.terraform_blockstorage: Creating...
159+
>> openstack_blockstorage_volume_v3.terraform_blockstorage: Still creating... [10s elapsed]
160+
>> openstack_blockstorage_volume_v3.terraform_blockstorage: Creation complete after 12s [id=daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
161+
>> openstack_compute_volume_attach_v2.volume_attach: Creating...
162+
>> openstack_compute_volume_attach_v2.volume_attach: Still creating... [10s elapsed]
163+
>> openstack_compute_volume_attach_v2.volume_attach: Creation complete after 14s [id=11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
164+
>>
165+
>> Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
166+
>> ```
167+
33168
Log in to the [OVHcloud Control Panel](/links/manager) and open your `Public Cloud`{.action} project. Then open `Block Storage`{.action} in the left-hand menu.
34169
35170
In this section, click on the button `Create a volume`{.action}.
@@ -351,77 +486,160 @@ If you wish to detach a volume from your instance, the best practice is to unmou
351486
> 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.
352487
>
353488
354-
#### On Linux
355-
356-
Establish an [SSH connection to your instance](/pages/public_cloud/compute/public-cloud-first-steps#connect-instance), then use the command below to list the attached disks.
357-
358-
```bash
359-
lsblk
360-
```
361-
362-
```console
363-
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
364-
vda 254:0 0 10G 0 disk
365-
└─vda1 254:1 0 10G 0 part /
366-
vdb 8:0 0 10G 0 disk
367-
└─vdb1 8:1 0 10G 0 part /mnt/disk
368-
```
369-
370-
Unmount the partition using the command below:
371-
372-
```bash
373-
sudo umount /dev/vdb1
374-
```
375-
376-
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.
377-
378-
```bash
379-
sudo nano /etc/fstab
380-
```
381-
382-
Save and exit the editor.
383-
384-
Go to the `Public Cloud`{.action} section of your OVHcloud Control Panel and click on `Block Storage`{.action} in the left-hand menu under **Storage**.
385-
386-
Click on the `...`{.action} next to the corresponding volume and select `Detach from instance`{.action}.
387-
388-
![detach disk](images/detachinstance.png){.thumbnail}
389-
390-
Click on `Confirm`{.action} in the pop up window to start the process.
391-
392-
![confirm disk detach](images/confirminstancedetach.png){.thumbnail}
393-
394-
#### On Windows
395-
396-
Establish a remote desktop (RDP) connection to your Windows instance.
397-
398-
Once logged in, right-click on the `Start Menu`{.action} button and open `Disk Management`{.action}.
399-
400-
![disk management](images/start-menu.png){.thumbnail}
401-
402-
Right click on the volume you wish to unmount and select `Change Drive Letter and Paths...`{.action}.
403-
404-
![unmount disk](images/unmountdisk.png){.thumbnail}
405-
406-
Click on `Remove`{.action} to remove the drive.
407-
408-
![remove disk](images/changedriveletter.png){.thumbnail}
409-
410-
Next, click on `Yes`{.action} to confirm the disk removal.
411-
412-
![confirm remove disk](images/confirmunmounting.png){.thumbnail}
413-
414-
When finished, you can close the Disk Management window.
415-
416-
Go to the `Public Cloud`{.action} section of your OVHcloud Control Panel and click on `Block Storage`{.action} in the left-hand menu under **Storage**.
417-
418-
Click on the `...`{.action} next to the corresponding volume and select `Detach from instance`{.action}.
419-
420-
![detach disk](images/detachinstance.png){.thumbnail}
421-
422-
Click on `Confirm`{.action} in the pop up window to start the process.
423-
424-
![confirm disk detach](images/confirminstancedetach.png){.thumbnail}
489+
Here's how to **unmount the volume** from the operating system before detaching it from the instance :
490+
491+
> [!tabs]
492+
> **On Linux**
493+
>>
494+
>> Establish an [SSH connection to your instance](/pages/public_cloud/compute/public-cloud-first-steps#connect-instance), then use the command below to list the attached disks.
495+
>>
496+
>> ```bash
497+
>> lsblk
498+
>> ```
499+
>>
500+
>> ```console
501+
>> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
502+
>> vda 254:0 0 10G 0 disk
503+
>> └─vda1 254:1 0 10G 0 part /
504+
>> vdb 8:0 0 10G 0 disk
505+
>> └─vdb1 8:1 0 10G 0 part /mnt/disk
506+
>> ```
507+
>>
508+
>> Unmount the partition using the command below:
509+
>>
510+
>> ```bash
511+
>> sudo umount /dev/vdb1
512+
>> ```
513+
>>
514+
>> 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.
515+
>>
516+
>> ```bash
517+
>> sudo nano /etc/fstab
518+
>> ```
519+
>>
520+
>> Save and exit the editor.
521+
>>
522+
> **On Windows**
523+
>>
524+
>> Establish a remote desktop (RDP) connection to your Windows instance.
525+
>>
526+
>> Once logged in, right-click on the `Start Menu`{.action} button and open `Disk Management`{.action}.
527+
>>
528+
>> ![disk management](images/start-menu.png){.thumbnail}
529+
>>
530+
>> Right click on the volume you wish to unmount and select `Change Drive Letter and Paths...`{.action}.
531+
>>
532+
>> ![unmount disk](images/unmountdisk.png){.thumbnail}
533+
>>
534+
>> Click on `Remove`{.action} to remove the drive.
535+
>>
536+
>> ![remove disk](images/changedriveletter.png){.thumbnail}
537+
>>
538+
>> Next, click on `Yes`{.action} to confirm the disk removal.
539+
>>
540+
>> ![confirm remove disk](images/confirmunmounting.png){.thumbnail}
541+
>>
542+
>> When finished, you can close the Disk Management window.
543+
544+
Finally, we will detach the volume from the instance:
545+
546+
> [!tabs]
547+
> **Via the OVHcloud Control Panel**
548+
>>
549+
>> Go to the `Public Cloud`{.action} section of your OVHcloud Control Panel and click on `Block Storage`{.action} in the left-hand menu under **Storage**.
550+
>>
551+
>> Click the `...`{.action} button next to the corresponding volume and select `Detach from instance`{.action}.
552+
>>
553+
>> ![detach disk](images/detachinstance.png){.thumbnail}
554+
>>
555+
>> Click on `Confirm`{.action} in the pop up window to start the process.
556+
>>
557+
>> ![confirm disk detach](images/confirminstancedetach.png){.thumbnail}
558+
>>
559+
> **Via Terraform**
560+
>>
561+
>> Start by deleting the lines previously created in your Terraform file:
562+
>>
563+
>> ```python
564+
>> # Attach the volume to the instance
565+
>> resource "openstack_compute_volume_attach_v2" "volume_attach" {
566+
>> instance_id = "<your_instance_id>"
567+
>> volume_id = openstack_blockstorage_volume_v3.terraform_volume.id
568+
>> }
569+
>> ```
570+
>>
571+
>> Enter the following command to check whether the correct resource will be deleted:
572+
>>
573+
>> ```console
574+
>> terraform plan
575+
>> ```
576+
>>
577+
>> The output should look like this:
578+
>>
579+
>> ```console
580+
>> $ terraform plan
581+
>> openstack_compute_volume_attach_v2.va_1: Refreshing state... [id=11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
582+
>> openstack_blockstorage_volume_v3.terraform_volume: Refreshing state... [id=daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
583+
>>
584+
>> Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
585+
>> - destroy
586+
>>
587+
>> Terraform will perform the following actions:
588+
>>
589+
>> # openstack_compute_volume_attach_v2.va_1 will be destroyed
590+
>> # (because openstack_compute_volume_attach_v2.va_1 is not in configuration)
591+
>> - resource "openstack_compute_volume_attach_v2" "va_1" {
592+
>> - device = "/dev/sdb" -> null
593+
>> - id = "11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806" -> null
594+
>> - instance_id = "11cc1279-xxxx-xxxx-xxxx-3ace4c954780" -> null
595+
>> - region = "GRA11" -> null
596+
>> - volume_id = "daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806" -> null
597+
>> }
598+
>>
599+
>> Plan: 0 to add, 0 to change, 1 to destroy.
600+
>> ```
601+
>>
602+
>> Then apply the changes by entering this command:
603+
>>
604+
>> ```console
605+
>> terraform apply
606+
>> ```
607+
>>
608+
>> The output should look like this:
609+
>>
610+
>> ```console
611+
>> $ terraform apply
612+
>> openstack_compute_volume_attach_v2.va_1: Refreshing state... [id=11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
613+
>> openstack_blockstorage_volume_v3.terraform_volume: Refreshing state... [id=daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
614+
>>
615+
>> Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
616+
>> - destroy
617+
>>
618+
>> Terraform will perform the following actions:
619+
>>
620+
>> # openstack_compute_volume_attach_v2.va_1 will be destroyed
621+
>> # (because openstack_compute_volume_attach_v2.va_1 is not in configuration)
622+
>> - resource "openstack_compute_volume_attach_v2" "va_1" {
623+
>> - device = "/dev/sdb" -> null
624+
>> - id = "11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806" -> null
625+
>> - instance_id = "11cc1279-xxxx-xxxx-xxxx-3ace4c954780" -> null
626+
>> - region = "GRA11" -> null
627+
>> - volume_id = "daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806" -> null
628+
>> }
629+
>>
630+
>> Plan: 0 to add, 0 to change, 1 to destroy.
631+
>>
632+
>> Do you want to perform these actions in workspace "test_terraform"?
633+
>> Terraform will perform the actions described above.
634+
>> Only 'yes' will be accepted to approve.
635+
>>
636+
>> Enter a value: yes
637+
>>
638+
>> openstack_compute_volume_attach_v2.va_1: Destroying... [id=11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806]
639+
>> openstack_compute_volume_attach_v2.va_1: Still destroying... [id=11cc1279-xxxx-xxxx-xxxx-3ace4c954780/daf3a86e-xxxx-xxxx-xxxx-ac7b6ffbb806, 10s elapsed]
640+
>> openstack_compute_volume_attach_v2.va_1: Destruction complete after 17s
641+
>>
642+
>> Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
425643
426644
## Go further
427645

0 commit comments

Comments
 (0)