HOWTO migrate an AMI from Essex to a bootable volume on Havana

A snapshot of an Essex OpenStack instance contains an AMI ext3 file system. It is rsync’ed to a partitioned volume in the Havana cluster. After installing grub from chroot, a new instance can be booted from the volume.

The instance snapshot from the Essex cluster is mounted on the host containing the glance directory:

$ mount /var/lib/glance/images/493e2e71-f100-403c-98a0-0ccbafec6fbd /mnt

A volume is created in an Havana cluster and attached to a temporary instance, for the duration of the migration. A single partition is created and formatted as ext3.

root@migrate:~# fdisk /dev/vdc
Command (m for help): p
Disk /dev/vdc: 32.2 GB, 32212254720 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/vdc1            2048    62914559    31456256   83  Linux
root@migrate:~# mkfs.ext3 /dev/vdc

The content of the AMI is copied from the glance host to the newly created file system:

root@migrate:~# mount /dev/vdc1 /mnt
root@migrate:~# rsync -avHz --numeric-ids glance.host.net:/mnt/ /mnt/

Grub is installed after mounting the special file systems:

migrate:/# mount --bind /dev /mnt/dev && mount --bind /dev/pts /mnt/dev/pts && mount --bind /proc /mnt/proc && mount --bind /sys /mnt/sys
migrate:~# chroot /mnt
migrate:/# grub-install /dev/vdc
Searching for GRUB installation directory ... found: /boot/grub
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(hd0)	/dev/vda
(hd1)	/dev/vdb
(hd2)	/dev/vdc
migrate:/# update-grub
# update-grub
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.26-2-686
Updating /boot/grub/menu.lst ... done

Detach the volume from the temporary instance

migrate:~# umount /mnt/dev/pts && umount /mnt/dev && umount /mnt/proc && umount /mnt/sys
migrate:~# umount /mnt
migrate:~# nova volume-detach migrate b4bdd79f-e9e8-4cd1-9826-a122d9d626f6

Booting from the volume may fail if grub is misconfigured. It can be fixed from the console.

One Reply to “HOWTO migrate an AMI from Essex to a bootable volume on Havana”

Comments are closed.