PDA

View Full Version : How to dual boot Ubuntu and Windows XP without changing the Windows MBR (use NTLDR)


oblib
October 22nd, 2005, 12:03 PM
If you do not want to use grub for your bootloading control, you can do the following. This assumes Ubuntu is already installed, and the Windows MBR is still intact. This would be the case if you are booting from a floppy, or have it set up like I do. I have Windows installed on hda1 (C:\) and Ubuntu on hdb (used to be D:\) and I used to just choose the boot drive in BIOS before booting to select Windows or Ubuntu.

The goal is to make a copy of a bootrecord that you can put on the windows drive. Use http://www.ubuntuforums.org/showthread.php?t=56723 instead if you already have a boot floppy for Ubuntu. If you don't then you can do the following, adapted from http://jaeger.morpheus.net/linux/ntldr.php.

You need to know what your root partition is. In fstab (type: cat /etc/fstab) it is the entry with / as the mount point. For me it is hdb1, so wherever I say hdb1, replace it with your root.

Get lilo from synaptic.

Run liloconfig as root:
sudo liloconfig

It will ask you some questions:

Install a partition boot record to boot Linux from /dev/hdb1? (answer yes if this is your root partition. If not, something is weird)

Use LBA32 for addressing big disks using new BIOS features ? (answer yes if your drive supports it, which is likely)

Enter the number of the bitmap: (choose a bitmap, doesn't matter)

Install a master boot record on /dev/hdb? (answer 'no' unless you want to replace grub on that drive)

Make /dev/hdb1 the active partition? (answer yes)

Then it creates /etc/lilo.conf. I had a couple of warnings about not being on the first disk in the system and the video adapter, but they are not important.

Now we need to edit lilo.conf.


sudo gedit /etc/lilo.conf


Change:

prompt
timeout=50

to

#prompt
#timeout=50

so that it won't pause. Now scroll down the the very bottom and comment out all of the images that you don't want to boot with # like above. My whole lilo.conf looked like this:
# Generated by liloconfig

# This allows booting from any partition on disks with more than 1024
# cylinders.
lba32

# Specifies the boot device
boot=/dev/hdb1

# Specifies the device that should be mounted as root.
# If the special name CURRENT is used, the root device is set to the
# device on which the root file system is currently mounted. If the root
# has been changed with -r , the respective device is used. If the
# variable ROOT is omitted, the root device setting contained in the
# kernel image is used. It can be changed with the rdev program.
root=/dev/hdb1

# Bitmap configuration for /boot/sarge.bmp
bitmap=/boot/sarge.bmp
bmp-colors=1,,0,2,,0
bmp-table=120p,173p,1,15,17
bmp-timer=254p,432p,1,0,0

# Enables map compaction:
# Tries to merge read requests for adjacent sectors into a single
# read request. This drastically reduces load time and keeps the map
# smaller. Using COMPACT is especially recommended when booting from a
# floppy disk.
# compact

# Install the specified file as the new boot sector.
# LILO supports built in boot sectory, you only need
# to specify the type, choose one from 'text', 'menu' or 'bitmap'.
# new: install=bmp old: install=/boot/boot-bmp.b
# new: install=text old: install=/boot/boot-text.b
# new: install=menu old: install=/boot/boot-menu.b or boot.b
# default: 'menu' is default, unless you have a bitmap= line
# Note: install=bmp must be used to see the bitmap menu.
# install=menu
install=bmp

# Specifies the number of _tenths_ of a second LILO should
# wait before booting the first image. LILO
# doesn't wait if DELAY is omitted or if DELAY is set to zero.
# delay=20

# Prompt to use certaing image. If prompt is specified without timeout,
# boot will not take place unless you hit RETURN
#prompt
#timeout=50

# Specifies the location of the map file. If MAP is
# omitted, a file /boot/map is used.
map=/boot/map

# Specifies the VGA text mode that should be selected when
# booting. The following values are recognized (case is ignored):
# NORMAL select normal 80x25 text mode.
# EXTENDED select 80x50 text mode. The word EXTENDED can be
# abbreviated to EXT.
# ASK stop and ask for user input (at boot time).
# <number> use the corresponding text mode. A list of available modes
# can be obtained by booting with vga=ask and pressing [Enter].
vga=normal

# These images were automagically added. You may need to edit something.

#image=/boot/vmlinuz-2.6.10-5-386
# label="Lin 2.6.10img0"
# initrd=/boot/initrd.img-2.6.10-5-386
# read-only

#image=/boot/vmlinuz-2.6.11-1-386
# label="Lin 2.6.11img1"
# initrd=/boot/initrd.img-2.6.11-1-386
# read-only

#image=/boot/vmlinuz-2.6.11-1-686
# label="Lin 2.6.11img2"
# initrd=/boot/initrd.img-2.6.11-1-686
# read-only

image=/boot/vmlinuz-2.6.12-9-386
label="Lin 2.6.12img3"
initrd=/boot/initrd.img-2.6.12-9-386
read-only

#image=/boot/memtest86+.bin
# label="Memory Test+"
# read-only

# If you have another OS on this machine (say DOS),
# you can boot if by uncommenting the following lines
# (Of course, change /dev/hda2 to wherever your DOS partition is.)
# other=/dev/hda2
# label="MS Windows"


You won't have as many images if you did a fresh Breezy install. You want the image with 2.6.12-9 if you are using the basic Breezy setup. Use 'uname -r' if you aren't sure.

Save the file and run lilo:
sudo lilo

It should return something like (after any repeated warnings):
Added Lin_2.6.12img3 *

Now you have written a good bootrecord to the root. To copy it:

sudo dd if=/dev/hdb1 of=bootsect.lnx bs=512 count=1


Once you have created bootsect.lnx, you have to get that to C:\ however you can. Email, shared drive, floppy, that's up to you.

Boot to windows and edit C:\boot.ini. This is the file that Windows looks at on boot. Add the following line:

c:\bootsect.lnx="Ubuntu Linux"

You might want to adjust the timeout to your liking, and select which will be default.

Now if you reboot to your windows drive, it should give you the option of booting Ubuntu or booting Windows. If it doesn't work, however you used to boot Ubuntu (through BIOS in my case) should still work as before.

If you ever change kernels or upgrade (like when I just upgraded to Breezy) you will need to edit your lilo.conf to reflect the kernel change, run lilo, and copy the record over to Windows again.

tvbum
November 20th, 2005, 07:31 PM
An easy way to do this is to use the bootpart utility (http://www.winimage.com/bootpart.htm).
Install this anywhere on your windows partition, but make sure to use a path with no spaces.
Install Ubuntu anywhere you like; when it asks where to install grub, make sure to not use the MBR but install in the partition where Ubuntu is.

When the install step 1 is complete, reboot; the reboot will bring you back to Windows, since there is no way to boot into Linux (rather: into grub) yet.
Open a DOS prompt and cd into the directory where you installed bootpart. Type the command "bootpart" which will give you a breakdown of partitions found. On my machine for instance this looks like:

C:\appl\bootpa26>bootpart
Boot Partition 2.60 for WinNT/2K/XP (c)1995-2005 G. Vollant (info@winimage.com)
WEB : http://www.winimage.com and http://www.winimage.com/bootpart.htm
Add partition in the Windows NT/2000/XP Multi-boot loader
Run "bootpart /?" for more information

Physical number of disk 0 : 9dc96e9e
0 : C: type=de , size= 48163 KB, Lba Pos=63
1 : C:* type=7 (HPFS/NTFS), size= 37889302 KB, Lba Pos=96390
2 : C: type=f (Win95 XInt 13 extended), size= 39294990 KB, Lba Pos=75874995
3 : C: type=7 (HPFS/NTFS), size= 9470286 KB, Lba Pos=75875058
4 : C: type=5 (Extended), size= 25093530 KB, Lba Pos=94815630
5 : C: type=83 (Linux native), size= 25093498 KB, Lba Pos=94815693
6 : C: type=5 (Extended), size= 4200997 KB, Lba Pos=145002690
7 : C: type=83 (Linux native), size= 4200966 KB, Lba Pos=145002753
8 : C: type=5 (Extended), size= 530145 KB, Lba Pos=153404685
9 : C: type=82 (Linux swap), size= 530113 KB, Lba Pos=153404748

Looking at this, I see that the first Linux native partition (nr. 5) is the one containing the bootsector I'm looking for (the other one is a data partition that I've kept smaller).
Instruct bootpart to copy the bootsector over using:

C:\appl\bootpa26>bootpart 5 ubuntu.bin Ubuntu

This will copy over the bootsector from partition 5 into a file ubuntu.bin in bootpart's install directory, and add an entry "Ubuntu" to boot.ini pointing to this file. When you choose "Ubuntu" from the NTLDR menu, you will be taken
into the grub menu. A nice side effect is that you do not have to repeat this procedure when you generate a new kernel, since grub is not written into the bootsector like lilo is.

Be sure to put the ubuntu.bin file on a path without any spaces, since spaces on the path will confuse the NT bootloader.

BLTicklemonster
November 21st, 2005, 08:49 PM
An easy way to do this is to use ...
I beg to differ, though you are technically right. His method is for people like me who have two different hard drives, and want to dual boot them, yours is for a fresh install of ubuntu. I finally got all the worms squished, and bugs mashed, I don't care to reinstall. :)


THANK YOU OBLIB~!!!

BLTicklemonster
November 21st, 2005, 09:38 PM
EEEk!!! saved boot.ini, but now it won't boot. lmao. I think I have "the ultimate boot cd" around here somewhere, I'll boot from it and see if I can fix it.

So, in all my travellings, I have yet to see a sure fire way to make a disk that is set as hd one in the linux software to want to dual boot with windows. Windows refuses to boot if it's not the first hard drive... and as such, apparently ubuntu does, too.

So if I want to dual boot, then I have to reinstall one or the other, right? I have more stuff on the windows disk that is of importance than I do the ubuntu.. but I just got ubuntu the way I want it!!!


c'est la hack, eh, mon ami?

sudogeek
November 30th, 2005, 11:37 PM
See this how to:

http://www.weblog.nohair.net/archives/000598.html

This is for multi-boot from the same disk/different partitions.

BLTicklemonster
December 3rd, 2005, 10:54 PM
Nice head.

I've since installed ubuntu again, but this time I left xp in master, and put ubuntu in slave.

It gave me a chance to write the loader to the xp drive so that I can dual boot, but windows will not boot. ubuntu does, but windows will not boot at all. Now I'm totally geeked. I came back to give ubuntu a second chance, and remembered that everyone said to put the drives in order like that, and now wham.

I can edit whatever needs to be edited from ubcd, but I am wondering, what did ubuntu put on the xp drive?

BLTicklemonster
December 3rd, 2005, 10:54 PM
No, really, I keep mine skin tight, too.

saivert
December 11th, 2005, 01:16 AM
I have put GRUB in the MBR of my disk, but I have also used the Bootpart utility to put an entry for Ubuntu in my NTLDR menu (boot.ini).
This means I can select Windows entry in GRUB and then select Ubuntu in NTLDR menu to get back to GRUB again if I change my mind (no more Ctrl-Alt-Del each time I regret).

zodder
January 10th, 2006, 08:26 PM
I know this is an old thread, but I had to kick it to the top because it was the only way I could get Ubuntu to dual boot correctly with XP. Thanks a million, dude! :)

This forum is invaluable. :)

blu.gecko
January 10th, 2006, 09:02 PM
is it possible to write grub to floppy, I installed linux 1st on my machine then my wifes xp, lost my grub.
could this be done possibly running ubuntu 5.10 live from the terminal?

my floppy is set to boot 1st then dvdrw then sata0

:confused:

Mishal
February 1st, 2006, 12:31 AM
I have installed Ubuntu and Windows in two different partitions with Linux installed after Windows.

Once Ubuntu was installed, the grub started coming up at boot offering my to choose between Ubuntu and Windows. But if I select Windows, it doesn't work. How can I change this?

livingtarget
February 1st, 2006, 02:39 AM
I've used a different method that works for me. I never see it referenced, but I use WinGrub. Meaning i've got NTLDR in the MBR, grub installed on hdb (my second disc) and WinGrub installed in windows's BOOT.ini.

Works like a charm, I boot and it will ask me to pick Windows XP(Default) or Ubuntu.

tcarthy
April 20th, 2006, 04:26 AM
I have set up my system with two hard drives, master - XP, slave - UBUNTU and modified my boot.ini to allow me to select ubuntu or XP. I now get a mount error on sellecting Ubuntu:

Uncompressing Linux... Ok, booting the kernel
Mount: Mounting /dev/hdb1 on /root failed: Invalid argument.
.
.

After a few similar error messages it drops into a command line environment.

I now get the same problem even if I boot from floppy!

Any suggestions??

missingxtension
October 2nd, 2006, 06:54 PM
Yeah wingrub works wonders without any modifications to anything but he boot.ini or extractions and best of all u dont need to have a runing linux i just copied MENU.LST from /boot/grub copied it to c:/boot/grub then just like that it booted ubuntu without extracting a bootsector or using the windows bootsec extracting utility just in case someone needs it just add this to your menu list in wingub this came from 6.06.1 of course i removed my custom kernels

# 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=/dev/sda1 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,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

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery mode) 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.15-26-386
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-26-386 root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.15-26-386
savedefault
boot

title Ubuntu, kernel 2.6.15-26-386 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-26-386 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.15-26-386
boot

title Ubuntu, kernel 2.6.15-23-386
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-23-386 root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.15-23-386
savedefault
boot

title Ubuntu, kernel 2.6.15-23-386 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-23-386 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.15-23-386
boot

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

### 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/sda3
title Windows NT/2000/XP (loader)
root (hd0,2)
savedefault
makeactive
chainloader +1



edit
use this post along with this link
http://www.skyjammer.com/files/knoppix/
and you will have a working grub that loads linux's grub

Sef
October 2nd, 2006, 07:01 PM
I have installed Ubuntu and Windows in two different partitions with Linux installed after Windows.

Once Ubuntu was installed, the grub started coming up at boot offering my to choose between Ubuntu and Windows. But if I select Windows, it doesn't work. How can I change this?

You can't just using Windows boot loader; it only boots up Windows.

Mgiacchetti
May 19th, 2008, 01:50 PM
Nice head.

I've since installed ubuntu again, but this time I left xp in master, and put ubuntu in slave.

It gave me a chance to write the loader to the xp drive so that I can dual boot, but windows will not boot. ubuntu does, but windows will not boot at all. Now I'm totally geeked. I came back to give ubuntu a second chance, and remembered that everyone said to put the drives in order like that, and now wham.

I can edit whatever needs to be edited from ubcd, but I am wondering, what did ubuntu put on the xp drive?

What happened was grub wrote over your MBR, you can run your recovery mode from winxp cd and do a fixmbr and/or fixboot, but until you install grub on the ubuntu disk(hmmm, a reinstall? maybe you can do this from live cd, i dunno havent tried), and add the capability somewhere to access that disk (like entering boot menu) you will only be able to boot windows.

dxxvi
May 23rd, 2008, 03:51 PM
I want to dual boot hardy and xp without changing the windows mbr and I don't have the xp installation cd. Then, can I do the dual boot but keep the xp mbr intact?

Regards.

lswest
May 23rd, 2008, 03:56 PM
I want to dual boot hardy and xp without changing the windows mbr and I don't have the xp installation cd. Then, can I do the dual boot but keep the xp mbr intact?

Regards.

you can use a program called mbrtool (http://www.diydatarecovery.nl/mbrtool.htm) to backup your mbr, and then just restore it after you install Ubuntu, then configure it.

or mbrfix (http://www.sysint.no/nedlasting/mbrfix.htm)