Roll your own CentOS 6.5 HVM AMI in less than 15 minutes
Update: Selinux sometimes does not install properly unless you have at least 1024MB combined memory (physical and swap).
So after attending the AWS summit 2014 in Melbourne, I was sold on the benefits it brought vs pursuing the hassle of racking hardware and configuring the low level functions. While I find that fun and interesting.. it's probably the most time consuming effort and then to compare that up to the performance you get from AWS.. it's hard to compete..sure you can get refurb hardware, but that doesn't beat the performance AWS can give you. Enough rambling..
We all know the flaws of the marketplace centos image, but the big killer was it doesn't support HVM. I want the new t2 instance types!!! Then the community third party AMIs, are riddled with random stuff I don't know what they've done.. custom repos, disabled selinux!?!?!?! I stopped there..
Lets cut the crap, here's all you need to do:
# Create a new instance # Just choose any CentOS 6 image with HVM and EBS support. I used RightImage_CentOS_6.5_x64_v13.5.2_HVM_EBS (ami-45950b7f) # Now login, RightImage seems to use root as the account mkdir /boot/centos cd /boot/centos wget http://mirror.centos.org/centos/6/os/x86_64/isolinux/vmlinuz wget http://mirror.centos.org/centos/6/os/x86_64/isolinux/initrd.img echo ' default 0 timeout 0 hiddenmenu title CentOS 6 VNC Installation root (hd0,0) kernel /boot/centos/vmlinuz vnc vncpassword=yourvncpassword ip=dhcp xen_blkfront.sda_is_xvda=1 ksdevice=eth0 ks=https://gist.githubusercontent.com/andrewklau/9c354a43976d951bdedd/raw/266f8acc3c4a09af0cde273e6046bd9fc26ca9ea/centosami.ks method=http://mirror.centos.org/centos/6/os/x86_64/ lang=en_US keymap=us initrd /boot/centos/initrd.img ' > /boot/grub/menu.lst reboot
Boom! That's it, let it go and it'll install and shutdown once it's finished. Mine took about 5 minutes, once it's done right click and press "Create Image".. that's your AMI there. A few tips, go modify the kickstart to fit your requirements, some of the key things I've got in there are all commented.
You probably also noticed the vnc and vncpassword parameter in the grub config. If you want, you can follow along with the install by connecting your vnc client to ipaddress:1 aka ipaddress:5901
I used to do these installs on my physical boxes all the time, why bother spring up that ugly java dell/ibm KVM interface when VNC looks colorful and without lag! Another thing to note, if your install seems to be taking a while.. your KS is probably borked and it's just hung. If you can ping your instance, but VNC hasn't come up yet, it's errored at a kickstart entry. I used a local VM to test my ks file first.
You can also start up a local VM and upload it as an AMI, but that's a painful process with working out all the APIs etc. I did it, and it took me a lot longer than 15 minutes. Eitherway, my new AMI just finished building so /endrant