#+filetags :exoscale:
The goal is to install another cloud image on an existing VM. We will assume the existing VM is running Debian Jessie.
apt-get -qyy install dropbear busybox
cat <<EOF >> /etc/initramfs-tools/initramfs.conf
DROPBEAR=y
DEVICE=eth0
IP=dhcp
EOF
cp /root/.ssh/authorized_keys /etc/initramfs-tools/root/.ssh/authorized_keys
update-initramfs -u
apt-get -qyy install grub2
echo GRUB_CMDLINE_LINUX_DEFAULT="break=mount" >> /etc/default/grub
grub-install /dev/vda
update-grub
Once rebooted, you should be able to SSH into the initramfs. From here, you can use the following command to put an alternative image into the disk. The image should be a raw image (no way to convert a qcow2 image on the fly).
For example, for ArchLinux:
wget -O - \
http://159.100.248.75/arch.raw | \
dd of=/dev/vda
sync
sync
echo b > /proc/sysrq-trigger
Note that you have to do the resolution manually as a static busybox is not able to use the resolver.