Jump to content


Photo
- - - - -

Fixing MBR to Dual-Boot


  • Please log in to reply
16 replies to this topic

#1 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 13 May 2007 - 10:54 PM

I first installed Windows Vista. I used that for a while, and liked it. Then I installed Ubuntu for dual-boot. I never went back to Vista. Then I wanted to play some games. So instead of messing around with Vista, I decided to go back to XP.
So I installed XP, planning on using it only when I wanted to play games, and keeping Ubuntu my default boot OS.
But on the XP install, it wiped the boot loader Linux installed. I'm fine with using NTLDR (XP's boot loader) as default since it's easy to edit.
What do I need to edit to make it so that I can add Ubuntu to it?
Here is what it looks like now:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP Professional" /fastdetect
multi(0)disk(0)rdisk(0)partition(3)/sbin/lilo="Ubuntu Linux" /fastdetect
As you can see, I was playing with it a little bit to try and make it so that I can choose which one boots up, but only Windows XP works. I want to make it so that they both work, and Ubuntu is default.
My googling didn't help me in this one.

Thanks.

#2 intimidat0r

intimidat0r

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 455 posts

Posted 14 May 2007 - 12:21 AM

The easiest option would be to pop in a Linux live CD and reinstall grub to your MBR. This can probably be done with your Ubuntu disc. This should work:

$ sudo grub
> root (hd0,1)
> setup (hd0)
> quit

And then reboot.

That's assuming that this is on the first hard drive on your machine (hd0; the second would be hd1, and so on).

I'm also assuming in the root line that Ubuntu mounts / to /dev/hda2. The bold number corresponds to the ,1) on that line. Change it accordingly (again, hda1 is 0, hda3 is 2, etc.)

#3 Enkil

Enkil

    SUP3R 31337 P1MP

  • Members
  • 278 posts

Posted 15 May 2007 - 07:14 AM

intimidator, you're right.
though what i did was instal linux in one drive, xp in hte other, and then vista on the 3rd.
when i installed vista it took over the boot options. my mobo has an option to boot from whichever disk i choose, and then i was able to load the grub on my main drive and add the vista install on it.

however, i had to deselect the vista drive from being hte first one that booted :| vista, like all of microsofts shit, is invasive as hell ^^

#4 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 19 May 2007 - 03:18 PM

The easiest option would be to pop in a Linux live CD and reinstall grub to your MBR. This can probably be done with your Ubuntu disc. This should work:

$ sudo grub
> root (hd0,1)
> setup (hd0)
> quit

And then reboot.

That's assuming that this is on the first hard drive on your machine (hd0; the second would be hd1, and so on).

I'm also assuming in the root line that Ubuntu mounts / to /dev/hda2. The bold number corresponds to the ,1) on that line. Change it accordingly (again, hda1 is 0, hda3 is 2, etc.)

I did that and it reinstalled grub, but now when I try to boot ubuntu it says Error 17: Could not mount the selected partition.

How do I fix this?


EDIT: I'm trying to fix it with an Ubuntu LiveCD. I need this link when I have that booted: http://www.sorgonet....ux/grubrestore/

Edited by matt, 19 May 2007 - 06:10 PM.


#5 intimidat0r

intimidat0r

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 455 posts

Posted 19 May 2007 - 08:00 PM

Did you adjust the commands I posted based on your partitioning scheme?

#6 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 20 May 2007 - 01:21 AM

Yeah, but I'm not sure what to adjust them to.

Here's a history of my hard drive.

300 Gigs, blank.
Installed windows XP to 100 gigs of it
Partitioned 200 gigs for storage space
Installed Windows Vista over the XP install
Resized storage space to 150 gigs, to make room for ubuntu
Installed Ubuntu, manually configuring partitions so I could leave some space for swap. I *think* the swap is after the ubuntu partition.


So I probably used the wrong number, and I tried fixing it but I don't know exactly what number to use.

#7 Divo

Divo

    SUP3R 31337

  • Members
  • 197 posts

Posted 20 May 2007 - 08:27 AM

Try booting with a live cd, mount your ubuntu partition, and run "grub-install" (Or something along those lines) off the mounted partition. Its probably in /sbin.

#8 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 20 May 2007 - 11:47 AM

Is there an easy way to determine which partition Ubuntu is on?

And I would imagine installing grub fresh would work best, because it still says Windows (Longhorn/Vista) when it's actually XP now.

#9 Enkil

Enkil

    SUP3R 31337 P1MP

  • Members
  • 278 posts

Posted 20 May 2007 - 12:39 PM

Is there an easy way to determine which partition Ubuntu is on?

And I would imagine installing grub fresh would work best, because it still says Windows (Longhorn/Vista) when it's actually XP now.



yes, just start a new install, and itll show you the partition master or wahtever its called.
of course, dont do the install, but take note on which hd and partition each component is ;)

#10 Alk3

Alk3

    "I Hack, therefore, I am"

  • Binrev Financier
  • 1,003 posts
  • Gender:Not Telling
  • Location:312 Chi-town

Posted 20 May 2007 - 04:22 PM

Use GRUB, and install it. The easiest way IS to follow the example previously given example. Or just google the GRUB manual, it is REALLY easy to follow. If you really do not know what your partitioning scheme is, use fdisk or cfdisk and view the table from those progs. Most Linux live CDs come with those. I use cfdisk, so:

cfdisk /dev/hdxx

(replacing the hdxx with your hard drive device)

#11 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 20 May 2007 - 07:35 PM

http://apcmag.com/54..._and_windows_xp

I need that link for when I boot back into ubuntu. So far everything has worked easily. Now to see if I can get into Ubuntu again.

EDIT: Still not working.

Following the directions, here is what I am doing in the terminal, and what it's telling me:

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

grub> root (hd0,2)

grub> setup (hd0)
 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 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,2)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

grub>


When I reboot and select Ubuntu, I get Error 17: Cannot mount selected partition

Edited by matt, 20 May 2007 - 10:36 PM.


#12 Divo

Divo

    SUP3R 31337

  • Members
  • 197 posts

Posted 21 May 2007 - 11:15 AM

Could we take a peep at your fdisk output? ie, start fdisk off a live cd or whatever and print your partition table ( press "p" ). Also, the contents of /boot/grub/menu.lst would be helpful.

Edited by Divo, 21 May 2007 - 11:40 AM.


#13 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 25 May 2007 - 01:33 PM

starting fdisk didn't work and I don't know how to print /boot/grub/menu.lst

Is there just a simple way to reinstall grub fresh and clean? I'm considering just reinstalling Ubuntu completely. I'd like to not have to do that, but this other stuff just isn't working.



EDIT: Here...

Posted Image

Edited by matt, 25 May 2007 - 01:43 PM.


#14 Alk3

Alk3

    "I Hack, therefore, I am"

  • Binrev Financier
  • 1,003 posts
  • Gender:Not Telling
  • Location:312 Chi-town

Posted 25 May 2007 - 02:03 PM

1. boot up with a linux live cd.
2. mount the root partition whre /boot/grub exists
3. change the location of where grub looks for your kernel.

The grub config file in Ubuntu is at /boot/grub/menu.lst.

SO: In the grub config file (menu.lst) change the part where it says:
root=/dev/sdaxx

To this:
root=/dev/sda3


AND Whre it says:
root		(hd0,0)

Change that to
root		(hd0,3)

If I am wrong, someone correct me. Kinda hard to say without the grub config.

#15 intimidat0r

intimidat0r

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 455 posts

Posted 25 May 2007 - 07:19 PM

Are you sure it's hd0 if he's using the sd* devices, Alk3? A little voice in the back of my mind is telling me to use sd0.

Matt:

mkdir /mnt/hdubuntu
sudo mount /dev/sda3 /mnt/hdubuntu
cat /mnt/hdubuntu/boot/grub/menu.lst
sudo umount /dev/sda3

What's the output of cat (command #3)?

#16 matt

matt

    /dev/zero > C:\WINDOWS

  • Members
  • 1,166 posts
  • Location:817

Posted 25 May 2007 - 07:31 PM

Wow, That made a lot of sense. Mounting and displaying it the way you showed.
Thanks.
Here is the output of command 3



# 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 change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default		 0

## 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=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro

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

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

## 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

## ## End Default Options ##

title		   Ubuntu, kernel 2.6.20-15-generic
root			(hd0,3)
kernel		  /boot/vmlinuz-2.6.20-15-generic root=UUID=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro quiet splash vga=791
initrd		  /boot/initrd.img-2.6.20-15-generic
quiet
savedefault

title		   Ubuntu, kernel 2.6.20-15-generic (recovery mode)
root			(hd0,3)
kernel		  /boot/vmlinuz-2.6.20-15-generic root=UUID=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro single
initrd		  /boot/initrd.img-2.6.20-15-generic

title		   Ubuntu, kernel 2.6.20-12-generic
root			(hd0,3)
kernel		  /boot/vmlinuz-2.6.20-12-generic root=UUID=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro quiet splash
initrd		  /boot/initrd.img-2.6.20-12-generic
quiet
savedefault

title		   Ubuntu, kernel 2.6.20-12-generic (recovery mode)
root			(hd0,3)
kernel		  /boot/vmlinuz-2.6.20-12-generic root=UUID=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro single
initrd		  /boot/initrd.img-2.6.20-12-generic

title		   Ubuntu, memtest86+
root			(hd0,3)
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/sda1
title		   Windows Vista/Longhorn (loader)
root			(hd0,0)
savedefault
makeactive
chainloader	 +1


#17 intimidat0r

intimidat0r

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 455 posts

Posted 26 May 2007 - 12:30 AM

Try to use this as your grub configuration file (mount the Ubuntu partition, and open menu.lst in a text editor, like Gedit. Be sure to run it as root):

$ gksu gedit /mnt/hdubuntu/boot/grub/menu.lst

menu.lst:

default		 0
timeout		 20

title		   Ubuntu, kernel 2.6.20-15-generic
root			(sd0,2)
kernel		  /boot/vmlinuz-2.6.20-15-generic root=UUID=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro quiet splash vga=791
initrd		  /boot/initrd.img-2.6.20-15-generic
quiet
savedefault

title		   Ubuntu, kernel 2.6.20-12-generic
root			(sd0,2)
kernel		  /boot/vmlinuz-2.6.20-12-generic root=UUID=91eb81bd-00d4-4a9a-a5fb-f965156385f4 ro quiet splash
initrd		  /boot/initrd.img-2.6.20-12-generic
quiet
savedefault

title		   Windows Vista/Longhorn (loader)
root			(sd0,0)
makeactive
chainloader	 +1

What I did was change all references from hd# to sd#, since you're using the sd* devices, not the hd* devices. Unfortunately, I have no experience with that, so I'm not sure if my change was correct.

I also changed the partition number from 3 to 2, because since /dev/sda1 is (sd0,0), it follows /dev/sda3 would be (sd0,2).

If it doesn't work, try changing the 3 references to sd back to hd.




BinRev is hosted by the great people at Lunarpages!