EC2 Custom Kernels
One minor issue with EC2 is that they supply the kernel, and that already caused difficulties with my first EC2 tutorial – the image I created doesn’t let you create a new snapshot from a running image since the EC2 kernel lacks loopback support, and I didn’t supply a matching kernel module.
Amazon has a nice guide on how to do it – here is a gentoo-specific one.
These instructions start from a working ami image created using my previous instructions. Go ahead and mount it and chroot into the image.
- Install a kernel using emerge xen-sources
- Be sure to enable xen support in the kernel config file. Here is a working config.
- Build the kernel with make && make modules_install as usual
- Copy the kernel image to /boot as usual.
- Create /boot/grub/menu.lst, containing:
kernel /boot/kernel root=/dev/sda1
- While optional you might want to clean up the kernel source directory, or even remove it – you’re paying by the gb and the sources and object files are large.
- Bundle it up with the instructions in the first guide, but on the ec2-bundle-vol command line add –kernel followed by a suitable kernel ID from the pdf linked above. For a 64-bit ami in the US-east region use aki‐427d952b
That’s it – upload, register, and boot it up!
I am currently maintaining two images at the moment:
Both are running stable kernel and udev, and I’ll update them periodically for a while.
On both images I have an entry in root’s ssh authorized_keys so that I can more conveniently access these instances when I’m using them. If you use this for anything other than experimentation you should remove this before creating your image. I’d host a version with and without this, but that does cost money on S3, so consider yourself warned…