LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Reinstalled Win XP and repaired Grub, now I can't boot Linux or Windows. Please help. (https://www.linuxquestions.org/questions/linux-newbie-8/reinstalled-win-xp-and-repaired-grub-now-i-cant-boot-linux-or-windows-please-help-591403/)

MegaSvensk 10-12-2007 06:47 PM

Reinstalled Win XP and repaired Grub, now I can't boot Linux or Windows. Please help.
 
Hi,

I installed Windows XP again last night after trying Vista for a bit. Then I couldn't boot Ubuntu of course, so I did the root (hd0,1) + setup (hd0) like I've done successfully once before.
But this time something must have gone wrong, because when I try to boot Ubuntu I get this error message:
Code:

Error 17: Cannot mount selected partition
And when I try to boot Windows I get this message:
Code:

Error 12: Invalid device specified
Does anyone know how to solve this problem?

Thanks.

pixellany 10-12-2007 07:10 PM

What system were you running when you re-installed GRUB? If you were running from live CD, then the drives might not been seen the same.

If running from live CD---before running GRUB--do "fdisk -l" to see how the system sees your drives. This will determine what to put in the GRUB install commands.

It's handy to keep GRUB on a floppy for situations like this (But I don't always follow my own advice...;))

Simon Bridge 10-12-2007 07:13 PM

Perhaps your partition numbers have changed after erasing vista?
Compare fdisk -l with /boot/grub/menu.lst (presumably from a live install... so make sure it is the menu.lst on the HDD and not the one on the CD.)

MegaSvensk 10-12-2007 07:17 PM

Thanks for your reply.

I'm using an Ubuntu live CD right now.

This is my fdisk -l:
Code:

Disk /dev/sda: 300.0 GB, 300090728448 bytes
255 heads, 63 sectors/track, 36483 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              2        5738    46082452+  f  W95 Ext'd (LBA)
/dev/sda2            5739      36483  246959212+  7  HPFS/NTFS
/dev/sda5              2        3825    30716248+  7  HPFS/NTFS

Disk /dev/hdc: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hdc1  *          1      21773  174890040    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/hdc2          21774      24199    19486845  83  Linux
Partition 2 does not end on cylinder boundary.
/dev/hdc3          24200      24321      979965  82  Linux swap / Solaris
Partition 3 does not end on cylinder boundary.

Quote:

Originally Posted by Simon Bridge (Post 2922429)
Perhaps your partition numbers have changed after erasing vista?
Compare fdisk -l with /boot/grub/menu.lst (presumably from a live install... so make sure it is the menu.lst on the HDD and not the one on the CD.)

Well, this is what it used to look like so it has changed quite a bit.
Code:

Disk /dev/sda: 300,0 GB, 300090728448 byte
255 heads, 63 sectors/tracks, 36483 cylindrar
Devices = cylindrar av 16065 · 512 = 8225280 byte

    Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1        5738    46090453+  7  HPFS/NTFS
/dev/sda2            5739      36483  246959212+  7  HPFS/NTFS

Disk /dev/hdc: 200,0 GB, 200049647616 byte
255 heads, 63 sectors/tracks, 24321 cylindrar
Devices = cylindrar av 16065 · 512 = 8225280 byte

    Device Boot      Start        End      Blocks  Id  System
/dev/hdc1  *          1      21135  169758776    7  HPFS/NTFS
Partition 1 does not end on cylinder limit.
/dev/hdc2          21135      21773    5125680    c  W95 FAT32 (LBA)
Partition 2 does not end on cylinder limit.
/dev/hdc3          21774      24199    19486845  83  Linux
Partition 3 does not end on cylinder limit.
/dev/hdc4          24200      24321      979965  82  Linux swap / Solaris
Partition 4 does not end on cylinder limit.

How do I view menu.lst?

MegaSvensk 10-12-2007 07:33 PM

Do you think what's causing Windows not to boot is the fact that it was at sda1 before and now it's at sda5? Can I just change grub to boot XP at sda5? If so, how do I do it?

I did remove the FAT32 partition, so Linux has been bumped up from hdc3 to hdc2.

Maybe I just have make some edits to grub to fix this. But the question is how do I do that?

jschiwal 10-12-2007 08:40 PM

You can get into the grub interactive mode and enter the "kernel" & "initrd" lines manually. Using autocompletion makes it easy to locate the kernel and initrd file. Then enter the "boot" command to get into your regular linux installation. From there, examine the system. If the devices jive with what you used to boot with, then edit /boot/grub/menu.lst to reflect the changes and run grubinstall.

If the devices are different from what you saw earlier than edit /boot/grub/device.map. I ran into this situation on my desktop where the bios would have /dev/sda & /dev/sdb reversed. After booting I couldn't simply edit menu.lst.

MegaSvensk 10-12-2007 08:45 PM

How do I get into the "grub interactive mode"? I'm pretty much a newbie to Linux and Grub.

I tried "gedit /boot/grub/device.map," but the file came up empty.

Simon Bridge 10-12-2007 08:46 PM

Quote:

How do I view menu.lst?
cat /boot/grub/menu.lst

It looks like your partition numbers have certainly changed.
Read grub(8) and update-grub(8), but most people edit the menu.lst file by hand following the conventions already present.

sudo cp /boot/grub/menu.lst /boot/grub/menu-old.lst
sudo gedit /boot/grub/menu.lst

You'll probably only need to point the old linux root device to the correct place. Reboot then run update-grub. But you may want to edit the windows entry too. Note: you only need to edit the default linux entry and remove all others.

MegaSvensk 10-12-2007 08:49 PM

Quote:

Originally Posted by Simon Bridge (Post 2922483)
cat /boot/grub/menu.lst

I tried that command but I got "no such file or directory."

Simon Bridge 10-12-2007 09:03 PM

From the live mode?
First mount the partition that contains your normal /boot directory

- if the linux root is /dev/hdc2 then:

mount -t ext3 /dev/hdc2 /mnt
ls /mnt/boot/grub

... now you see it?
Code:

$ ls /mnt/boot/grub
default        installed-version  minix_stage1_5    xfs_stage1_5
device.map    jfs_stage1_5      reiserfs_stage1_5
e2fs_stage1_5  menu.lst          stage1
fat_stage1_5  stage2

If you chroot /mnt, the system will list everything where you are used to it. But if you confuse easy, use the grub interactive mode.

MegaSvensk 10-12-2007 09:07 PM

Yeah, I see it now. But I still don't know how to view the menu.lst

Edit:
Never mind, I figured out how to view it.

MegaSvensk 10-12-2007 09:18 PM

Do you think this will work?
Code:

title                Ubuntu, kernel 2.6.20-16-generic
root                (hd0,1)
kernel                /boot/vmlinuz-2.6.20-16-generic root=UUID=5a285e7d-4d95-412f-85b6-f3c58f06e18c ro quiet splash locale=sv_SE
initrd                /boot/initrd.img-2.6.20-16-generic
quiet
savedefault

title                Ubuntu, kernel 2.6.20-16-generic (recovery mode)
root                (hd0,1)
kernel                /boot/vmlinuz-2.6.20-16-generic root=UUID=5a285e7d-4d95-412f-85b6-f3c58f06e18c ro single
initrd                /boot/initrd.img-2.6.20-16-generic

title                Ubuntu, memtest86+
root                (hd0,1)
kernel                /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title                Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda5
title                Microsoft Windows XP Professional
root                (hd1,0)
savedefault
makeactive
map                (hd0) (hd1)
map                (hd1) (hd0)
chainloader        +1

I changed the Linux ones to where the find /boot/grub/stage1 says the root is (before it was 0,2) and I changed XP from sda1 to sda5.

MegaSvensk 10-12-2007 09:38 PM

So, I changed it and I rebooted back into the live cd and now I'm trying to run the update-grub command but I get this error:
Code:

No GRUB directory found. To create a template run 'mkdir /boot/grub' first.
To install grub, install it manually or try the 'grub-install' command. ###
Warning, grub-install is used to change your MBR.

I tried cd'ing the grub directory and then running it, but I got the same message.

Edit:
Okay, I managed to run the command but gave me an error about that it couldn't resolve something and then it changed the partition number back to the wrong ones.
Then I just decided to try and boot up without update-grub and when I tried booting linux, it worked perfectly. However, when I tried booting Windows, I got the same Error 12.

Edit again:
I tried running update-grub inside of my real Ubuntu now but it just updated it back the old, erroneous value.


Any ideas on how to get Win XP up and running again. I guess I should change the root value but to what...

MegaSvensk 10-12-2007 11:23 PM

I'm bumping this so that it won't fall off of the first page while I get a few hours of sleep before I have to go to work.

MegaSvensk 10-13-2007 05:34 AM

Okay, so I guess I'll just test root (hd1,x) till I get the right one.
Is there any way I can test the path inside of Ubuntu to see if it works without having to reboot over and over?


All times are GMT -5. The time now is 10:27 AM.