Skip to content

How to migrate a volume from one OpenStack provider to another

Estimated time to read: 4 minutes

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 you're going to convert the volume into an image. After converting it into an image, you can download the image and upload it to your new provider.

This tutorial was tested on Fuga Cloud using the OpenStack CLI tools client version 3.17.0

Tip

We recommend using a small Linux cloud instance on the source or 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 can really speed 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.

Info

For big data sets, we recommend rebuilding 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, you 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:

$ server remove volume <instance_name> <volume_id>

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

Step 1.1

To create an image of an attached volume, you're first going to create a snapshot from our bootable volume. After that, you're going to create a new volume from that snapshot. This way you have a volume that is unattached, so that you 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>

You can see if the snapshot is listed:

$ 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 you 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 raw --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 you need to create a volume from the image that you 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. You 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.