Tuesday, December 28, 2010

FreeBSD on Amazon EC2

Thanks to Colin Percival you can try FreeBSD on Amazon EC2! According to Colin's blog more is to come, but for now you can try FreeBSD 8.2-RC1 and FreeBSD 9.0-CURRENT.

I decided to try spinning up 8.2-RC1. I used the command line tools for Ubuntu rather than the Web interface.

richard@neely:~$ sudo apt-get install ec2-api-tools

richard@neely:~$ export EC2_PRIVATE_KEY=$HOME/.ec2/pk-GO7RNG3LZTNPOUD5TH4YRCA4LFNGP5SB.pem

richard@neely:~$ export EC2_CERT=$HOME/.ec2/cert-GO7RNG3LZTNPOUD5TH4YRCA4LFNGP5SB.pem

richard@neely:~$ export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/

Now I check my security settings and authorize my IP.

richard@neely:~$ ec2-authorize default -p 22 -s [MYIP]/32
GROUP default
PERMISSION default ALLOWS tcp 22 22 FROM CIDR [MYIP]/32

richard@neely:~$ ec2-describe-group default

GROUP 162896439853 default default group

PERMISSION 162896439853 default ALLOWS all FROM USER 162896439853 GRPNAME default

PERMISSION 162896439853 default ALLOWS tcp 22 22 FROM CIDR [MYIP]/32

Next I start the 8.2-RC1 AMI.

richard@neely:~$ ec2-run-instances ami-d29b6abb -k taosecuritykey -t t1.micro

RESERVATION r-a54c17cf 162896439853 default
INSTANCE i-44bda629 ami-d29b6abb pending taosecuritykey
0 t1.micro 2010-12-28T15:21:41+0000 us-east-1b
aki-407d9529monitoring-disabled ebs

After a few seconds I check to see if it is running.
 
richard@neely:~$ ec2-describe-instances i-44bda629
RESERVATION r-a54c17cf 162896439853 default
INSTANCE i-44bda629 ami-d29b6abb ec2-50-16-108-39.compute-1.amazonaws.com
ip-10-243-6-109.ec2.internal running taosecuritykey 0 t1.micro
2010-12-28T15:21:41+0000
us-east-1b aki-407d9529 monitoring-disabled 50.16.108.39
10.243.6.109 ebs

BLOCKDEVICE /dev/sda1 vol-200caa48 2010-12-28T15:21:44.000Z
BLOCKDEVICE /dev/sdb vol-220caa4a 2010-12-28T15:21:44.000Z

Now I connect to it.

richard@neely:~$ ssh -i .ssh/taosecuritykey.pem root@ec2-50-16-108-39.compute-1.amazonaws.com

Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.

FreeBSD 8.2-RC1 (XEN) #1: Fri Dec 24 05:49:26 UTC 2010

Welcome to FreeBSD!

Before seeking technical support, please use the following resources:

o Security advisories and updated errata information for all releases are
at http://www.FreeBSD.org/releases/ - always consult the ERRATA section
for your release first as it's updated frequently.

o The Handbook and FAQ documents are at http://www.FreeBSD.org/ and,
along with the mailing lists, can be searched by going to
http://www.FreeBSD.org/search/. If the doc distribution has
been installed, they're also available formatted in /usr/share/doc.

If you still have a question or problem, please take the output of
`uname -a', along with any relevant error messages, and email it
as a question to the questions@FreeBSD.org mailing list. If you are
unfamiliar with FreeBSD's directory layout, please refer to the hier(7)
manual page. If you are not familiar with manual pages, type `man man'.

You may also use sysinstall(8) to re-enter the installation and
configuration utility. Edit /etc/motd to change this login announcement.

ip-10-243-6-109# uname -a

FreeBSD ip-10-243-6-109 8.2-RC1 FreeBSD 8.2-RC1 #1: Fri Dec 24 05:49:26 UTC 2010
root@chch.daemonology.net:/usr/obj/i386/usr/src/sys/XEN i386

ip-10-243-6-109# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/da1s1 4.8G 193M 4.3G 4% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/da0 1.0G 20M 945M 2% /boot/grub

When done I disconnect and terminate the instance. I could have also just shut down the machine within SSH if I wanted to use the instance in the future.

richard@neely:~$ ec2-terminate-instances i-44bda629
INSTANCE i-44bda629 running shutting-down

That's really cool! Many thanks to Colin for his work on this. If you want to support development on this sort of project, consider donating to the FreeBSD Foundation as Colin suggests in his blog.

No comments: