Skip to content

Instantly share code, notes, and snippets.

@vincentbernat
Created December 5, 2016 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentbernat/d5c96b27e6f254ff293962778682d9c5 to your computer and use it in GitHub Desktop.
Save vincentbernat/d5c96b27e6f254ff293962778682d9c5 to your computer and use it in GitHub Desktop.

Switching to another cloud image

#+filetags :exoscale:

The goal is to install another cloud image on an existing VM. We will assume the existing VM is running Debian Jessie.

Steps

Installing dropbear for initramfs access

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

Installing Grub 2

apt-get -qyy install grub2
echo GRUB_CMDLINE_LINUX_DEFAULT="break=mount" >> /etc/default/grub
grub-install /dev/vda
update-grub

Reboot and login into initramfs

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment