Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Generate AMI from DOMU



Le 22/10/2014 02:38, Louis Guillaume a écrit :
Hello,

Is there was a way to convert an existing DOMU (NetBSD or Linux)
running on a NetBSD DOM0 into an AMI?

The disks presented to the DOMUs are all Logical Volumes, so I have,
for example:

  disk = [
           'phy:/dev/mapper/vg1-lv0,0x01,w'
         ]

  vif = [ 'bridge=bridge0' ]
  root = "xbd0"

AFAICT, two possibilities. Sadly they both involve tweaking your image a bit, after all an EC2 instance is not exactly the same as a dom0 on your host.

=== 1 ===

The guide [1] shows you how to add the /etc/rc.d/ec2_init script to your image as well as adding an EXT2 partition for Grub (required for pygrub booting in EC2):

[1] http://wiki.netbsd.org/amazon_ec2/build_your_own_ami/

For your LV you need to dump the root volume to an image file.

=== 2 ===

ec2-import-instance can do part of the job for you, however I never used it (and I don't know if it works). This requires building a volume in a format supported by AWS (VMDK), throuh a utility like qemu-img.

I'd suggest doing 1) first, then try 2) to automate the upload part a bit more if required.


Beware of your network configuration when migrating your VM (like IP addresses and such). DHCP in /etc/ifconfig.xennet0 (and its equivalent for your Linux distro) is highly recommended.


Also - what about the other way around?


Follow the export EC2 image guide at

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExportingEC2Instances.html

and export the image in VMWare format (VMDK). Then convert the vmdk to raw with qemu-img:

    qemu-img convert -f vmdk -O raw src.vmdk dest.img

then use the dest.img any way you want (mounting it through vnconfig(8) should work, as well as dd(1) it to a fresh LV).


Good luck :)

--
Jean-Yves Migeon


Home | Main Index | Thread Index | Old Index