sigmapie.com

12Nov/090

Get the EC2 Instance ID for this (current) machine in Ruby

On Amazon EC2, if you are in ruby, and you want to get the current Instance ID for the machine you are running the script from, here is one way you can do it.

require 'net/http'
instance_id =  Net::HTTP.get URI.parse('http://169.254.169.254/2009-04-04/meta-data/instance-id');

we are using 2009-04-04 API there.  If you want to see if there is a more recent version, you can do this on the command line:

wget http://169.254.169.254

and replace the 2009-04-04. with whatever versions are listed.

Tagged as: , No Comments
3Jul/090

Mount the knoppix-data.img file inside Ubuntu (or any other Linux distro)

If you are like me and you left some important files on your knoppix usb key and need to get that data out, you can mount the data.img file by using the following command:

sudo mount -o loop /media/KINGSTON/KNOPPIX/knoppix-data.img  /tmp/knoppix