Working with volumes: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(updating links)
(Marked this version for translation)
Line 2: Line 2:
<translate>
<translate>


<!--T:1-->
A volume provides storage which is not destroyed when a VM is terminated. On our clouds, volumes use [https://en.wikipedia.org/wiki/Ceph_(software) Ceph] storage with either a 3-fold replication factor or [https://en.wikipedia.org/wiki/Erasure_code erasure codes] to provide safety against hardware failure. On [[Cloud_resources|Arbutus]] the ''Default'' volume type uses erasure codes to provide data safety while reducing the extra storage costs of 3-fold replication while the ''OS or Database'' volume type still uses the 3-fold replication factor. More documentation about OpenStack volumes can be found [https://docs.openstack.org/cinder/latest/cli/cli-manage-volumes.html here]
A volume provides storage which is not destroyed when a VM is terminated. On our clouds, volumes use [https://en.wikipedia.org/wiki/Ceph_(software) Ceph] storage with either a 3-fold replication factor or [https://en.wikipedia.org/wiki/Erasure_code erasure codes] to provide safety against hardware failure. On [[Cloud_resources|Arbutus]] the ''Default'' volume type uses erasure codes to provide data safety while reducing the extra storage costs of 3-fold replication while the ''OS or Database'' volume type still uses the 3-fold replication factor. More documentation about OpenStack volumes can be found [https://docs.openstack.org/cinder/latest/cli/cli-manage-volumes.html here]


=Creating a volume=
=Creating a volume= <!--T:2-->


<!--T:3-->
[[File:Creating_a_volume_EN.png|300px|thumb| Create Volume dialog (Click for larger image)]]
[[File:Creating_a_volume_EN.png|300px|thumb| Create Volume dialog (Click for larger image)]]


<!--T:4-->
To create a volume click [[File:Create-Volume-Button.png]] and fill in the following fields:
To create a volume click [[File:Create-Volume-Button.png]] and fill in the following fields:


<!--T:5-->
*Volume Name: <code>data</code>, for example<br/>
*Volume Name: <code>data</code>, for example<br/>
*Description: Optional text
*Description: Optional text
Line 17: Line 21:
*Availability Zone: On the East and Arbutus clouds, the only option is <code>nova</code><br/>
*Availability Zone: On the East and Arbutus clouds, the only option is <code>nova</code><br/>


<!--T:6-->
Finally, click the blue "Create Volume" button.
Finally, click the blue "Create Volume" button.


=Mounting a volume on a VM=
=Mounting a volume on a VM= <!--T:7-->
==Attaching a Volume==
==Attaching a Volume==
[[File:Manage_attachments_EN.png|400px|thumb| Managing attachments command in Actions menu (Click for larger image)]]
[[File:Manage_attachments_EN.png|400px|thumb| Managing attachments command in Actions menu (Click for larger image)]]
Line 38: Line 43:
This command makes the volume's directory and file structure available under the VM's /mnt directory.
This command makes the volume's directory and file structure available under the VM's /mnt directory.


=Booting from a volume=
=Booting from a volume= <!--T:8-->
If you want to run a persistent machine, it is safest to boot from a volume. When you boot a VM from an image rather than a volume, the VM is stored on the local disk of the actual machine running the VM. If something goes wrong with that machine or its disk the VM may be lost. Volume storage has redundancy which protects the VM from hardware failure. Typically when booting from a volume VM flavors starting with a 'p' are used (see [[Virtual machine flavors]]).
If you want to run a persistent machine, it is safest to boot from a volume. When you boot a VM from an image rather than a volume, the VM is stored on the local disk of the actual machine running the VM. If something goes wrong with that machine or its disk the VM may be lost. Volume storage has redundancy which protects the VM from hardware failure. Typically when booting from a volume VM flavors starting with a 'p' are used (see [[Virtual machine flavors]]).


<!--T:9-->
There are several ways to boot a VM from a volume. You can  
There are several ways to boot a VM from a volume. You can  
* boot from an image, creating a new volume, or  
* boot from an image, creating a new volume, or  
Line 46: Line 52:
* boot from a volume snapshot, creating a new volume.
* boot from a volume snapshot, creating a new volume.


<!--T:10-->
If you have not done this before, then the first one is your only option. The other two are only possible if you have already created a bootable volume or a volume snapshot.
If you have not done this before, then the first one is your only option. The other two are only possible if you have already created a bootable volume or a volume snapshot.


<!--T:11-->
If creating a volume as part of the process of launching the VM, select <code>Boot from image (creates a new volume)</code>, select the image to use, and the size of the volume. If this volume is something you would like to remain longer than the VM ensure that the "Delete on Terminate" box is unchecked. If you are unsure about this option, it is better to leave this box unchecked. You can manually delete the volume later.
If creating a volume as part of the process of launching the VM, select <code>Boot from image (creates a new volume)</code>, select the image to use, and the size of the volume. If this volume is something you would like to remain longer than the VM ensure that the "Delete on Terminate" box is unchecked. If you are unsure about this option, it is better to leave this box unchecked. You can manually delete the volume later.


=Creating an image from a volume=
=Creating an image from a volume= <!--T:12-->
[[File:Upload_volume_from_image_EN.png|400px|thumb| Upload to Image form (Click for larger image)]]<!--Note to translator: there is a FR version of this screen shot at [[File:Os-upload-volume-to-image-fr.png]]-->
[[File:Upload_volume_from_image_EN.png|400px|thumb| Upload to Image form (Click for larger image)]]<!--Note to translator: there is a FR version of this screen shot at [[File:Os-upload-volume-to-image-fr.png]]-->
Creating an image from a volume allows you to download the image. Do this if you want to save it as a backup, or to spin up a VM somewhere other than the CC Cloud, e.g. with [https://www.virtualbox.org/ VirtualBox]. If you want to copy a volume to a new volume within the same cloud see [[#Cloning a Volume|cloning a volume]] instead. To create an image of a volume, it must first be detached from a VM. If it is a boot volume, it can only be detached from a VM if the VM is terminated/deleted.
Creating an image from a volume allows you to download the image. Do this if you want to save it as a backup, or to spin up a VM somewhere other than the CC Cloud, e.g. with [https://www.virtualbox.org/ VirtualBox]. If you want to copy a volume to a new volume within the same cloud see [[#Cloning a Volume|cloning a volume]] instead. To create an image of a volume, it must first be detached from a VM. If it is a boot volume, it can only be detached from a VM if the VM is terminated/deleted.


==Using the dashboard==
==Using the dashboard== <!--T:13-->
# Click on the ''Volumes'' left-hand menu.
# Click on the ''Volumes'' left-hand menu.
# Under the volume you wish to create an image of click on the drop down ''Actions'' menu and select ''Upload to Image''.
# Under the volume you wish to create an image of click on the drop down ''Actions'' menu and select ''Upload to Image''.
Line 61: Line 69:
# Finally click ''Upload''.
# Finally click ''Upload''.


==Using the Command Line Clients==
==Using the Command Line Clients== <!--T:14-->
The [[OpenStack Command Line Clients|command line client]] can do this:
The [[OpenStack Command Line Clients|command line client]] can do this:
{{Command|openstack image create --disk-format <format> --volume <volume_name> <image_name>}}
{{Command|openstack image create --disk-format <format> --volume <volume_name> <image_name>}}
Line 70: Line 78:
You can then [[Working_with_images#Downloading_an_Image|download the image]] as described below. It is best to detach the volume from the VM before you create an image from the volume. If the volume is a boot volume you will likely need to delete your VM to detach it, however, make sure you have not checked "Delete Volume on Instance Delete" when creating the VM.
You can then [[Working_with_images#Downloading_an_Image|download the image]] as described below. It is best to detach the volume from the VM before you create an image from the volume. If the volume is a boot volume you will likely need to delete your VM to detach it, however, make sure you have not checked "Delete Volume on Instance Delete" when creating the VM.


=Cloning a volume=
=Cloning a volume= <!--T:15-->
Cloning is the recommended method for copying volumes. While it is possible to make an image of an existing volume and use it to create a new volume, cloning is much faster and requires less movement of data behind the scenes. This method is handy if you have a persistent VM and you want to test out something before doing it on your production site. It is highly recommended to shut down your VM before creating a clone of the volume as the newly created volume may be left in an inconsistent state if there was writing to the source volume during the time the clone was created. To create a clone you must use the [[OpenStack Command Line Clients|command line client]] with this command
Cloning is the recommended method for copying volumes. While it is possible to make an image of an existing volume and use it to create a new volume, cloning is much faster and requires less movement of data behind the scenes. This method is handy if you have a persistent VM and you want to test out something before doing it on your production site. It is highly recommended to shut down your VM before creating a clone of the volume as the newly created volume may be left in an inconsistent state if there was writing to the source volume during the time the clone was created. To create a clone you must use the [[OpenStack Command Line Clients|command line client]] with this command
{{Command|openstack volume create --source <source-volume-id> --size <size-of-new-volume> <name-of-new-volume>}}
{{Command|openstack volume create --source <source-volume-id> --size <size-of-new-volume> <name-of-new-volume>}}


=Detaching a volume=
=Detaching a volume= <!--T:16-->
Before detaching a volume, it is important to make sure that the operating system and other programs running on your VM are not accessing files on this volume. If so, the detached volume can be left in a corrupted state or the programs could show unexpected behaviours. To avoid this, you can either shut down the VM before you detach the volume or [[Using_a_new_empty_volume_on_a_Linux_VM#Unmounting_a_volume_or_device|unmount the volume]].
Before detaching a volume, it is important to make sure that the operating system and other programs running on your VM are not accessing files on this volume. If so, the detached volume can be left in a corrupted state or the programs could show unexpected behaviours. To avoid this, you can either shut down the VM before you detach the volume or [[Using_a_new_empty_volume_on_a_Linux_VM#Unmounting_a_volume_or_device|unmount the volume]].


<!--T:17-->
To detach a volume, log in to the OpenStack dashboard (see the [[Cloud#Using_the_Cloud|list of links]]) and select the project containing the volume you wish to detach. Selecting ''Volumes -> Volumes'' displays the project’s volumes. For each volume, the ''Attached to'' column indicates where the volume is attached.  
To detach a volume, log in to the OpenStack dashboard (see the [[Cloud#Using_the_Cloud|list of links]]) and select the project containing the volume you wish to detach. Selecting ''Volumes -> Volumes'' displays the project’s volumes. For each volume, the ''Attached to'' column indicates where the volume is attached.  


<!--T:18-->
*If attached to <code>/dev/vda</code>, it is a boot volume; you must delete the attached VM before the volume can be detached otherwise you will get the error message ''Unable to detach volume''.
*If attached to <code>/dev/vda</code>, it is a boot volume; you must delete the attached VM before the volume can be detached otherwise you will get the error message ''Unable to detach volume''.


<!--T:19-->
*With volumes attached to <code>/dev/vdb</code>, <code>/dev/vdc</code>, etc. you do not need to delete the VM it is attached to before proceeding. In the ''Actions'' column drop-down list, select ''Manage Attachments'', click on the ''Detach Volume'' button and again on the next ''Detach Volume'' button to confirm.
*With volumes attached to <code>/dev/vdb</code>, <code>/dev/vdc</code>, etc. you do not need to delete the VM it is attached to before proceeding. In the ''Actions'' column drop-down list, select ''Manage Attachments'', click on the ''Detach Volume'' button and again on the next ''Detach Volume'' button to confirm.


<!--T:20-->
[[Category:CC-Cloud]]
[[Category:CC-Cloud]]
</translate>
</translate>

Revision as of 21:00, 8 November 2022

Other languages:

A volume provides storage which is not destroyed when a VM is terminated. On our clouds, volumes use Ceph storage with either a 3-fold replication factor or erasure codes to provide safety against hardware failure. On Arbutus the Default volume type uses erasure codes to provide data safety while reducing the extra storage costs of 3-fold replication while the OS or Database volume type still uses the 3-fold replication factor. More documentation about OpenStack volumes can be found here

Creating a volume

Create Volume dialog (Click for larger image)

To create a volume click Create-Volume-Button.png and fill in the following fields:

  • Volume Name: data, for example
  • Description: Optional text
  • Volume Source: No source, empty volume
  • Type: No volume type
  • Size (GiB): 40, or some suitable size for your data or operating system
  • Availability Zone: On the East and Arbutus clouds, the only option is nova

Finally, click the blue "Create Volume" button.

Mounting a volume on a VM

Attaching a Volume

Managing attachments command in Actions menu (Click for larger image)
  • Attaching is the process of associating a volume with a VM. This is analogous to inserting a USB key or plugging an external drive into your personal computer.
  • You can attach a volume from the Volumes page in the Dashboard.
  • At the right-hand end of the line describing the volume is the Actions column; from the drop-down menu, select "Manage Attachments."
  • In the "Attach To Instance" drop-down menu, select a VM.
  • Click the blue "Attach Volume" button.

Attaching should complete in a few seconds. Then the Volumes page will show the newly created volume attached to your selected VM on /dev/vdb or some similar location.

Formatting a newly created Volume

  • Formatting is the process of preparing a volume to store directories and files.
  • Before a newly created and attached volume can be used, it must be formatted.
  • Formatting erases all existing information on a volume and therefore should be done with care.
  • See instructions for doing this on a Linux or Windows VM.

Mounting a Volume

  • Mounting is the process of mapping the volume's directory and file structure logically within the VM's directory and file structure.
  • To mount the volume, use a command similar to [name@server ~]$ sudo mount /dev/vdb1 /mnt depending on the device name, disk layout, and the desired mount point in your filesystem.

This command makes the volume's directory and file structure available under the VM's /mnt directory.

Booting from a volume

If you want to run a persistent machine, it is safest to boot from a volume. When you boot a VM from an image rather than a volume, the VM is stored on the local disk of the actual machine running the VM. If something goes wrong with that machine or its disk the VM may be lost. Volume storage has redundancy which protects the VM from hardware failure. Typically when booting from a volume VM flavors starting with a 'p' are used (see Virtual machine flavors).

There are several ways to boot a VM from a volume. You can

  • boot from an image, creating a new volume, or
  • boot from a pre-existing volume, or
  • boot from a volume snapshot, creating a new volume.

If you have not done this before, then the first one is your only option. The other two are only possible if you have already created a bootable volume or a volume snapshot.

If creating a volume as part of the process of launching the VM, select Boot from image (creates a new volume), select the image to use, and the size of the volume. If this volume is something you would like to remain longer than the VM ensure that the "Delete on Terminate" box is unchecked. If you are unsure about this option, it is better to leave this box unchecked. You can manually delete the volume later.

Creating an image from a volume

Upload to Image form (Click for larger image)

Creating an image from a volume allows you to download the image. Do this if you want to save it as a backup, or to spin up a VM somewhere other than the CC Cloud, e.g. with VirtualBox. If you want to copy a volume to a new volume within the same cloud see cloning a volume instead. To create an image of a volume, it must first be detached from a VM. If it is a boot volume, it can only be detached from a VM if the VM is terminated/deleted.

Using the dashboard

  1. Click on the Volumes left-hand menu.
  2. Under the volume you wish to create an image of click on the drop down Actions menu and select Upload to Image.
  3. Choose a name for your new image.
  4. Choose a Disk Format. QCOW2 is recommended for using within the OpenStack cloud as it is relatively compact compared to Raw image format and works well with OpenStack. If you wish to use the image with Virtualbox the vmdk or vdi image formats might be better suited.
  5. Finally click Upload.

Using the Command Line Clients

The command line client can do this:

Question.png
[name@server ~]$ openstack image create --disk-format <format> --volume <volume_name> <image_name>

where

  • <format> is the disk format (two possible values are qcow2 and vmdk),
  • <volume_name> can be found from the OpenStack dashboard by clicking on the volume name, and
  • <image_name> is a name you choose for the image.

You can then download the image as described below. It is best to detach the volume from the VM before you create an image from the volume. If the volume is a boot volume you will likely need to delete your VM to detach it, however, make sure you have not checked "Delete Volume on Instance Delete" when creating the VM.

Cloning a volume

Cloning is the recommended method for copying volumes. While it is possible to make an image of an existing volume and use it to create a new volume, cloning is much faster and requires less movement of data behind the scenes. This method is handy if you have a persistent VM and you want to test out something before doing it on your production site. It is highly recommended to shut down your VM before creating a clone of the volume as the newly created volume may be left in an inconsistent state if there was writing to the source volume during the time the clone was created. To create a clone you must use the command line client with this command

Question.png
[name@server ~]$ openstack volume create --source <source-volume-id> --size <size-of-new-volume> <name-of-new-volume>

Detaching a volume

Before detaching a volume, it is important to make sure that the operating system and other programs running on your VM are not accessing files on this volume. If so, the detached volume can be left in a corrupted state or the programs could show unexpected behaviours. To avoid this, you can either shut down the VM before you detach the volume or unmount the volume.

To detach a volume, log in to the OpenStack dashboard (see the list of links) and select the project containing the volume you wish to detach. Selecting Volumes -> Volumes displays the project’s volumes. For each volume, the Attached to column indicates where the volume is attached.

  • If attached to /dev/vda, it is a boot volume; you must delete the attached VM before the volume can be detached otherwise you will get the error message Unable to detach volume.
  • With volumes attached to /dev/vdb, /dev/vdc, etc. you do not need to delete the VM it is attached to before proceeding. In the Actions column drop-down list, select Manage Attachments, click on the Detach Volume button and again on the next Detach Volume button to confirm.