Inside an Amazon EC2 Virtual Machine

I spent a little time tonight poking around inside a virtual machine booted on the Amazon Elastic Compute Cloud web service. I knew that they used Xen for virtualization, but that’s about all. Here’s what I found.

Opteron Inside

Looking at /proc/cpuinfo, it looks like the host machine is running an AMD Opteron 2.4 GHz processor. Very nice.

Custom domU Kernel

Yes, Amazon uses their own custom-built domU Linux kernel built as a monolithic kernel image with no module support. You can put whatever kernel you want on your filesystem image; it will be ignored completely.

Here’s what uname reports:

Linux domU-xx-xx-xx-xx-xx-xx 2.6.16-xenU #1 SMP Wed Dec 20 12:45:04 SAST 2006 i686 athlon i386 GNU/Linux

/tmp can be nearly infinite

All you need to do is mount /dev/sda2 to get a freaking huge virtual disk for scratch space:

[root@domU-xx-xx-xx-xx-xx-xx ~]# mount -t ext3 /dev/sda2 /tmp
[root@domU-xx-xx-xx-xx-xx-xx ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             4.4G  2.1G  2.1G  51% /
none                  851M     0  851M   0% /dev/shm
/dev/sda2             147G  189M  140G   1% /tmp

1.8 GB of RAM Ought to be Enough for Anybody

[root@domU-xx-xx-xx-xx-xx-xx ~]# free 
             total       used       free     shared    buffers     cached
Mem:       1740944     614080    1126864          0      78224     363436
-/+ buffers/cache:     172420    1568524
Swap:      1023992          0    1023992

This particular AMI image was configured with a 1.0 GB swapfile (/var/swap), but it turns out that /dev/sda3 is available with about 1.0 GB of swap.

No Loopback Device Support

This may make some people sad.

[root@domU-xx-xx-xx-xx-xx-xx tmp]# mount -t ext2 -o loop foo bar
mount: Could not find any loop device. Maybe this kernel does not know
       about the loop device? (If so, recompile or `modprobe loop'.)

Bottom Line

You get to rent a fully functional Linux box for $0.10 an hour. If you need a whole lotta computing power and you want it cheap without having to maintain a farm of machines, then EC2 is definitely the way to go. And, if you want to build a custom Linux appliance for the job, you can get up and running by building a raw filesystem target and following Brett’s instructions.

This will become a lot easier really soon.

UPDATE: a correction about module support.

2007.02.21 · permalink