Monday, April 26, 2010

Deleted Linux partition! How to get back into Windows?

Recently one of my computers' Linux partition was deleted by mistake. As the Linux partition held the multi-boot information, it made the computer stuck at grub prompt with no way of knowing where to load the OS images from. I think that is known as grub stage 2. I was able to find grub commands and successfully booted into Windows XP. So, if Linux partition of your multi-boot system is inadvertently deleted and you are stuck at grub prompt without access to Windows cd, then try this list of commands at grub prompt

grub> root(hd0, 0)
grub>chainloader +1

Note the first command " root(hd0, x) "here x could be a different number on your system...mine worked for 0.
This booted the Windows XP on the computer. But each time the computer is restarted after this, it's stuck at grub prompt and you have to follow the same list of commands. Another search and I found and installed a very nice utility called "mbrfix". Booted Windows and ran the utility; it created the master boot record (MBR) for Windows and fixed the problem and I could reboot without any problem.

Alternatively, I have read that if you have access to Windows cd, booting from it and running command "fixmbr" also does the trick.

Monday, March 29, 2010

Wubi and Ubuntu

I was trying out Wubi installer for Ubuntu. What it does basically is install Ubuntu on a Windows file system. It creates a windows file and makes it look like a hard disk to Ubuntu i.e. a virtual hard disk. So, while Ubuntu is installing on windows file system (loopback mounting), Windows need not boot if we want to work on Ubuntu. We are using Windows file system but not booting Windows as a host. Ubuntu is running on its own.The installation creates an entry in boot.ini file so that Ubuntu can be booted up as a separate OS just like a dual-boot system. Also, the installation shows up as an installed application on Windows, so if you need to remove Ubuntu, remove it as any Windows program. This is good for newbies as it saves them from the hassles of partitioning the disk.

Another cool thing about having Ubuntu on the system is that I can use my mobile broadband that is available in modem right out of the box. No need to configure or install any extra softwares. Just go to network connections, select the provider from the list, and the Ubuntu is ready to use the usb modem. Just enable it with a click of mouse. Very neat!

Friday, February 26, 2010

A probabilistic solution to the Two Generals problem

Here is a probabilistic solution to the two General's problem; it gives a high probability of succcess if the number of messages(messengers) is kept high.

The two General's problem is a problem of synchronization between two army Generals. They have surrounded an enemy
army that is more powerful than any one of the two armies. But together the two armies outnumber the enemy and can win. The problem is that the two Generals are far enough from each other and can't communicate with each other except by sending messengers. The messengers have to move through enemy line. The messengers can either get caught or reach the other General with a message.How would the army Generals agree on a time to attack? If they don't synchronize their attack, the enemy will win. The receiver General has to send an acknowledgment back to the first General now. The acknowledgment has to be sent through a messenger. The messenger again has a possibility of getting caught by the enemy. To acknowledge the receipt of acknowledgment, a messenger has to be sent again. Thus, the cycle of acknowledgments will continue...

Let's make some assumptions before discussing a solution to this problem:


A1- Each messenger has 50% chance of reaching the other General with the message.
A2- We will expect a 99.999 % chance of agreement between the Generals as sufficient enough.
A3- Each General sends an equal number of messengers.

Now, the chance of a messenger reaching the other General is 50%; it means the chance of failure is also 50%. If a General sends N messengers, the probability that none of them will reach the other General is (0.5)^N. So, the probability that at least one of the messengers will reach the other General is 1-(0.5)^N.

So, the probability that at least one messenger from each General will reach the other General is (1 - (0.5)^N)^2. When at least one messenger from a General reaches the other General with a time to attack, and an acknowledge from the other General reach the first one the message+acknowledgment is complete and there is an agreement.

We are taking the probability of 99.999% as success.
So, (1-(0.5)^N)^2 > 0.99999
or, (1-(0.5)^N) > 0.999995 (thanks to the calculator that is present in Google search, "square root of .99999" and search)
or, 0.5^N > 0.000005
or, N = 17

So, if a General sends 17 messengers one after the other with a message, and the other General replies with 17 messengers with acknowledgment, we have a greater than 99.999% probability of an agreement on the time to attack. Increasing the number of messengers increase this probability even more.