How to migrate a volume from one OpenStack provider to another
volume snapshot migrate CLI R2

How to migrate a volume from one OpenStack provider to another

In this tutorial you learn how you can migrate small (bootable) volumes from one provider to another, using images. You can not download or upload volumes from one provider to another that’s why we are going to convert the volume into an image. After converting it into an image, we can download the image and upload it to your new provider.

This tutorial was tested on Fuga Cloud Release 1 and Release 2 using the OpenStack CLI tools client version 3.17.0

TIP: We recommend using a small Linux cloud instance on the destination platform with the OpenStack CLI tools installed. This way you can make full use of the fast connections of the cloud platforms instead of downloading it to your local machine. This really speeds up the process.

Prerequisites:

  • 2 active OpenStack accounts
  • OpenStack CLI tools installed
  • A block store or volume (that you would like to migrate)
  • OpenStack credentials (open.rc files) from both OpenStack providers.

For big data sets we recommend to rebuild your platform and sync your data instead of using the method described in this tutorial.

Step 1 Detach your volume

Before creating an image of your volume so that you can download it, you need to detach the volume from your instance.

First, let’s stop your instance where the volume is attached too. You can view the instance name of your instance using the following command:

openstack server list

If the instance is still running you can Shut down your instance using the following command:

openstack server stop <instance_name>

Next, we need to detach the volume from the instance it is mounted on. First, let’s check the volume ID

$ openstack volume list

You can detach the volume using the following command:

$ nova volume-detach <instance_name> <volume_id>

If the volume is detached, you can go to step 2 otherwise follow Step 1.1

STEP 1.1

To create an image of an attached volume, we are first going to create a snapshot from our bootable volume. After that, we are going to create a new volume from that snapshot. This way we have a volume that is unattached so that we can create an image of that volume.

First let’s create a snapshot of the (bootable)volume

openstack volume snapshot create --volume <volume_name> --force <snapshot_name>

We can check the status here:

openstack volume snapshot list

Now let’s create a new volume from our freshly made snapshot. Please note that the volume size should match the snapshot size.

$ openstack volume create --snapshot <snapshot-name-or-id> --size <size> <new-volume-name>

STEP 2 Create an image of your volume

You can not download a volume in OpenStack, so we first have to create an image of your volume so that the image can be downloaded.

Get your image ID using the following command:

openstack volume list

Create an image of your volume and give it a proper name using the following command

openstack image create --volume <volume_name> <your_image_name>

You can check the status of your image using the following command:

openstack image list

STEP 3 Download your image

You can now download your newly created image using the following command

$ openstack image save --file snapshot.raw <your_image_id>

STEP 4 Uploading your image to the new OpenStack platform

Make sure you are logged in to the correct OpenStack platform with your CLI tools

source your_openrc.sh

Upload your snapshot that you’ve just downloaded using the following command:

openstack image create --container-format bare --disk-format qcow2 --file <image_file_name> <image_name>

STEP 5 Creating a volume from an image

You need the image ID of the image that you have uploaded to the new platform. You can obtain this using the following command:

openstack image list

Now we need to create a volume from the image that we have uploaded. You can do that using the following command:

openstack volume create --image <image_id> --size <size_in_gb> <name_your_volume>

You can check the status of your volume

openstack volume list

Start your instance with your bootable volume

openstack server create --volume <volume_name> --flavor <flavor_name> <instance_name>

Conclusion

You have now learned how you can convert a volume into an image so that you can download it. We showed you how you can upload that image to a new cloud provider and convert it back into a volume. This tutorial is an easy way to migrate volumes from one provider to another using the OpenStack CLI tools.

Was this article helpful?


Next article:

How to migrate an instance from one OpenStack provider to another

In this tutorial, we will show you how you can migrate an instance with ephemeral storage from one OpenStack provider to another OpenStack provider using snapshots. There are several ways of migrating instances and probably even some forms of doing this without any downtime, but this tutorial describes one of the most basic and easiest ways of doing it, using the OpenStack CLI tools. This tutorial was tested on Fuga Cloud Release 1 and Release 2 using the OpenStack CLI tools client version 3.

Improved performance and more features

BRAND NEW PLATFORM

NOW IN PUBLIC BETA

Test it for FREE! More information