A few months ago, a friend of mine had an MS-Windows PC that was riddled with viruses, and he asked me to help him out with it.
So I shrunk his main MS-Windows partition and I created a partition for Ubuntu.
When Grub was installing to the MBR, it said something about Sector 32 being in use by FlexNet, but it didn't say that this was a fatal error.
After I installed Grub, I rebooted the PC, but I wasn't able to get Ubuntu to boot up. I eventually decided to explore the Sector 32 problem to see if that was the cause.
It seems a lot of people encounter this problem but I haven't seen one solution for it on the web other than to "wipe your hard disk". Total nonsense.
So I'm gonna try put together a solution in this thread. Let's take a look at the problem:
A hard disk is made up of sectors. A sector on a modern hard disk is 512 bytes. The first sector is called Sector 0, and it stores the Master Boot Record. The MBR consists of:
* 440 bytes for bootable code (such as Grub)
* 4 bytes for the disk signature
* 2 bytes of nulls
* 64 bytes for the partition table
* 2 bytes for the MBR signature
The partition table contains the list of partitions, saying what sector they start at and what sector they finish on.
You might expect the 1st partition to start at Sector 1, but actually it tends to start at Sector 63 on a lot of computers. (The 1st partition tends to start at Sector 63 because there's 63 sectors in a cylinder, and MS-DOS wanted every partition to start at a cylinder boundary). So that means there's 62 unused sectors between the MBR and the 1st partition.
(To find out where your own first partition starts, do fdisk -lu /dev/sda. On modern PC's this could be all sorts of numbers because of the way recovery partitions are laid out. By the way make sure that fdisk says that the sector size is "512 bytes"... because emm... I don't know what to say if it doesn't!).
It so happens that more than one program likes to make use of those 62 free sectors between the MBR and the 1st partition.
Grub has 440 bytes available to it in the MBR to store its bootable code, but it wants more space than that, so it uses the space between the MBR and the 1st partition. But Grub isn't the only program that wants to use that space, a thing called FlexNet does too. FlexNet is some sort of software license manager, and according to the warning issued by Grub, it likes to store data in Sector 32.
When you try to install Grub over FlexNet, Grub refuses to overwrite Sector 32 if it sees FlexNet data in it. It would be great if you could just tell Grub to overwrite Sector 32, but it provides no such facility. For me, this caused a problem and Ubuntu wouldn't boot up for me.
So what's the solution to get Grub working? You don't need to go wiping your entire hard disk, you just need to wipe the area between the MBR and the 1st partition.
EXTREME CAUTION ADVISED: Wiping the storage area between your MBR and the 1st partition is an inherently dangerous activity. Doing so may result in serious injury and even death. Programs which make use of this storage area, such as FlexNet, may cease to function. You willingly accept the serious risks involved. You accept as your own responsiblity any harm that comes about as a result of following this guide, even if the guide contains errors or oversights.
First, make a backup of the first 63 sectors of your hard disk (i.e. the MBR along with the 62 free sectors):
Code:
sudo dd if=/dev/sda of=~/first_63_sectors bs=512 count=63
Trust me, back this up. No really. Do. Back it up. Seriously. You don't want to lose your partition table. Plus it's handy to have it backed up just in case you actually need that FlexNet data in future for whatever reason.
Next, erase Sector 1 through Sector 62 (i.e the 62 free sectors):
Code:
sudo dd if=/dev/zero of=/dev/sda bs=512 count=62 seek=1
That should do it, now Sector 1 through Sector 62 should be full of zeroes. Do "grub-install" again and see what happens.
I'm not sure if FlexNet stores data in sectors other than Sector 32, but that's not a problem since we've just wiped everything between the MBR and the 1st partition.
If you want to target one individual sector to erase, then you can erase Sector 32 as follows:
Code:
sudo dd if=/dev/zero of=/dev/sda bs=512 count=1 seek=32
After I erased the FlexNet data and re-installed Grub, the PC booted up fine.
If anyone sees any error in this post then please post here ASAP -- I'd hate for someone to lose data because of an error made in this guide.