LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grub trouble (https://www.linuxquestions.org/questions/linux-newbie-8/grub-trouble-464724/)

Geminias 07-16-2006 11:27 PM

Grub trouble
 
Sorry to have to ask this here, but I just installed fc5 and in grub i ran setup (hd0,0) to put grub on the first partition. The reason I included that information is because I'm not sure what needs to be done in order to configure grub to boot windows xp that was on the first partition. I'm quite certain setup (hd0,0) replaced windows bootloader with grub on the mbr.

here's my grub.conf file.

Code:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd1,1)
#          kernel /boot/vmlinuz-version ro root=/dev/sda2
#          initrd /boot/initrd-version.img
#boot=/dev/sda2
default=0
timeout=5
splashimage=(hd1,1)/boot/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.17-1.2157_FC5)
        root (hd0,1)
        kernel /boot/vmlinuz-2.6.17-1.2157_FC5 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.17-1.2157_FC5.img

title Windows
        map (hd0,0) (hd0,2)
        map (hd0,2) (hd0,0)
        rootnoverify (hd0,0)
        makeactive
        chainloader +1       

title Windows XP
        map (hd0,0) (hd0,1)
        map (hd0,1) (hd0,0)
        rootnoverify (hd0,0)
        makeactive
        chainloader +1

Neither of those titles for windows work... THe error i get is nothing. WHat happens is it flickers the screen and then begins the count down to boot linux.

syg00 07-16-2006 11:47 PM

Quote:

Originally Posted by Geminias
... I just installed fc5 and in grub i ran setup (hd0,0) to put grub on the first partition. The reason I included that information is because I'm not sure what needs to be done in order to configure grub to boot windows xp that was on the first partition. I'm quite certain setup (hd0,0) replaced windows bootloader with grub on the mbr.

That wasn't a very good idea. What you did was override the boot sector record in the partition. Windows will not tolerate that.
It's possible you can recover this by booting the XP CD and selecting recovery console, then run fixboot. I wouldn't be surprised if you need to run fixmbr first, but I haven't tried it, so I'm guessing. Various posters have reported no success, and had to resort to full re-install of XP. After that you'll need to restore grub to the MBR - this time use "setup (hd0)"

After that, remove the "map" lines from grub.conf, and you should be good to go.
FC5 should have installed grub correctly itself I would have thought.

Geminias 07-16-2006 11:53 PM

Thanks syg00, I didn't realize the difference between setup (hd0,0) and (hd0). I will fixmbr with windows and let you know how it went.


Quote:

Originally Posted by Syg00
FC5 should have installed grub correctly itself I would have thought.

It's Linux, what do you expect? Actually apart from the fact that the graphical installation turned my monitor into a messy electrical disturbance it also didn't even show my windows xp installation in disk druid. Although I dont know if it even was disk druid since I had to install it in text mode.

Geminias 07-17-2006 12:40 AM

Yeah thanks for that wonderful advice. fixboot managed to completely destroy the partition tables so now I can't even get into linux recovery cause it doesnt detect that linux is on a partition...

ugh.

syg00 07-17-2006 01:28 AM

Just trying to help - note I said "It's possible ...".

Regardless, let's see if we can fix it. I'd be surprised if fixboot trashed the partition table - I suspect you're misinterpreting the error. Try booting Knoppix or somesuch - I'd expect the partitions to be o.k.
Only thing I can think of is that you had the FC partition marked as bootable, and the fixboot used that as an indicator of which partition it needed to recover. So it went ahead and overwrote your Linux boot sector record.
Going from bad to worse.
I would think you could boot the FC CD1 into recovery mode, and recover from there, but I haven't used FC at all, so you'll need to look for yourself.

Geminias 07-17-2006 07:17 AM

The partitions are still there, yes, but like i said the partition table is damaged so it doesn't know that it has a fedora partition therefore recovery cannot be used. I've been for the past 6 hours searching for a partition table recoverer but every time I think I found one it ends up having some limitation that makes it unable to do it. The closest I got was with an app called testdisk which did the job partially but the reason it failed was because it was limited to a 128gb hard drive and mine is 250 so it was unable to salvage the linux partition. but it did salvage grub somehow only i can't do anything with grub because technically it has nothing to boot. This just completely sucks that is all I know.

muha 07-17-2006 07:52 AM

Maybe the ultimate boot cd could help with the partition table: http://www.ultimatebootcd.com/
Good luck anyways!

michapma 07-17-2006 08:15 AM

I know this isn't what you want to hear right now, but this is why it's a good idea to backup the MBR and partition table before such operations. It's relatively simple to do once you have the knowledge, and because they take up such little space, you can write them as an image file to floppy or, if like me you don't trust floppies, CD, USB stick, a webhost, etc. Then it's a simple matter to restore your MBR and partition table instead of all this headache. You can do this with a number of programs, or if you understand how you can simply use the dd command.

I currently can't boot XP using Grub because XP wasn't on a primary partition. I'm not sure this is the problem you had though. For the time being it doesn't appear to matter.

Quote:

Yeah thanks for that wonderful advice. fixboot managed to completely destroy the partition tables so now I can't even get into linux recovery cause it doesnt detect that linux is on a partition...
It's Windows, what do you expect? Sorry, couldn't resist the cheap shot. ;)

As syg00 hinted, how are you sure that your partition table is damaged? I think it would be wise to know this for sure. How are you running your forensic programs such as Testdisk? I take you are using a live CD like Knoppix? If so, what is the output of fdisk -l? If fdisk is showing you partitions, then your partition table is fine. If instead you are running your forensic programs from Windows, then I'd assume your partition table is not kaputt.

Has Testdisk or another program you've used may have modified the partition table?

I'm still not sure whether you are saying the Windows XP CD cannot be used to recover your XP installation. Is Windows working? If it is or can be recovered, and probably it can, at this stage it may be easiest to forget about your current Linux installation and just recover XP. Once that's working, you can then backup your MBR and partition table, and try installing Linux again.




By the way, according to the Testdisk site:
Quote:

IDE LBA28 adressing is limited to 128GB HD.
IDE LBA48 adressing is limited to 131072 TB.
PC/Intel MBR partition table is limited to 2TB.
If your disk is larger than 128GB, are you sure that LBA28 addressing is being used? Someone more knowledgeable about LBA will educate me, but that doesn't make sense to me.
Quote:

Originally Posted by Wikipedia
LBA addresses in ATA can be 28-bit or 48-bit (introduced in ATA-6) wide, which results in a disk size limit of 128 GiB and 128 PiB, respectively, assuming the common 512 bytes per sector.


michapma 07-17-2006 08:22 AM

Quote:

Originally Posted by muha
Maybe the ultimate boot cd could help with the partition table: http://www.ultimatebootcd.com/
Good luck anyways!

Yes, this is a great resource. It has several partition tools, such as Active@ Partition Recovery, which looks useful in this situation. It's described as being able to restore deleted FAT and NTFS partitions, and you can also use it to backup and restore the MBR and partition table, which you will definitely want to do anyway as soon as you have a running system again.

I forgot to mention before, but you need to backup the MBR and partition table each time you make partition or boot changes.

Geminias 07-17-2006 04:31 PM

I'll try the ultimate boot cd, thanks.

Concerning other questions: the partition table is damaged because i get this error when the computer starts: "invalid partition table" And absolutely nothing will boot off the disk.

I didn't know that i should back up my partition table because I never had to deal with anything like this before. In fact I didn't even know what I was doing.

EDIT: Ultimate Boot CD says that it includes Active@ partition recovery. I've tried the demo version and this software was successful up to the part where i couldn't write to disk since it was demo. Is the one on Ultimate Boot just a demo? I can't see how it would be the commercial...

michapma 07-18-2006 05:13 AM

Quote:

Originally Posted by Geminias
Concerning other questions: the partition table is damaged because i get this error when the computer starts: "invalid partition table" And absolutely nothing will boot off the disk.

I'm not sure whether the BIOS is providing this message, or whatever boot loader is currently there (possibly NTLDR?). Either way, that information could be a best-guess error message and totally wrong. I would definitely investigate first.

Quote:

I didn't know that i should back up my partition table because I never had to deal with anything like this before. In fact I didn't even know what I was doing.
And why should you have? Most computer users have no idea that such things even exist. When a user starts multi-booting, it is best to become aware of such things exactly because of the kind of trouble you're having now. It's not your fault, just your problem. :(


About the Ultimate Boot CD, and I hope you read this in time, because I should have mentioned: Make sure to get the version of Ultimate Bood CD (UBCD) with Insert, which is based on Knoppix. This means downloading the full version, as opposed to the basic version. It's worth the extra 64 MB of download because (despite being for the "advanced user") you can then also use UBCD to boot Insert Linux from the CD, without installing to hard-drive. If you like, you might also try out Knoppix straight away, although it is a bigger download and is more of a "try out Linux" type of deal.

I don't seem to have explained live CD concept so far, so here goes. The advantage of these live CDs (like UBCD full and Knoppix) is that they allow you to easily run a complete operating system without using the hard-drive. You can then use them to investigate and make changes to your machine, including such things as restoring partition tables.

Note that I am no expert and can only tell you my thoughts on what to do. Just trying to help.

To boot with UBCD, you just need to put it in your CD drive and start the machine. If it doesn't boot from CD, you may need to open your BIOS to enable booting from CD. What happens with UBCD is that it brings up a menu. You can then choose whether to start using tools or to load Insert Linux.

In your case, the first thing I think you should do is to start Insert Linux. It uses Fluxbox as a window manager, which you probably are not familiar with. No worries, you can right-click on the desktop and look for a terminal window app. Look under XShell for Xterm for example, or Apps > Shells for Bash or Sh.

Once you have a terminal window, switch to superuser by entering the command "su". You won't need a password, since this is a live CD session and not a permanent Linux installation. Now type
Code:

fdisk -l
The -l (lowercase L) switch tells it to print out the partition information to the screen. If it shows you a list of your partitions or even just some of your partitions, then your partition table is likely not screwed after all.

If you don't like fdisk or don't understand it, you can try running Qtparted, which is a graphical interface to the program parted. (It should run if you just type in qtparted in your terminal window and hit Enter.) Be careful though not to actually use the program to partition until you understand what you're doing. All you're looking for is to see whether the partitions show up.

We can be much more specific than that though, if needed. If the above two methods don't help you, we can take a look directly at your partition table. To do that, from the terminal window as superuser type in (don't type the #, it just means you're superuser):
Code:

# sfdisk -d /dev/hda
I write /dev/hda because I assume that you have a single IDE hard-drive and not, for example, a SCSI hard-drive. (The "hd" part means IDE, and "a" would be the first drive: with mulitple drives you have hda, hdb, hdc, etc., including IDE CD-ROM drives.) Here's what it looks like on my Linux box at work:
Code:

# sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=      63, size=  3919797, Id=83, bootable
/dev/sda2 : start=  3919860, size=  1959930, Id=82
/dev/sda3 : start=  5879790, size= 29350755, Id= 5
/dev/sda4 : start=        0, size=        0, Id= 0
/dev/sda5 : start=  5879853, size=  9767457, Id=83
/dev/sda6 : start= 15647373, size=  7823592, Id=83
/dev/sda7 : start= 23471028, size=  3919797, Id=83
/dev/sda8 : start= 27390888, size=  3919797, Id=83
/dev/sda9 : start= 31310748, size=  3919797, Id=83

You can see that for each partition on the drive (sd means it's a SCSI drive, btw), the output lists the starting sector plus the size in sectors, an Id and a flag for which partition is bootable. The Id tells you what kind of filesystem the partition has: in this case, Id=83 means ext2 and Id=82 means swap. Id=07 would be an NTFS partition.

If you get this output, then your partition table is indeed intact. Let us know how this looks. The more explicit the info, the better, especially if you get warnings, errors, or garbage.

To quote the Red Hat post where I got this:
Quote:

Try this command by itself to see your partition table as it is very safe. You will want to check to check for warnings in the output.... Output containing a warning may look like the example below:
Code:

$ sfdisk -d /dev/hda
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
# partition table of /dev/hda
unit: sectors

/dev/hda1 : start=      63, size= 16771797, Id= 7, bootable
/dev/hda2 : start= 16771860, size=217632555, Id= f
/dev/hda3 : start=        0, size=        0, Id= 0
/dev/hda4 : start=        0, size=        0, Id= 0
/dev/hda5 : start= 16771923, size=104856192, Id= 7
/dev/hda6 : start=121628178, size=112776237, Id= 7



If you are now convinced that the partition table is hosed though, then I would reboot and try using the partition tools from the UBCD startup screen. (To reboot, right-click the Fluxbox desktop and select Exit, or if you can't figure out how to restart it should be safe to just press your reset button since the hard-disks shouldn't be mounted.)

Quote:

EDIT: Ultimate Boot CD says that it includes Active@ partition recovery. I've tried the demo version and this software was successful up to the part where i couldn't write to disk since it was demo. Is the one on Ultimate Boot just a demo? I can't see how it would be the commercial...
About Active@ Partition: The Ultimate Boot CD only uses software that is free to distribute. In the case of Active@ Partition, this will mean only the demo version, which is too bad. :( Hopefully you won't even need it, hopefully only your MBR is wrecked.

But if you do still need such a tool, let's see what the Ultimate Boot CD has to offer. Here is a list of tools on the UBCD that I found will recover a partition table:
- Active@ Partition (demo, need to buy to restore)
- TestDisk (free, though you've already tried it)

A couple of other notes:
DIY Datarecovery DiskPatch; this is listed on UBCD as MBRtool, which is freeware from DIY. MBRtool won't recover your partition table, but their DiskPatch software will. It also has a demo, which you can use to create a support logfile to send to their staff. Of course this is also payware -- the non-pro version costs $30, compared to Advanced@ Partition for 30 Euros.

On the same page hosting MBRWork there is a utility called Partinfo that you can use it to view your partition table, although the way described above with sfdisk above does this already.

Furthermore, it looks like DIY Datarecovery has some good information. This is more like expert advice, even if their products are not free.

General procedures for data recovery:
http://www.diydatarecovery.nl/forum/viewtopic.php?t=15
Info on the MBR and partition tables:
http://www.diydatarecovery.nl/mbr.htm


Summary:
You should figure out whether your partition table is okay. If it is, you just need to fix your MBR. If it is not, it looks to me that to restore it you have the choice between freeware and payware. For freeware, try TestDisk again and get as much help with it as possible. For payware, there are two versions: Active@ Partition and DIY DiskPatch, both of which cost roughly $30. Of course, there is always the abortive approach, which is to reinstall Windows -- but you are likely to lose any and all valuable data already on your drive if you do this.

I would consider giving TestDisk another, closer look. (I just used its sister program PhotoRec, to recover some valuable files from a partition I borked at the end of a 200GB drive.) There is a list of live CDs that it appears on.


Outlook
If, at the end of all these trials, you cannot recover your partition table, which I consider unlikely, and you have valuable data on the drive that you want to keep (say on your Windows partition), all is not lost. It is still possible to recover the data. But one step at a time.


If none of this helps you, maybe it will help some poor soul down the road, that's the great thing about searchable forums. :)


All times are GMT -5. The time now is 04:23 PM.