I lost ubuntu GRUB

Asked by tribezinho

I used to have Windows XP and Ubuntu on the same hardrive, but I decided I wanted to update the microsoft OS to windows vista, so I formated windows xp partition and instaled windows vista on it, when I restarted the pc the menu to choose between operative systems was gone, now I can only access windows vista, I searched in the forums for several solutions but none worked

-------------------------------------------------------------------------------------------------
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x8b5f111a

   Device Boot Start End Blocks Id System
/dev/sda1 * 1 5491 44104704 7 HPFS/NTFS
/dev/sda2 5492 38913 268462215 5 Extended
/dev/sda5 5492 38161 262421743+ 83 Linux
/dev/sda6 38162 38913 6040408+ 82 Linux swap / Solaris

Disk /dev/sdb: 2006 MB, 2006974464 bytes
16 heads, 32 sectors/track, 7656 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Disk identifier: 0x00000000

   Device Boot Start End Blocks Id System
/dev/sdb1 16 7656 1955904 b W95 FAT32
ubuntu@ubuntu:~$ sudo gedit /boot/grub/menu.lst
ubuntu@ubuntu:~$ update grub
bash: update: command not found
ubuntu@ubuntu:~$ linux rescue root=/dev/hda5
The program 'linux' is currently not installed. You can install it by typing:
sudo apt-get install user-mode-linux
You will have to enable the component called 'universe'
bash: linux: command not found
ubuntu@ubuntu:~$ sudo gedit /boot/grub/menu.lstIf
ubuntu@ubuntu:~$ sudo grub
Probing devices to guess BIOS drives. This may take a long time.
ubuntu@ubuntu:~$

-------------------------------------------------------------------------------------------------
sudo grub

       [ Minimal BASH-like line editing is supported. For
         the first word, TAB lists possible command
         completions. Anywhere else TAB lists the possible
         completions of a device/filename. ]

grub> find /boot/grub/stage1
 (hd0,4)

grub> root (hd?,?)

Error 23: Error while parsing number

grub> setup (hd0,4)

Error 12: Invalid device requested

grub>

-------------------------------------------------------------------------------------------------

This was all the steps I tried

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub Edit question
Assignee:
No assignee Edit question
Solved by:
Tom
Solved:
Last query:
Last reply:
Revision history for this message
tribezinho (tribemx) said :
#1

I tried to use supergrub but couldn't fix the problem either, has you might noticed by now im a very new ubuntu user with no experience

Revision history for this message
tribezinho (tribemx) said :
#2

grub> find /boot/grub/stage1
 (hd0,4)

grub> root (hd0,4)

-------------------------------------------------------------------------------------------------
grub> setup (hd4)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd4)"... failed (this is not fatal)
 Running "embed /boot/grub/e2fs_stage1_5 (hd0,4)"... failed (this is not fatal)
 Running "install /boot/grub/stage1 d (hd4) /boot/grub/stage2 p /boot/grub/menu
.lst "... failed

Error 21: Selected disk does not exist

grub>
-------------------------------------------------------------------------------------------------

Revision history for this message
Best Tom (tom6) said :
#3

Wow!!

Sooo close but that final "setup" command always needs to write to the MBR of the primary MAster hard-drive unless you are setting up something clever on external disks. So,

sudo grub

root (hd0,4)

setup (hd0)

quit

should do the trick. Note that both grub and linux both use a reference to a particular partition by identifying the drive first and then the partition. Grub is designed to talk to machines rather than people so it starts counting at 0 where we start at 1. Also grub uses entirely numbers where we use a combination of letters and numbers. So in linux that partion (hd0,4) would be called sda5. There is a new system that directly references the partition itself no matter which order you re-arrange your hard-drives into. Lets say you physically swapped your 2 hard-drives over - then what had been (hd0,4) would become (hd1,4) and thus would be sdb5 in linux, however it would keep the same "uuid" number.

I hope this helps!
Good luck and regards from
Tom :)

Revision history for this message
tribezinho (tribemx) said :
#4

Helped a lot thank you! ;D

Revision history for this message
tribezinho (tribemx) said :
#5

Thanks Tom, that solved my question.

Revision history for this message
Tom (tom6) said :
#6

Brilliant! :))) Nicely done :))
Welcome to linux-land, especially the ubuntu corner :)
Congrats and regards from
Tom :)