Working with volumes: Difference between revisions
(more information about creating images) |
No edit summary |
||
(30 intermediate revisions by 5 users not shown) | |||
Line 3: | Line 3: | ||
<!--T:1--> | <!--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 | 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 <i>Default</i> volume type uses erasure codes to provide data safety while reducing the extra storage costs of 3-fold replication while the <i>OS or Database</i> 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= <!--T:2--> | =Creating a volume= <!--T:2--> | ||
Line 11: | Line 11: | ||
<!--T:4--> | <!--T:4--> | ||
To create a volume click [[File:Create-Volume-Button.png]] and fill in the following fields: | To create a volume click on [[File:Create-Volume-Button.png]] and fill in the following fields: | ||
<!--T:5--> | <!--T:5--> | ||
*Volume Name: <code>data</code>, for example<br/> | *<i>Volume Name</i>: <code>data</code>, for example<br/> | ||
*Description: | *<i>Description</i>: (optional) | ||
*Volume Source: <code>No source, empty volume</code><br/> | *<i>Volume Source</i>: <code>No source, empty volume</code><br/> | ||
*Type: <code>No volume type</code><br/> | *<i>Type</i>: <code>No volume type</code><br/> | ||
*Size (GiB): <code>40</code>, or some suitable size for your data or operating system<br/> | *<i>Size (GiB)</i>: <code>40</code>, or some suitable size for your data or operating system<br/> | ||
*Availability Zone: | *<i>Availability Zone</i>: the only option is <code>nova</code><br/> | ||
<!--T:6--> | <!--T:6--> | ||
Finally, click the blue | Finally, click on the blue <i>Create Volume</i> button at the bottom. | ||
=Mounting a volume on a VM= <!--T:7--> | =Mounting a volume on a VM= <!--T:7--> | ||
==Attaching a | ==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 the Actions menu (Click for larger image)]] | ||
* | * <b>Attaching</b> 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 | * You can attach a volume from the <i>Volumes</i> 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 | * At the right-hand end of the line describing the volume is the <i>Actions</i> column; from the drop-down menu, select <i>Manage Attachments</i>. | ||
* In the | * In the <i>Attach to Instance</i> drop-down menu, select a VM. | ||
* Click the blue | * Click on the blue <i>Attach Volume</i> button. | ||
Attaching should complete in a few seconds. Then the | Attaching should complete in a few seconds. Then the volumes page will show the newly created volume attached to your selected VM on <code>/dev/vdb</code> or some similar location. | ||
==Formatting a newly created volume== | |||
* | * <b>DO NOT FORMAT</b> if you are attaching an existing volume. Instead you can skip this step as the volume would have already been formatted if you had been previously using it to store data. | ||
* <b>Formatting</b> erases all existing information on a volume and therefore should be done with care. | |||
* 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. | * Before a newly created and attached volume can be used, it must be formatted. | ||
* See instructions for doing this on a [[Using a new empty volume on a Linux VM|Linux]] or [[Using a new empty volume on a Windows VM|Windows]] VM. | * See instructions for doing this on a [[Using a new empty volume on a Linux VM|Linux]] or [[Using a new empty volume on a Windows VM|Windows]] VM. | ||
==Mounting a | |||
==Mounting a volume== <!--T:23--> | |||
* '''Mounting''' is the process of mapping the volume's directory and file structure logically within the VM's directory and file structure. | * '''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 <code>[name@server ~]$ sudo mount /dev/vdb1 /mnt</code> depending on the device name, disk layout, and the desired mount point in your filesystem. | * To mount the volume, use a command similar to <code>[name@server ~]$ sudo mount /dev/vdb1 /mnt</code> 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. | This command makes the volume's directory and file structure available under the VM's /mnt directory. However, when the virtual machine reboots, the volume will need to be re-mounted using the same <code>mount</code> command. | ||
<!--T:24--> | |||
It is possible to automatically mount volumes when a virtual machine boots. This requires editing the file named /etc/fstab to contain a new line with details about how the volume should be mounted. | |||
<!--T:25--> | |||
To view mounting information, use the 'blkid' command<br> | |||
<code>blkid</code> | |||
<!--T:26--> | |||
Based on the UUID, add a line to /etc/fstab like this: | |||
<!--T:27--> | |||
<code>/dev/disk/by-uuid/anananan-anan-anana-anan-ananananana /mnt auto defaults,nofail 0 3</code> | |||
<!--T:28--> | |||
Where 'anananan-anan-anana-anan-ananananana' is substituted with UUID of the device you wish to auto-mount. | |||
<!--T:29--> | |||
For more details about how to edit this file see this [https://help.ubuntu.com/community/Fstab Ubuntu community help page]. | |||
=Booting from a volume= <!--T:8--> | =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 | 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 the letter p are used (see [[Virtual machine flavors]]). | ||
<!--T:9--> | <!--T:9--> | ||
Line 56: | Line 77: | ||
<!--T:11--> | <!--T:11--> | ||
If creating a volume as part of the process of launching the VM, select < | If creating a volume as part of the process of launching the VM, select <i>Boot from image (creates a new volume)</i>, 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 <i>Delete on Terminate</i> box is not checked. 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= <!--T:12--> | =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 on a different 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. | 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 on a different 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 (root) volume, it can only be detached from a VM if the VM is terminated/deleted; however, make sure you have not checked | <!--T:21--> | ||
To create an image of a volume, it must first be detached from a VM. If it is a boot (root) volume, it can only be detached from a VM if the VM is terminated/deleted; however, make sure you have not checked <i>Delete Volume on Instance Delete</i> when creating the VM. | |||
<!--T:22--> | |||
Large images (more than 10-20GB) may be very slow to create, upload, and otherwise manage. You may want to consider [[Backing_up_your_VM#An_example_backup_strategy | separating data]] if possible. | Large images (more than 10-20GB) may be very slow to create, upload, and otherwise manage. You may want to consider [[Backing_up_your_VM#An_example_backup_strategy | separating data]] if possible. | ||
==Using the dashboard== <!--T:13--> | ==Using the dashboard== <!--T:13--> | ||
# Click on the | # Click on the <i>Volumes</i> left-hand menu. | ||
# Under the volume you wish to create an image of click on the drop down | # Under the volume you wish to create an image of click on the drop-down <i>Actions</i> menu and select <i>Upload to Image</i>. | ||
# Choose a name for your new image. | # Choose a name for your new image. | ||
# Choose a | # Choose a disk format. QCOW2 is recommended for using within the OpenStack cloud as it is relatively compact compared to <i>Raw</i> and works well with OpenStack. If you wish to use the image with Virtualbox, the <i>vmdk</i> or <i>vdi</i> image formats might be better suited. | ||
# Finally click | # Finally, click on <i>Upload</i>. | ||
==Using the | ==Using the command line client== <!--T:14--> | ||
The [[OpenStack | 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>}} | ||
where | where | ||
Line 83: | Line 106: | ||
=Cloning a volume= <!--T:15--> | =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 | 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>}} | ||
Line 90: | Line 113: | ||
<!--T:17--> | <!--T:17--> | ||
To detach a volume, log in to the OpenStack dashboard (see the [[Cloud# | To detach a volume, log in to the OpenStack dashboard (see the [[Cloud#Cloud_systems|list of links to our cloud systems]]) and select the project containing the volume you wish to detach. Selecting <i>Volumes -> Volumes</i> displays the project’s volumes. For each volume, the <i>Attached to</i> column indicates where the volume is attached. | ||
<!--T:18--> | <!--T:18--> | ||
Line 99: | Line 122: | ||
<!--T:20--> | <!--T:20--> | ||
[[Category: | [[Category:Cloud]] | ||
</translate> | </translate> |
Latest revision as of 21:31, 30 March 2023
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
To create a volume click on and fill in the following fields:
- Volume Name:
data
, for example - Description: (optional)
- 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: the only option is
nova
Finally, click on the blue Create Volume button at the bottom.
Mounting a volume on a VM
Attaching a volume
- 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 on 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
- DO NOT FORMAT if you are attaching an existing volume. Instead you can skip this step as the volume would have already been formatted if you had been previously using it to store data.
- Formatting erases all existing information on a volume and therefore should be done with care.
- 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.
- 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. However, when the virtual machine reboots, the volume will need to be re-mounted using the same mount
command.
It is possible to automatically mount volumes when a virtual machine boots. This requires editing the file named /etc/fstab to contain a new line with details about how the volume should be mounted.
To view mounting information, use the 'blkid' command
blkid
Based on the UUID, add a line to /etc/fstab like this:
/dev/disk/by-uuid/anananan-anan-anana-anan-ananananana /mnt auto defaults,nofail 0 3
Where 'anananan-anan-anana-anan-ananananana' is substituted with UUID of the device you wish to auto-mount.
For more details about how to edit this file see this Ubuntu community help page.
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 the letter 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 not checked. 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 allows you to download the image. Do this if you want to save it as a backup, or to spin up a VM on a different 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 (root) volume, it can only be detached from a VM if the VM is terminated/deleted; however, make sure you have not checked Delete Volume on Instance Delete when creating the VM.
Large images (more than 10-20GB) may be very slow to create, upload, and otherwise manage. You may want to consider separating data if possible.
Using the dashboard
- 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.
- Choose a name for your new image.
- Choose a disk format. QCOW2 is recommended for using within the OpenStack cloud as it is relatively compact compared to Raw and works well with OpenStack. If you wish to use the image with Virtualbox, the vmdk or vdi image formats might be better suited.
- Finally, click on Upload.
Using the command line client
The command line client can do this:
[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.
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
[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 to our cloud systems) 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.