Lost grub from a dual boot system

Asked by ChrisCS

Hi

I had a dual boot system with Windows XP on my C: drive and Ubuntu 8.04LTS Desktop edition in the same hard drive(160GB). Due to a problem with Windows I had to "repair" it using the Windows installation CD and as a result of this I am now unable to boot into Ubuntu.

My problem is that I don't know how to get grub back or where to put it when I find out how to do it.

HELP

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub Edit question
Assignee:
No assignee Edit question
Solved by:
ChrisCS
Solved:
Last query:
Last reply:
Revision history for this message
Wyatt Smith (wyatt-smith) said :
#1

I am concerned that grub cannot find stage1. First lets install grub to MBR of you ubuntu disk. This will not solve your problem, but the output from this will tell us something about the condition of your system. I would not want to overwrite you MBR of your windows disk if ubuntu is working properly.

From the LiveCD, open a terminal

sudo grub
root (hd1,0)
setup (hd1)

Please tell the output of these commands (copy and paste).

If you do not get any errors. I would then make ubuntu disk the primary boot device in the bios and see if it loads properly. If it does load properly, please include the output of the following command as well.

cat /boot/grub/menu.lst

Thanks

Revision history for this message
ChrisCS (chriscro) said :
#2

Hello Wyatt,

Thanks for your reply. I think that I must have made a typo earlier when using the 'find' command in grub, or else there was some other problem. I say some other problem because when I did sudo su and then fdisk -l the program shut down. Anyway I tried the 'find' command again after re-booting and it came up with (hd1,0).

Shall I still follow your instructions:
sudo grub
root (hd1,0)
setup (hd1) ?

Chris

Revision history for this message
Wyatt Smith (wyatt-smith) said :
#3

Glad to hear that it was just a typo. Yes, please do this.

Reinstall grub

sudo grub
root (hd1,0)
setup (hd1)

Then mount you ubuntu drive

sudo mkdir /mnt/ubuntu
mount /dev/sdb1 /mnt/ubuntu

Then please post output of this command

cat /mnt/ubuntu/boot/grub/menu.lst

Thank you

Revision history for this message
ChrisCS (chriscro) said :
#4

I will do that a bit later as I have to go out for an hour or so now. Meanwhile I wonder if this is relevant to anything:-

I altered the BIOS so as to boot from the second HD and although I got the grub menu, when I selected Ubuntu it said it could not mount the partition and and wouldn't boot. When I selected Windows XP it said that the medium was in an incorrect format and wouldn't boot either.

Will be back a bit later.

Chris

Revision history for this message
ChrisCS (chriscro) said :
#5

Hello Wyatt, here is the output from the cat command:

ubuntu@ubuntu:~$ sudo grub
Probing devices to guess BIOS drives. This may take a long time.
ubuntu@ubuntu:~$ sudo mkdir /mnt/ubuntu
ubuntu@ubuntu:~$ mount /dev/sdb1 /mnt/ubuntu
mount: only root can do that
ubuntu@ubuntu:~$ sudo mount /dev/sdb1 mnt/ubuntu
mount: mount point mnt/ubuntu does not exist
ubuntu@ubuntu:~$ sudo mkdir /mnt/ubuntu
mkdir: cannot create directory `/mnt/ubuntu': File exists
ubuntu@ubuntu:~$ sudo mount /dev/sdb1 /mnt/ubuntu
ubuntu@ubuntu:~$ cat /mnt/ubuntu/boot/grup/menu.lst
cat: /mnt/ubuntu/boot/grup/menu.lst: No such file or directory
ubuntu@ubuntu:~$ cat mnt/ubuntu/boot/grub/menu.lst
cat: mnt/ubuntu/boot/grub/menu.lst: No such file or directory
ubuntu@ubuntu:~$ sudo mount /dev/sdb1/mnt/ubuntu
mount: can't find /dev/sdb1/mnt/ubuntu in /etc/fstab or /etc/mtab
ubuntu@ubuntu:~$ sudo mount /dev/sdb1 /mnt/ubuntu
mount: /dev/sdb1 already mounted or /mnt/ubuntu busy
mount: according to mtab, /dev/sdb1 is already mounted on /mnt/ubuntu
ubuntu@ubuntu:~$ sudo cat /mnt/ubuntu/boot/grub/menu.lst
# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 3

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 10

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=cea2746e-b7ee-4c9c-b0ff-860373553f92 ro

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd1,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title Ubuntu 8.04, kernel 2.6.24-19-generic
root (hd1,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=cea2746e-b7ee-4c9c-b0ff-860373553f92 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet

title Ubuntu 8.04, kernel 2.6.24-19-generic (recovery mode)
root (hd1,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=cea2746e-b7ee-4c9c-b0ff-860373553f92 ro single
initrd /boot/initrd.img-2.6.24-19-generic

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/sda1
title Microsoft Windows XP Professional
root (hd0,0)
savedefault
makeactive
chainloader +1

ubuntu@ubuntu:~$

Revision history for this message
Wyatt Smith (wyatt-smith) said :
#6

This error is expected after changing boot order. We just need to modify you grub menu.lst menu.

Now that grub is installed to ubuntu drive. Again select it primary boot device and reboot.

At the grub menu, select first item, ubuntu, and hit ´e´ to edit. Then select the root command and hit ´e´ to edit. Then change

root (h1,0) to root (hd0,0)

Hit enter, then ´b´ to boot.

When ubuntu loads up, we will edit your menu.lst, so open a terminal and type

gksudo gedit /boot/grub/menu.lst

Now find the following lines and make the edits I have indicated:
1) change groot
2) change root command is both ubuntu entries
3) change root command in windows entry
4) add the mapping commands

The edit should look like this -----------------------------------------------------------

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)

Then at the end

## ## End Default Options ##

title Ubuntu 8.04, kernel 2.6.24-19-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=cea2746e-b7ee-4c9c-b0ff-860373553f92 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet

title Ubuntu 8.04, kernel 2.6.24-19-generic (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=cea2746e-b7ee-4c9c-b0ff-860373553f92 ro single
initrd /boot/initrd.img-2.6.24-19-generic
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/sda1
title Microsoft Windows XP Professional
rootnoverify (hd1,0)
map (hd1)(hd0)
map (hd0)(hd1)
chainloader +1

Save and exit and then reboot :)

You now have a dual-boot system. Note that each MBR on contains the bootloader for the OS that is installed on its drive.

NTLoader on windows drive and
Grub on Ubuntu Drive.
With this configuration, if you ever have problems with one drive, it will not affect the other :)

Revision history for this message
ChrisCS (chriscro) said :
#7

Hello Wyatt,

I have now got a boot menu back and can now boot into Ubuntu but when I select Windows in that menu I get "Error 11: Unrecognised device string".
I have altered the BIOS so that it boots from the first HD to see if that makes any difference and can boot into Windows but there is no boot menu.

Nearly there, I think, and thank you for all your patience and hard work. Is it just a case for a bit more editing of menu.lst or might it be something else?

Chris

Revision history for this message
Wyatt Smith (wyatt-smith) said :
#8

Sorry about the typo, there is a space between the devices in the map command.

title Microsoft Windows XP Professional
rootnoverify (hd1)
map (hd0) (hd1)
map (hd1) (hd0)
chainloader +1

Glad to see you can still get into windows. That is why I preferred this configuration rather than have grub overwrite you windows MBR. That way if you ever has a problem with one drive, it won´t effect the other - kinda keeps em independent.

Revision history for this message
ChrisCS (chriscro) said :
#9

Fantastic! It all works as it should, so thank you very much for all your time and work. If you were near at hand I would be very pleased to take you out for a drink. I am in France and I suspect you are in the US

Thanks again,

Chris

Revision history for this message
sabareesh (sabareeshbc) said :
#10

Thanks