OpenWrt Forum Archive

Topic: OpenWRT Running on Amazon EC2

The content of this topic has been archived on 2 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all,  ( i just had too much time on my hands , and nothing to do)

For those interested, even just for fun or anything, i've shared an AMI on EC2 with latest trunk as of today.

It's id is ami-e4c8c790 and it's in the EU-WEST region

Remember to add the port 23 to your security group in order to telnet the instance for the first time.

How to make your own:

Step 1) Download OpenWRT Sources
Step 2) make menuconfig, select x86, and subtarget as Xen ParavirtGuest
Step 3) go to base-files source /etc/config/network, and change proto from static to DHCP, else you won't be able to access it from the interwebs
Step 4) Go to target images, select tar.gz only (you won't need the other options for nothing), you can now save and exit, and make your build.

Create a 32mb (depending on what you built of course) file using dd:
dd if=/dev/zero of=/tmp/sf-01 bs=1M count=32

mkfs.ext4 that file

mount that file somewhere


After this is done (and assuming you already have your ec2 api and ami tools instaled and configured), untargz the root-fs to some the mountpoint of that file

Inside the extracted rootfs:


Step 1) mkdir -f boot/grub
Step 2) vi/nano/whatever boot/grub/menu.lst
Insert these contents
default 0
timeout 1
title OpenWRT
root   (hd0)
kernel /boot/vmlinuz root=/dev/xvda1 rootfstype=ext4 rootwait xencons=hvc console=tty0 console=hvc0,38400n8 noinitrd

Step 3) copy the kernel to boot/grub/vmlinuz (note the filename MUST be vmlinuz)
Step 4) umount the filesystem.

Now for the EC2 commands and stuff (again assuming you already have the EC2 cmd line utils etc installed and running, you can find lots of tutorials around

Run these commands:

ec2-bundle-image --cert $EC2_CERTIFICATE -k $EC2_PRIVATE_KEY --user $AWS_UID -i imagefile

now using the output of the previous command
ec2-upload-bundle --access-key $EC2_ACCESS_KEY --secret-key $EC2_SECRET_KEY  --bucket yourbucketname --manifest /tmp/something.manifest.xml

That will upload the AMi to your S3 Bucket.

Now that uploaded a non-ebs backed AMi (by this i mean, that if you stop/terminate the instance, you will loose all data)

Go to your AWS Console , go to EC2, AMI, Register AMi, and put the location to the manifest xml file there, and it'll register.

Launch the AMI (remember the telnet port on the security group before telling it won't work)
IMPORTANT: Please select kernel ID aki-75665e01 or IT WON'T BOOT

If it telnets, it's all OK, if not... welll welcome to my last 5 hours, terminate the instance, get system log and analyze smile

If everything is OK you can continue reading.

In order to create an EBS backed  AMi do this:

Step 1) Create a 1gb EBS volume (i guess its more than enough, and it's the minimum size ) , on the same availability zone as another linux (NOT OPENWRT )instance you already have running.

Step 2) Attach that volume to the "another linux instance", after it's attached, just mkfs.ext4 that volume (DO NOT CREATE PARTITIONS)

Step 3) Detach from that volume, and attach it to your OpenWRT instance

Step 4) Go to the OpenWRT Instance and do this:

mkdir /mnt/rootfs
mkdir /mnt/clone

mount -o bind / /mnt/rootfs
mount /dev/attachedvolumename /mnt/clone

cp -a /mnt/rootfs /mnt/clone

umount /mnt/rootfs
rm /mnt/clone/mnt/clone (or just leave it there)

umount /mnt/clone

Detach volume

Now go to your AWS Console again, and create a snapshot of this volume, after the snapshot is completed. Go to the Snapshots tab, right click on this volume snapshot, Create Image, and do the same for the kernel ID (aki-75665e01) , continue until the end (also remember the security groups again) and you're all set, you created your own EC2 EBS Backed OpenWRT AMi

Best Regards

Tiago

(Last edited by kadettgte on 5 Feb 2013, 20:38)

kadettgte,

Did you get this working? You AMI is not longer available and it seems there may be a few little instructions missing in your post.

Are you able to let me know if you definitely got this to work or am I chasing my tail on this one.

Cheers

You also mention that you must use aki-75665e01 as the Kernel ID but it is not available in the list.

Can you explain why you must use this one?

I can confirm that this does work. After much playing around i got it up and running.

Please note for ap-southeast-2 use aki-33990e09.

After much playing around i also got it up and running.

environmental management system

(Last edited by Momen63125 on 30 Apr 2013, 15:50)

I will make a proper repository with gui ssh keypars and other probable necessary stuff as soon as i can

I am trying to find these AMIs, but they seem to have been deleted.

Or where can I find them?

EC2 Micro Instance Limitations

EC2 offers a lot of advantages over many web site hosting options.  I am a bit of a control freak and like having full control over my web server.  This has advantages and disadvantages of course, meaning more work but more flexibility.  Running a WordPress blog on a micro instance can be a serious challenge.  I have fought with getting my site to have a minimum level of stability, and here are some of my notes on what helped.  Amazon offers a free EC2 micro instance for a year to new users, so it is a very attractive option for hosting a web site.

The EC2 micro instance is pretty cheap compared to the other system options that Amazon offers, but there are some caveats that may shock you after using it for a while.  There are a couple of major problems with using this option for hosting a website:

CPU Usage restrictions: If you use 100% CPU for more than a few minutes, Amazon will “steal” CPU time from the instance, meaning that they throttle your instance.  This can last (from my observations) as long as five minutes, and then you get a few seconds of 100% again, then the restrictions are back.  This will cripple your website, making it slow, and even timing-out requests.
Limited Memory: The instance is limited to 613MB of RAM, and does not have a swap partition.  If you run out of memory the system will panic and reboot.

The discussion might have continued from here.