Grub2 corrupts windows partition

Bug #716865 reported by Wei-Yee Chan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Committed
Undecided
Unassigned

Bug Description

Binary package hint: grub2

Windows partition of dual boot machine gets corrupted whenever there is an update applied for grub2. This has happened for the fourth time or so. Affects Natty only.

Everytime this occurs, recovery has to be done with a licensed copy of Acronis True Image.

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: grub2 (not installed)
ProcVersionSignature: Ubuntu 2.6.38-2.29-generic 2.6.38-rc3
Uname: Linux 2.6.38-2-generic x86_64
Architecture: amd64
Date: Fri Feb 11 14:34:09 2011
InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Alpha amd64 (20100803.1)
ProcEnviron:
 LANGUAGE=en_HK:en
 LANG=en_HK.UTF-8
 LC_MESSAGES=en_HK.utf8
 SHELL=/bin/bash
SourcePackage: grub2

Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :
Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :

Only the boot partition gets corrupted. Other ntfs partitions do not experience the same problem.

Revision history for this message
Colin Watson (cjwatson) wrote :

This is happening because some proprietary software on your system is unwisely using the boot track to make it difficult for you to uninstall it cleanly. You should find out which and complain about this shady practice; it's poor engineering and it causes conflicts with other software. I wrote about this (from a different angle, but it's the same underlying problem) here:

  http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/debian/2010-08-28-windows-applications-making-grub2-unbootable.html

However, it should be possible for us to work around it in GRUB, and I would like to do so. Please follow these instructions:

 * Save the output of 'sudo fdisk -lu' to a file. In this output, take note of the start sector of the first partition (usually 63, but might also be 2048 on recent installations, or occasionally something else). If this is something other than 63, then replace 63 in the following items with your number.
 * Save the contents of the boot track to a file (replace /dev/sda with your disk device if it's something else): 'sudo dd if=/dev/sda of=sda.1 count=63'
 * Run 'sudo dpkg-reconfigure -phigh grub-pc', and just press Enter (accept the default) in response to all questions. This should "corrupt" the Windows partition again. Now save the new contents of the boot track to a different file: 'sudo dd if=/dev/sda of=sda.2 count=63'
 * Attach these three files to this bug (the output of 'sudo fdisk -lu', and the boot track before and after making GRUB unbootable).

You don't need to recover the whole system from backups after this; just run:

  sudo dd if=sda.1 of=/dev/sda count=63 conv=notrunc

(again replacing /dev/sda and 63 with the real values, as above). Be careful when typing this as it will be writing to the boot track of your hard disk.

Changed in grub2 (Ubuntu):
status: New → Incomplete
Revision history for this message
Colin Watson (cjwatson) wrote : Re: [Bug 716865] Re: Grub2 corrupts windows partition

Oh, and don't keep the file sda.1 around permanently on the theory that
it will always help you recover from this in the future; the boot track
might need to be changed for other reasons, and restoring a copy that
wasn't taken recently could cause problems. We need to fix this
properly.

Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :
  • sda.1 Edit (31.5 KiB, application/octet-stream)

Hi Colin, thanks for the quick response. I've attached the 3 files that you've specified.

One thing I've noted is that this problem only started occurring when I upgraded to Natty. The previous 2 versions of Ubuntu did not give me the same problem whenever grub2 was updated. In the worst case, I would only lose my Windows entry in the grub menu, which could be easily recovered by booting into Linux and running "update-grub2" in a terminal window.

http://chanweiyee.blogspot.com/2009/09/windows-missing-in-grub-2-menu-ubuntu.html

Might there have been any changes in grub2 for Natty that might have caused this problem?

Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :
  • sda.2 Edit (31.5 KiB, application/octet-stream)
Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :
Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :

Hi, Colin, just an update.

I needed to boot into Windows to play a game and realised that I couldn't, because the dd command didn't work in the recovery - the Windows partition was still corrupted.

Again, I used Acronis to recover the Windows partition.

Revision history for this message
bachanator (bachanator) wrote :

Affects me as well. Upgrading grub-pc from maverick corrupts boot sector. I can fix it with testdisk by recovering backup boot-sector or so.

Revision history for this message
billbear (ninth-9) wrote :

This is a duplicate of
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/730225

This is not because of the reason Colin said, but relates to it.
It's caused by the wrong way grub responds to the proprietary software, not the proprietary software itself.
To avoid the sectors stolen, grub mistakenly overwrites sectors of the first partition.
The dd thing Colin mentioned won't work because it only overwrites the mbr and the embedding area, the ntfs itself will still remain corrupted.

Revision history for this message
Wei-Yee Chan (chanweiyee) wrote :

In my case, chkdsk didn't work as even Windows XP couldn't recognise my partition. For chkdsk to work, a partition must first be recognised as a Windows partiton, be it NTFS, FAT16 or FAT32. My corrupted partition was recognised as a raw filesystem.

Also, I do not have FlexNet installed.

In my case, the only utility that worked to repair the partition was TestDisk (https://secure.wikimedia.org/wikipedia/en/wiki/TestDisk).

Using this utility, I recovered the MFT.

Perhaps this might offer a clue as to what is going on.

Changed in grub2 (Ubuntu):
status: Incomplete → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.