All Pages

Amazon OS Outside EC2

linefeed.se > Amazon OS Outside EC2

The Amazon OS, or the Amazon Linux AMI is, according to Amazon, not supported outside the EC2. In some cases it can be useful to be able to run it on your own (virtual) hardware.
Warning, this is a very technical post.

Step ONE: Bring up an EC2 instance with the OS you want to clone. Choose the Amazon Linux AMI on a HVM (not paravirt) x86_64 EBS guest. Log in and install the dracut-kernel package and gcc44 (important – gcc 4.8 is not compatible with the elrepo-lt-kernel). Also set a root password for later.

Step TWO: Clone the xvda drive of that instance.
ssh ec2-user@ipaddr "sudo dd if=/dev/xvda bs=4096 | gzip -c" > cloned.drive.gz

Step THREE: Gunzip that cloned.drive.gz and use vboxmanage to create a VDI virtual harddisk.
vboxmanage convertfromraw cloned.drive amzn-clone.vdi --format VDI

Step FOUR: Create a new virtual machine, important is that the hard disk controller is SATA, and that both your amzn-clone.vdi is attached to the SATA controller.

Step FIVE: Try booting. You must enter the grub menu and alter the kernel command line – remove console=ttyS0 so that you can see what is going on.

The VM should now boot, but there is no network adapter so the VM is pretty useless. We must change the kernel to one that has drivers for the virtual hardware

Step SIX: Create a new ISO image with the kernel-lt rpm and the kernel-lt-devel from here: http://elrepo.org/linux/kernel/el6/x86_64/RPMS/. Mount that ISO image in the VM. The device is called /dev/sr0, because the CD is on the SATA controller.

Step SEVEN: Install the new kernel, and edit /boot/grub/menu.lst so that the kernel-lt is now default, also remove the console=ttyS0 from all entries.

Step EIGHT: Reboot into the new kernel. I got a very long timeout (20 minutes) for DHCP, but after that everything worked.

You are now up and running on Amazon OS outside EC2. But there are still things to do, like installing virtualbox guest additions and setting up so that you can reach the amzn-base and amzn-updates repo. But if you got this far I think you can manage.

Good Luck

//T-Å