In this guide we will demonstrate how to transfer an Ubuntu VPS off Digital Ocean by cloning the hard disk, along with how to handle the differences between the two services.
Requirements
To perform the migration, you will need two things:
- root login over SSH to the Digital Ocean server that will be cloned ("the source server") - if you normally use SSH keys, you will have to explicitly assign a root password.
- mPanel login to the Binary Lane server ("the destination server"). The Binary Lane server should be created with the same Linux distribution and disk size as the source server.
Preparing the source server
service apache2 stop service mysql stop # etc...
echo u > /proc/sysrq-trigger
At this point the source server is temporarily unusable - once the migration is complete, reboot the source server.
Preparing the destination server
Login to mPanel and go to the main management screen for the destination server. At the bottom of the page, there is a section for selecting what happens when your cloud server boots:
Change from "Distribution kernel" to "Finnix Recovery CD" and click the Save button. Your VPS will reboot into Finnix, which looks like this:
Press ENTER and you will shortly reach a pretty normal bash prompt:
You may wish to zoom in slightly to make the text more readable. At this point, your Binary Lane cloud server is running a "LiveCD" and we can directly modify the virtual hard disk.
Transferring the virtual hard disk
With both the source and destination servers prepared, the actual data transfer process is relatively simple. To perform the transfer, carefully type the following command - unfortunately it must be typed as the rescue environment does not support copy and paste:
ssh [email protected] "dd if=/dev/vda bs=1M | gzip -1" | gunzip | pv -W | dd of=/dev/vda1 bs=1M
Replace src.ip.addr.ess with the IP address used by your source server.
After entering your root SSH password for the source server, a progress bar will be displayed allowing you to see how many GB have been transferred.
Configuring the installation
With the virtual hard disk now copied to Binary Lane, we need to make some final adjustments to allow it to boot:
- Install Grub so that the Binary Lane virtual BIOS can find your Linux installation and boot it
- Change the network configuration to DHCP so that your VPS can start using its Binary Lane IP address
mount /dev/vda1 /mnt mount -o bind /proc /mnt/proc mount -o bind /dev /mnt/dev chroot /mnt
At this point you are now "inside" your linux installation without having actually booted it, allowing configuration to be modified as required. In this case, its just two commands:
grub-install /dev/vda sed -i s/static/dhcp/ /etc/network/interfaces
The process from start to finish looks like this:
Final steps
To complete the migration, scroll to the bottom of mPanel page - change the boot method back to "Distribution kernel" and click the Save button. After doing this, from within Finnix enter the following command:
poweroff
That's it! Your Binary Lane server will now boot with an exact copy of your source server's virtual disk - including the same packages, services, files, and database contents.
To modify it further, SSH to your Binary Lane IP address using the same root password from your Digital Ocean server.