Migrating a Virtual Machine from Scaleway to Proxmox
Posted <2021-08-15 Sun 01:22> by Aaron S. Jackson.
I'm not against Scaleway - I think they offer a great service! Still, I wanted to move one particular virtual machine away without dealing with the hassle of configuring everything again. Here are the general steps which worked for me:
- Create a backup image of your instance from the Scaleway console. This isn't for protection, it's so we can mount it as a read-only file system.
- Create a new instance using this image. You'll need to make sure it's sized correctly but Scaleway does a good job of letting you know if there's something wrong.
- Edit
/etc/fstab
to mount everything read only. This just involves changing the things that sayrw
toro
. You might also want to comment out any mount points which aren't entirely necessary, such as/home
if you keep this on a separate drive. - (optional) Install
zerofree
. This will allow us to strip out any of the old unreferenced data from the root fs which will make it more compressible. If you have a very fast connection, you might want to skip this. I found applying zerofree to my root fs to be very fast (20GB). - Reboot. Once it comes back up, you can run zero free if you want.
e.g.
zerofree -v /dev/vda1
. This has to be done after a reboot because the it needs to be unmounted or mounted read-only before zerofree will touch it. - We can begin the transfer and download the Scaleway image. I used dd for this, with gzip to speed things up.
ssh root@remote "dd if=/dev/vda | gzip" | gzip -d | dd of=scaleway.img status=progress
- Once it's transferred, you can delete the new instance from Scaleway, along with the backup image taken earlier. I recommend keeping the original instance running for a few days until you are sure everything has been transferred safely.
- Login to your proxmox web interface and create a new instance,
ensuring that the root drive is the same size, if not larger, than the
main block device on your Scaleway instance. I created my virtual disk
as a zfs subpool in
data0
, so I used the following to "import" the image from Scaleway.
dd if=scaleway.img | ssh root@pve "dd of=/dev/data0/vm-121-disk-0 status=progress"
- In case we imported to a disk which was slightly larger, we'll want
to use fdisk to correct the GPD headers, and the backup GPT entry at the
end of the disk (it won't be at the end of the disk if we imported to a
larger disk). We can use
fdisk
for this, simply rewriting the partition table.
fdisk /dev/data0/vm-121-disk-0
w
- From the Proxmox web interface, change the instance's BIOS to "OVMF
(UEFI)", since Scaleway uses EFI to boot their virtual machines. We'll
also need to add a blank EFI disk to stop Proxmox form complaining. The
EFI will pick out the partition from our transferred disk without
issues. Since Scaleway doesn't use graphical output on their VMs (opting
for serial instead), we'll want to add a virtual serial port and set the
Display to
serial0
. - You can now start up the instance and go to the console. It should boot up fine and allow you to login with your instances password. At this point, everything will still be mounted as read-only, so we'll remount this:
mount -o remount,rw /
- You can now update your
/etc/fstab
file to make these partitionsrw
at boot. - At this point there are a few things which you might want to do, but
it's up to you.
- Install qemu-guest-agent
- Delete
/usr/local/sbin/scw-*
, since these are helper scripts for running in a Scaleway environment. - Delete
/etc/systemd/system/scw-*
, since these services will no longer be useful, and will fail to start. - Install NetworkManager to make things easier on yourself.
That's it! Worked for me, hope it works for you too!
Wanting to leave a comment?
Comments and feedback are welcome by email (aaron@nospam-aaronsplace.co.uk).