Skip to content

How to migrate a Droplet from Digital Ocean and boot it in a new instance

Estimated time to read: 3 minutes

Unfortunately, Digital Ocean does not provide a way to directly export a droplet and migrate it to Fuga’s OpenStack platform. So we are going to export the data and create an image in OpenStack from it. Follow this tutorial if you would like to mount the data to an existing instance instead.

The below tutorial is derived from this PDF.

Requirements

  • Root access to the Digital Ocean Droplet.
  • Password for Root on the Digital Ocean Droplet.
  • Digital Ocean Droplet with SSH access enabled.
  • Digital Ocean Droplet with the qemu-util package installed. (sudo apt-get install qemu-utils)
  • Digital Ocean Droplet with OpenStack CLI installed.

Creating an image from the data

Log into the Digital Ocean Droplet Prepare the Droplet for Backup. Reset root’s password if you do not already know it.

Use DD to byte copy the Digital Ocean partition, to a file called snapshot.image

Change /dev/vda1 to the partition you want to migrate.

dd if=/dev/vda1 of=snapshot.image
You might have copied your whole disk instead of only your filesystem, to check this
fdisk -l snapshot.image
If you see more than one device, you have not copied only one partition but multiple. Go to the Converting the image with multiple partitions part If you only see one device, you have only copied one partition. Go to the Converting the image with single partition part

Converting the image with multiple partitions

Look at the output of the fdisk -l snapshot.image command you entered before.

Search for the device with type Linux Filesystem and hold on to the start-value.

This start-value is the amount of sectors offset that the partition has on the drive. We have to multiply this by 512 (start-value x 512) to determine the amount of offset in bytes. This value will be used when creating a loop device.

Convert the DD image to a qcow2 disk format with the ‘qemu-img’ utility please fill in the offset you determined the last step.

qemu-img convert -o ***offset***  -O qcow2 snapshot.image snapshot.qcow2
continue to Uploading the image to OpenStack

Converting the image with single partition

Convert the DD image to a qcow2 disk format with the ‘qemu-img’ utility.

qemu-img convert -O qcow2 snapshot.image snapshot.qcow2

Uploading the image to OpenStack

For this step you need to use your own configuration file with the OpenStack CLI. To upload/create a (private) image with name ‘do-image’ use the following command:

openstack image create --disk-format qcow2 --private --file snapshot.qcow2 do-image
Now you can see your image in the Fuga Dashboard, and create an instance with this image.