Ubuntu installer destroyed laptop bootloader!

Asked by Gary Trujillo

Though my real objective is to be able to use Sun's "VirtualBox" (http://virtualbox.org/) to run Linux and Windoze simultaneously, I want to set up my laptop to be able to boot Linux without the bother/danger of repartitioning the 250 GB internal drive of my new Compaq/HP laptop. Since I didn't have enough information last night to install Ubuntu within a NTFS partition (until posting and getting answers to a question on that subject - https://answers.launchpad.net/ubuntu/+question/124819), I decided as an experiment to install Kubuntu on a new 1.5 TB USB drive, just to get some experience with the system and the installation process).

When I earlier fired up the same (10.4 DVD) installer, it looked at the internal drive and offered to wipe away everything or let me repartition the drive. After plugging in the virgin USB drive, though, and firing up the installer again, I wasn't even told anything about the internal drive, since the installer saw a completely uninitialised drive. I chose to retain 500MB that I'll use later as a backup NTFS partition, leaving 1TB for Linux use.

The installation proceeded - an ext4 filesystem was created, and system stuff copied from the DVD to the USB device. All went well until the end, when the installer said it was finished and now it's time to reboot into the new system. My assumption at that point was that I'd be able to use the BIOS to select which drive's bootloader to use, so if I want to boot into Linux, I select the USB drive as the first one to scan for a bootloader and if I want to boot into Windoze, I have the BIOS look at the internal drive first.

But no, it looks to me as if the Kubuntu loader stepped on the internal drive's bootloader, since now I only get an error message with a big long device ID that identifies a drive the loader says it can't find. I assume it's looking for the USB drive. So now I have to figure out how to restore the Windoze bootloader and get the Linux one installed onto the USB drive.

I can still use the machine, booting into Knoppix, which I installed onto a USB flash memory stick. I can mount the internal drive and see that everything still looks OK - except for the bootloader, of course, which I don't even know how to display, let alone restore.

So my question is whether anyone knows how I might be able to fix things up. Later, I'll be wanting to know whether I'd be able to get at a Linux filesystem living within an NTFS partition from within VirtualBox, and creating Reiser filesystems within encrypted LVM volumes, and other things of that sort. But, as they say, "you gotta crawl before you can walk!" :-)

I may just take the laptop and USB drive down to the store where I bought both late this afternoon and spend some time with their techies to see if they might know what to do (there's at least one of them who knows a lot about Linux - I think he's from Russia). I also want to find out if I can back up the Windoze f.s. image in such a way that it can be used to define a VM within VirtualBox - maybe I'll post something here later on that subject.

Thanks in advance for any tips!

P.S. # 1 - Since posting the above, I've been doing some research, and have come across a few resources, one of which led me o a utility called "testdisk" (http://cgsecurity.org/wiki/TestDisk), which its author claims can, among other things, restore a lost boot partition from its backup. I'm going to see if this utility might be able to help me, though I want to do some serious thinking before letting it actually do its thing, since I don't want to risk making matters any worse than they already are. Meanwhile, I remain open to suggestions. Thanks.

P.S. #2 I suppose I should anticipate the question someone might ask - "Why do you want the crufty old Win7 bootloader anyway?" and say that maybe I really don't need it, if GRUB gives me all I need, which is the ability to boot into either Windoze or Linux (assuming I could get GRUB into the boot sector of the internal drive). I just recall having had this same problem on a tower machine running Debian where I finally gave up trying to install GRUB onto a drive that had Win2K in the boot sector. I don't recall the details, but I finally opted to use the BIOS to switch between two internal drives - I had to let Windoze boot itself from the drive it was living on if I wanted to run it (which wasn't very frequently). But if I can replace the Windoze boot loader with a GRUB installation that can boot into Win7 or Linux from either the internal drive (a Linux f.s. within an NTFS f.s.) or the external USB drive, I don't really care that the original Windoze loader is gone (and I guess I could always restore it from the backup track or wherever it is using TestDisk or some similar utility).

P.S. #3 I'm starting to wonder whether my original diagnosis was correct. Using TestDisk, I see that the contents of the boot sector and the backup are the same. I'm wondering what else might be producing the error message I'm getting when I try to boot. I do know, however, that even with the USB drive unplugged, the laptop is no longer booting into Win7 - it just gives that error message. The Kubuntu installer did something to the internal drive. I suppose it could have installed GRUB to both the boot sector and the backup sector. However, I would think that with GRUB installed, I wouldn't be getting that single line message about a missing device. Hmmmm.

TestDisk 6.11.3, Data Recovery Utility, May 2009
Christophe GRENIER <email address hidden>
http://www.cgsecurity.org

Disk /dev/sda - 250 GB / 232 GiB - CHS 30402 255 63
     Partition Start End Size in sectors
 1 * HPFS - NTFS 0 32 33 25 126 37 407552 [SYSTEM]

Boot sector
Status: OK

Backup boot sector
Status: OK

Sectors are identical.

A valid NTFS Boot sector must be present in order to access
any data; even if the partition is not bootable.

P.S. #4 Here's what's in the first bit of the boot sector, as reported by "od":

0000000 353 c 220 320 274 \0 | 373 216 300 216 330 213 364 277 \0
0000020 006 271 \0 002 374 363 244 352 ` 006 \0 \0 \0 \0 \0 \0
0000040 R e c o v e r y M g r \0 X h 033
0000060 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

Ahhh. A bit further down, I find:

0000600 } 350 . \0 315 030 353 376 G R U B \0 G e
0000620 o m \0 H a r d D i s k \0 R e a
0000640 d \0 E r r o r \r \n \0 273 001 \0 264 016
0000660 315 020 254 < \0 u 364 303 367 223 203 344 \0 \0 200

so it seems the Kubuntu installer DID in fact overwrite the Win7 loader
on the internal drive. And, since TestDisk tells me that the backup sector
has the same thing in it, if I want the Windoze loader back, I guess I'll
need to find an original install disk, which didn't come with the laptop.

So now the question becomes whether I can live without that loader and
why it's not finding the USB drive when it is connected. Also involved is
how to tell GRUB how to boot into Win7. I know there's a Windoze GRUB.
Do I need it, I wonder?

P.S. #5

After changing the boot device order in the BIOS, I succeeded in booting
into Kubuntu and into Windoze. Seems that the installer wrote a copy of
GRUB into the MBR of the external drive also. When I got into Win7, it
told me about some problem in the file system that needed fixing, so I let
it go ahead and fix it. Now, however, booting into Kubuntu, if I log in to
the X desktop, the machine hangs, apparently while trying to access a
drive, which I assume is the internal one (the display that shows the disks
that comes up right after I enter the user-ID and password is active briefly,
and then the whole machine freezes - I have to hit the power switch to re-
boot.

After rebooting, I went into a terminal window and created a second user,
since at that point I thought perhaps there was some startup file in my own
user directory that was corrupt - which, of course, shouldn't be enough to
hang the kernel. But I get the same results logging in as that user, which
doesn't surprise me. I'm just wondering now whether the fix Windoze made
to its file system has confused Linux somehow. Or maybe I'm completely
wrong and there is some other reason for the hang.

I'm wondering whether there isn't someplace I can find a copy of the Win7
MBR, so I can use "dd" to restore it. I know I've done such things in the
past - just copy a fixed size file which overwrites the MBR sector and leaves
the rest of the disk intact (one needs to know just how much to copy, of
course).

If I had known I might have such problems, I would have copied the MBR
from the internal drive using Knoppix before I ever started the Ubuntu install.
I'm tempted to try reinstalling Ubuntu, but my intuition tells me that it wouldn't
do me any good to do so.

P.S. #6 One thing I forgot to mention in that last note is that I used the
command "shutdown -r now" in a shell window to reboot Linux before I
first experienced the problem. So perhaps the problem didn't start
right after I let Win7 fix its problem - I just don't recall the exact
sequence of events. But I would think that a little detail like this one
shouldn't matter. I've used "shutdown" in Debian and Knoppix with
no problems.

Sigh.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu virtualbox-ose Edit question
Assignee:
No assignee Edit question
Solved by:
delance
Solved:
Last query:
Last reply:
Revision history for this message
Best delance (olivier-delance) said :
#1

A little too long.
When you boot on disk without USB stick, what did you get ?
And what did you want to get at end ?

Revision history for this message
Gary Trujillo (gst-btlonline) said :
#2

Well, for one thing, I want an installer that warns me before overwriting the bootloader of a device other than the one onto which it's doing the install. Second, I wanted, when I posted my request for help, to find a way to restore the Windoze bootloader, if only for the principle of the thing. Since then, the laptop software spontaneously offered (good timing!) me to write a bunch of DVDs containing a recovery set, which was able to restore the bootloader. I've encountered other problems since, but I'm slowly getting closer to be able to do an installation on the internal drive (at which point, of course, the bootloader will have to get overwritten with GRUB).

Anyway, to answer the other question, if I booted without the USB stick, which contains Knoppix, or the external drive, which has a working GRUB that knows about the Windoze system on the internal drive, I got a grub error messag about not being able to find a device (as previously reported). I dunno. But I'm past that point now.

Thanks anyway.