AWS: Gaining SSH access to an EC2 instance you lost access to.

Posted on April 9th, 2013 in AWS | 4 Comments »

I had a situation where an employee created a new EC2 instance with his keypair and was out the next day. I needed access to it immediately, so this posed a problem. Here is how I gained SSH access via AWS web console: I detached the EBS drive, mounted it on another EC2 instance I did have access to, added my ssh pub key to ~ec2-user/.ssh/authorized_keys, then reattached it back to the old instance. Amazing the ideas that strike you in the event of an emergency.

As long as you have full AWS console access and some light unix chops, it should be fairly straightforward:

  1. Go to the Amazon EC2 control panel, and click “Volumes” (under Elastic Block Store). Look at the attachment information for the old EBS volume to find the EBS attached to the old EC2 instance.
  2. Detach it and attach it to an EC2 instance you have SSH access to via this web console. Keep note the path, probably /dev/sda1. You will have to reconnect it to this path later and AWS doesn’t always guess correctly. When you attach it to your other EC2 it will probably attach as /dev/sdf or something since /sda is taken by the root drive. You can see this in the EBS Volumes table under “Attachment information”. This will be something like (<instance name>):/dev/sdg
  3. Use SSH and connect to your good instance. Type
    mkdir /mnt/oldvolume and then sudo mount /dev/sdf /mnt/oldvolume (or whatever the path given in the attachment information panel was). Your files should now be available under /mnt/oldvolume.

  4. Add your pub ssh key to /home/ec2-user/authorized_keys.
  5. Unmount the volume with umount -d /dev/sdf and follow the above steps to reattach it back. You should be able to login to ec2-user now on your old box.

The best and most concise explanation of stock options and venture funding.

Posted on February 26th, 2013 in startups | No Comments »

Venture Deals was a fantastic read but was primary focused on the viewpoint of an entrepreneur getting his first investment without getting ripped off. This article, in 20 pages summarizes amazingly well what stock options are for startup employees and everything else around it.
Edit: The above link should be the most recent (3rd Edition) but the latest is always kept on David Weekly’s site:

Recover photos and other media from a corrupt disk via command line for free.

Posted on January 25th, 2013 in make life easy, productivity | No Comments »

I lost some photos when my camera jammed on the last day of my vacation. Did a little research and discovered PhotoRec (mac download), a command line utility to recover images and other media off corrupt memory card or disk drives for FREE.

Every other recovery app wants to hijack your data and charge you from $40-80 or more to recover it. Gotta love open source. Kudos to this guy Christophe Grenier who wrote it. (available for all platforms, not just Mac)

Yes Virginia, you do need to defrag your Mac.

Posted on January 24th, 2013 in mac | 12 Comments »

After coming back from vacation I found my Mac unusually slow. Previewing a photo in Finder would cause the OS to beachball for a few seconds before finally showing the photo. It made sorting through all the media (25GB of photos and videos) quite painful.

I tried everything from restarting the OS to clearing ample disk space and nothing seemed to help. 2.2 Ghz of Intel Core I7 processer and 16 GB of ram seemed powerless to a 6MB photo. I started suspecting it was a hard disk problem as seek times seemed to be the major issue.

Researching the topic, it turns out that OS X runs a cron job at 3am for various maintenance task including defragging all files over 20MB. The problem is two fold: I have hundreds of files under 20MB and I always put my computer to sleep when I’m not using it because I actually care about the environment.

From Apple’s official doc:

“If your disks are almost full, and you often modify or create large files (such as editing video, [...]), there’s a chance the disks could be fragmented. In this case, you might benefit from defragmentation, which can be performed with some third-party disk utilities.”

Followed by this gem here: “Another option is to back up your important files, erase the hard disk, then reinstall Mac OS X and your backed up files.”

I went ahead and researched the best defragger for the Mac, iDefrag. (More reviews on it here.)

iDefrag screenshot

I ran the demo first which just reviews your system and then just ended up paying the $30 to buy the software and give it a try.

iDefrag is pretty like most Mac apps and gives you a boatload of useless information. They should strip it all and just have one piece of info after analyzing your system: what percent is it fragmented. This information was probably on one of the analysis pages but I sure couldn’t find it. I set the Mac to reboot and run iDefrag overnight in it’s non-OS mode. I woke up the next morning and my computer is now as fast as the day I bought it with all my photos and videos included this time.

Conclusion: If you constantly increase and decrease the size of your hard drive with lots of little files, do any kind of video editing, and/or don’t regularly leave your machine running all night then get iDefrag. It works.

Resize the root EBS disk on an EC2 instance

Posted on January 16th, 2013 in AWS | No Comments »

Running out of space on your EC2 instance? Here’s a great writeup on resizing the root EBS disk to something beefier. It requires having installing Amazon command line tools through another EC2 instance you have running. Works great.