Tuesday, May 01, 2012

Retrieve Amazon EC2 windows password

I recently was given to work with an existing Amazon EC2 AMI without having the benefit of the previous key-pair. Additionally when the AMI was created the Set Password was not enabled. This led to the problem that even though the AMI could be used to launch a Windows EC2 instance, we could not login.

To surmount this, we need to make use of an Ubuntu linux instance launched on Amazon EC2. Following steps help in recovering the password.


  1. Launch a Windows instance from the given AMI. Use your own or newly created Key-Pair.
  2. Stop the instance and detach the volume which contains the root partition. This is usually /dev/sda1. The root partition contains the setting for Set Password. (C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml)
  3. Launch a micro Ubuntu server instance. We do not need a larger instance since it is a simple operation.
  4. Attach the volume detached in step 2 to the Ubuntu instance under /dev/xvdf.
  5. Login into the Ubuntu instance via ssh or whichever way you do.
  6. Create a mount point  sudo mkdir /opt/tempm/
  7. Use fdisk to check the correct volume to mount sudo fdisk -l This will list two volumes - /dev/xvdf1 and /dev/xvdf2. Of these xvdf1 is the boot partition, and xvdf2 is the one containing the requisite file.
  8. Mount the Windows NTFS volume onto this directory using: sudo mount -t ntfs-3g /dev/xvdf2 /opt/tempm/ Take care to include the "2" in xvdf2 otherwise you will get errors.
  9. Once mounted, navigate to the configuration windows directory. cd /opt/tempm/Program\ Files/Amazon/Ec2ConfigService/Settings/
  10. Use your favorite editor to launch the config.xml file using sudo sudo vi config.xml
  11. In this file, change the tag from "Disabled" to "Enabled". Save and exit.
  12. Unmount the volume sudo umount /opt/tempm/
  13. Detach the volume from the ubuntu instance and reattach to the Windows instance. When attaching to the Windows instance take care to use the right mount point - "/dev/sda1". Otherwise the disk will not be treated as a boot partition.
  14. Start your windows instance and use "Get Windows Admin Password" to recover the password using your new key-pair.

Note: Obviously if the "Set Password" had been set correctly while creating the AMI, this problem should not have arisen. Please let me know otherwise in the comments section.

Thursday, March 29, 2012

Cassandra with Hector - Eclipse project

I have been mucking around with Cassandra to see how big data works. I am mainly a Java programmer and needed a client to use in Eclipse to connect to Cassandra. In comes Hector. There is the Cassandra tutorial. I am essentially still on the Ant system (will learn Maven someday for sure). Now it requires that I have the correct libraries in the classpath to run the examples.


List of libraries required to run the examples using Cassandra 1.0.8 and Hector 1.0.6:

  • apache-cassandra-thrift-1.0.8
  • commons-lang-2.4
  • guava-r09
  • hector-core-1.0.3
  • libthrift-0.6
  • slf4j-api-1.6.1
  • uuid-3.2.0

This isn't exhaustive. One could possibly include all the libraries in the Hector-core. Some of the jars can be found under cassandra/lib folder. Additionally, the Hector project now tracks the Cassandra versioning system. So look for an upgrade to 1.0.8 sometime soon.

This post is intended more as a collection of sources than a tutorial. Hopefully will update this into a full blown "how to" guide.

Monday, August 23, 2010

The Millenium Trilogy (Book Review)

It had been a long time since I had read fiction at any length having being busy with work and myriad such excuses. So when I had made up my mind that enough is enough, I went around, asked and looked for a good read. Given the history of my reading habits, I knew nothing short of great would get me interested. And then I found Stieg Larsson of The Millenium Trilogy fame and his lead protagonist Lisbeth Salander.

At the very outset I will admit that I have been bowled over completely by the contemporary and adult storyline, that involves themes like hacking, espionage, secret service, sex, activist journalism, and a potpourri of themes without losing the actual thread of the story.

Lisbeth Salander is one awe-inspiring woman, inherently moral and very much the sociopath in the everyday sense of the word. But she's much like John Nash, in that they share the common belief that if I can think, I can do pretty much everything. Remember that John Nash defeated schizophrenia by thinking and analyzing. Lisbeth Salander destroys the secret behind the all powerful sapo, the most clandestine of operations in the Swedish secret service. While some reviewers frown upon the use of violence by her as illegal, I like the fact that an individual is able to defend her own space when the system has not only ditched her, but also has systematically exploited her for its own needs and ends. Her individualism stands out almost in  an Ayn Rand way - remorseless and unrelenting. And it is probably the same when she bonds with people she likes and respects - complete and without inhibition.

The other main character is that of Mikael Blomkvist, an investigative journalist who lives to make that next expose that will bring down the most corrupt, whether it be humongous corporations or secret within sapo. He also lives to make love to strong women. And he does both with nuance and flair, treating them like the art that they really are.

The book left me flipping pages as fast as I my eyes could travel and my brain could process. Besides the storyline of murder, mystery and intrigue, the book trio also paints such beautiful colors and bleak shades of gray of the Swedish people, culture and countryside, that by the end you feel that you know it all. And did I add that all topics are dealt in such detail so as to leave the layman spellbound and the connoisseur impressed.

My recommendation: If you haven't read the trilogy, your should. Period. 

I am also eagerly waiting the Hollywood version of the trilogy - hopefully they pick a good team and do justice.

Saturday, August 21, 2010

Purchasing Power Parity

We have on varied and multiple occasions breathed long and vocal sighs when we hear the large dollar/pound/euro salaries and benefits that our very close and dear friends earn when they work in developed countries like USA, UK, Netherlands, Australia, etc (at least I do this purposefully on every occassion :)) What we tend to dismiss with the wave of our hand or the flick of our finger is their living expenses based on a certain minimum lifestyle in such countries. Obviously this applies to people who have stayed back for some duration like for say 4-5 years and not the other set of friends who were there on a short stay (how they behave is beyond of the scope of discussion in a blog post!) And this is where we should think of Purchasing Power Parity or more commonly known as PPP.

PPP: In simple terms it is difference in cost of a Big Mac at McDonalds in your native country vs. in the foreign country you are comparing to. Or you could say it is the cost of a meal/ movie/ party/ car/ house/ etc. in the countries you are putting in the comparison bucket. Again always look at averages across items, and across geographical regions within each country. So the coffee your NRI friend buys for $4 you can very well buy for ₹25 here - its like saying that the value of $4 is the same as the value of ₹25.

Are there any standard measures: Not really. Over the years various economists and organizations have tried to do something in this direction without much success or recognition. Although the Big Mac Index has some popularity in this matter - it was first popularized by The Economist. It essentially tracks the price of a Big Mac produced and sold across 120 countries that have a McDonald's outlet. Since this burger is a standardized product it is very loosely indicative of PPP or currency under/over valuation. Again, it is not a serious economic indicator, as in no country would probably base its economic policy on this. But it comes in handy when you want to write a post like this !

Why should I be bothered: Well, we probably wouldn't even use it in our day-to-day life unless you are economic policy advisor to the Government of India. But it helps to look at things in perspective, and realize errors in leading media articles like this on TOI today. I usually am wary of our media - half the time their content and the journalistic quality is such crap such that I cringe to pick up the morning newspaper. Some have gone so bad that their editorials come out as incoherent jingoistic babble in favor of the babus and netas. But this particular piece takes the cake pretty near the bottom. Aren't newspapers supposed to raise awareness about issues that people are concerned with ?? And not mislead the junta ??

Oh, by the way, my favorite newspaper is "Bangalore Mirror" - flawless and entertaining in their coverage of storm drains, petty theft, celebrity sightings, and your sex problems! What more can you ask for ??

Wednesday, July 21, 2010

Capitalism and Honest Living

Now that the old government has been elected anew and inducted into the Parliament, I am starting to think if all this is going to make a lot of difference to the state the people are in.

I recently was talking to a farmer who incurred an electricity bill of more than Rs. 66000 and was asked to pay up under the threat of law taking its own course with dire consequences for him. This astronomical figure was the sum total of his electricity bill for the past 7 years or so. I was pretty surprised as to why this farmer hadn't paid his bill for such a long time, when I was sure that he had been doing well for himself pretty steadily all these years. On further digging more facts were revealed. He admitted he could have easily paid the bill all these years, but he was living on the hopes that a new government would take the typical socialist stand and just write off his bill amount under some new scheme and he would save some money. But as years passed, the government did nothing of the sort in his district. Although this same government floated lots of other dole out schemes. In the meanwhile his bill kept incurring additional interest, compounded. And this was the plight of fellow farmers in his village too.

Seeing no way out, they visited some government officials and petitioned them with their plight. In the end, the district administration relented and waived off the interest amount on the bill. This farmer in the end ended up paying Rs. 40000 approx.

While the people are not inherently lax in their duty and obligation towards their country, the false hopes that the government keeps giving them makes them want to take advantage of all available such options. One such welfare scheme floated by the government is the NREGA - National Rural Employment Guarantee Scheme under which any person living in rural areas will get 100 days employment. Why is it just 100 days, why not the full 365 days ?? Is it because the government is aware that it cannot create jobs in enough quantity and is dispersing what it has to a larger multitude to keep them happy and garner more votes as it did this time around ?? Who will actually ask these rural people whether they are really satisfied with the scheme ?? Why only unskilled daily wages jobs for these people and why not skilled jobs too which are higher paying ??

On the other hand look at what capitalism does to the same category of daily wage workers. Every year millions of people migrate out of their poor villages towards the swanky towns and cities looking for a better place to work and live. The most visible example is that of the laborers in the real estate industry. I personally have worked with an NGO who teach the children of such unskilled workers. These guys toil very hard and put in a lot of physical work, that you and I won't be able to do without puking our guts out. After the initial coaxing they are very eager to send their children to schools, and that too private schools where they can interact with the teaching staff and be updated about their child's progress. One big factor for them also is that these children would typically be served a mid-day meal also. Their single aim seems to be see their child educated and with a more decent life than theirs. So why does the government school nearby not appeal to them - because it does not teach English. Its not as if they are richer than their rural cousins, but they realize that they stand a better chance at a more decent life if they work hard and not support themselves on government dole.

There are questions and then there are questions ?? Lots of cynics would say that its easy to raise questions. I disagree. It might be easy to raise questions. But it is difficult to do so in a sustained and coherent manner.