FreeBSD on EC2 via defenestration

On December 13th I announced the availability of FreeBSD on EC2 t1.micro instances, and on March 22nd I announced the availability of FreeBSD on EC2 cc1.4xlarge "cluster compute" instances; but for most people, these options were either too small or much too large. Today I am happy to announce the availability of FreeBSD on EC2 m1.large and m1.xlarge "standard" instances; m2.xlarge, m2.2xlarge, and m2.4xlarge "high-memory" instances; and c1.xlarge "high-CPU" instances.

The primary factor which has been limiting FreeBSD availability on EC2 until now is FreeBSD's poor paravirtualized Xen support. FreeBSD's 32-bit paravirtualized Xen support is far from perfect; and FreeBSD doesn't have 64-bit paravirtualized Xen support at all. Aside from the recently launched "cluster compute" instances, EC2 uses paravirtualization for all UNIX instances; and at the present time, t1.micro instances are the only ones compatible with FreeBSD's paravirtualized Xen support.

EC2 Windows instances, on the other hand, are launched in HVM (Hardware Virtual Machine) mode — which FreeBSD supports very well. If we can somehow trick EC2 into launching FreeBSD the same way as it launches Windows, we can run FreeBSD on a wide range of instance types. How can we trick EC2? Take advantage of the fact that Elastic Block Store disks can be detached from EC2 instances and reattached to different instances, and replace the boot disk of a "Windows" instance with a disk containing FreeBSD. In other words, defenestrate the EC2 instance. (Note to pedants: While "defenestrate" usually means "to throw out of a window", etymologically it could equally mean "to throw windows out" — and the Oxford English Dictionary does show a recorded use in this sense dating from 1927.)

I actually tried this over a year ago without success; I'm not sure why it didn't work at that point, but a few weeks ago a little bird suggested that I should try it again, and this time it worked... modulo a slight incompatibility in the Xen block device parameter negotiation protocol which I needed to patch around. Once I had a "Windows" instance running FreeBSD, turning it into an AMI was easy: EC2 provides a "Create Image" operation which takes a running instance and bundles it — including its attached disks and metadata such as the fact that it is a "Windows" instance — into a new AMI.

There is one downside to this approach, however: Because, as far as EC2 is concerned, instances launched from the defenestrated AMI are still running Windows, they are billed at the hourly rates for Windows instances — anywhere from 24% to 71% higher than the pricing for non-Windows instances. We can hope that some day Amazon will make HVM available without the need for defenestration; but until then, FreeBSD users will be paying the Windows tax on the cloud just like we do on laptops.

Still, even with the Windows tax, I imagine "filling in the gap" between t1.micro instances and cluster compute instances will prove useful to many FreeBSD users. In the US-East region FreeBSD 8.2b-RELEASE (8.2 plus my patches) is now available for 64-bit instances as ami-c69862af; go spawn some daemons!

Posted at 2011-07-08 02:00 | Permanent link | Comments
blog comments powered by Disqus

Recent posts

Monthly Archives

Yearly Archives


RSS