Migrating a Volume

Introduction

When you migrate an instance from one availability zone (AZ) to another, the volumes that it uses need to be migrated as well.  The Nectar federation does not allow a volume in one AZ to be attached to an instance in a different AZ.

We will describe three distinct approaches to dealing with volume migration.  

  • Discarding and recreating scratch volumes

  • Migrating using Volume Backup

  • Migrating by copying data between volumes.

Each one has advantages and disadvantages.

Assumptions

The instructions in this page assume that you understand how to detach and attach volumes, and format new file systems (when required) and unmount and mount file systems, and deal with Linux’s mechanisms for configuring mounts to persist over reboots.  For more information on these topics, please refer to:

Quotas

All 3 approaches to volume migration require Volume Storage quota in both the old and new AZ’s to hold all of the volumes.  Migration using Volume Backup also requires Object Storage quota to hold the backups.

Approach #1 - Discarding and recreating scratch volumes 

A couple of use-cases for Volume Storage are to provide temporary storage for data intensive computations, or local caching for data that is held elsewhere.  If your volume is used in these (or similar) ways, there is a quick way to deal with migration.

Steps:

  1. While the volume is still attached and mounted, double-check that it does not contain any files that need to be kept.  

  2. Unmount and detach old volume

  3. Delete the old volume.  (You could defer this, but there is little point if you already know that doesn’t contain anything of value.)

  4. Create a new empty volume in the new AZ.  You could create it with a larger or smaller size than the original volume.

  5. Attach the new volume to the new instance, format it and mount it.

Approach #2 - Using Volume Backup

In some respects, migration using the Volume Backup service is the simplest approach.  Unfortunately, it won’t always work:

  • Volume Backup may not work for large volumes. The server that performs the backup creates a temporary copy in local disk space before uploading the backup to Object Storage. If the volume is too large, there may not be enough disk space for the temporary copy.  It is not possible to say how large is “too large”, but as a rule of thumb, backups are normally expected to work for volumes with sizes up to 500 GB.

  • The QCIF Nectar Node does not currently implement the Volume Backup service.  This means that volumes cannot be migrated out of or into the QRIScloud AZ using backup and restore.

Note that Volume Backup stores the volume backup in Object Storage, and therefore requires sufficient Object Storage quota for the backup.

Steps:

  1. Unmount and detach the volume from the old instance.

  2. Use the Volume Backup service to create a volume backup.  Check that the backup has completed successfully.  (NB: Do not use a Volume Snapshot. You will not be able to create a new volume in the new AZ from the snapshot.)

  3. Create a new volume from the backup in the new AZ 

  4. Attach the new volume to the new instance.

  5. Wait.  It is advisable to keep the old volume for a few days in case it is needed to roll back the migration.

  6. Delete old volume and the backup

Approach #3 - Copying data between Volumes

The final approach is to copy the data from one volume to another while they are mounted on instances.  This approach should work in all cases, irrespective of the volume size and location. You can also be selective in the files that you copy, or use this as an opportunity to downsize the volume.

This approach is more involved than the Volume Backup approach, and may take longer  in some circumstances.  The following instructions assume that you are familiar with SSH public key authentication and the way that the “rsync” command works. They also assume that you understand how Linux user accounts (uids) and groups (gids) work.

Steps:

  1. Ensure that the old volume is attached to the old instance in original AZ.

  2. It is advisable to create precautionary backup of the data in the old volume before you start.

  3. Create the new volume in new AZ.  You could create it with a larger or smaller size than the original volume.

  4. Attach the new volume to the new instance, format it and mount it.

  5. Assuming that you are going to “push” files from the old instance to the new instance, arrange that you have the private key for the new instance’s admin account on the old instance. 

  6. Use rsync to copy the data from the old volume to the new volume. This could take some time, especially if your volume’s content consists of a huge number of small files.

NB: You need to be careful when running “rsync”.  If you get the command line options and arguments incorrect, there is the potential to clobber all of the files in the old volume. 

  1. Detach the old volume from the old instance.

  2. Wait.  It is advisable to keep the old volume for a few days in case it is needed to roll back the migration.

  3. Delete old volume and (optionally) the precautionary backup.