PDA

View Full Version : [ubuntu] 9.10 install GRUB 2 problem



htfntuna
November 16th, 2009, 10:03 PM
I have been using Ubuntu since 9.04 came out and it is now almost my default OS, although Win XP Pro holds that status.

I have always dual- or multibooted XP with Linux. I do not want to overwrite my MBR, so during Ubuntu install, I replace (hd0) with (fd0) in the "advanced" window where you can select where - or if - to install Grub.

This has always worked. I get Grub on a floppy, and my system doesn't know it can dual boot until I slide in the floppy and the other OSes appear.

But with Ubuntu 9.10, the install fails at the very end when it tries to write to the floppy with a fatal error.

I then installed 9.10 into VirtualBox, although they do not support this version yet. The install succeeded, and I let Grub 2 install to the first (only) virtual harddisk. When I booted into 9.10, it could not read my host's floppy when mounted, nor could it read a floppy image mounted as the a: drive.

As a test, I installed 9.10 on my 3rd harddisk and let it write Grub 2 to the MBR. I then could boot into 9.10, but I could not get it to mount or read my a: drive.

I have never had any problems with this a: drive with any other OS, including any other Ubuntu release.

I restored my MBR with fixmbr from the XP recovery console, and that is where I stand now. I can get into Windows, but not Ubuntu.

I do NOT want my MBR permanently overwritten.

Any ideas on how to proceed?

lemming465
November 18th, 2009, 04:28 AM
Personally I've always (since 1993) let my multiboot systems be controlled by the Linux side of things on the MBR, especially back when I was quintuple booting DOS 6, windows 95, OS/2, FreeBSD, and Linux. So I'm not sure what bothers you about that scenario; Linux in general and Ubuntu in particular are very good at detecting legacy Windows installs and making boot entries for them. I often rearrange the boot menu to get windows at the top, and the default Linux du jour as the second entry, with the default chosen according to which is most used (e.g. my daughters laptop defaults to windows 7, but this desktop defaults to Ubuntu 9.10).

All it takes in grub 1 to boot windows off sda1 is a paragraph like

title windows
rootnoverify (hd0,0)
chainloader +1

In grub 2, if you don't see a line starting menuentry "Microsoft Windows ...
in /boot/grub/grub.cfg, then you could add

menuentry "windows on sda1" {
set root=(hd0,1)
chainloader +1
}
to /etc/grub.d/40_custom and run sudo update-grub to regenerate /boot/grub/grub.cfg with the extra entry. Clone the 40_custom file to a lower number, say 09_custom, if you want it earlier in the boot options.

All is not lost for those determined to persevere with a windows MBR; you can boot Ubuntu from Windows too, and without having to resort to floppies or virtualbox.

1) If you only have a large Windows partition, one option is to do a WUBI install, where the Linux filesystem is a large blob loopback mounted from a NTFS file. The WUBI install process leaves the windows MBR intact, and simply adds a Linux entry to the XP (boot.ini) or Vista/7 (BCD DB) menu. Said entry will chain to a grub which is in a file, and carry on.

2) If you have a couple of separate partitions set aside for Linux, usually at least root + swap, put grub on that partition, e.g. /dev/sda2 or /dev/sda5 or /dev/sdb3 or whatever, rather than on the MBR. Assuming you are running from a live CD installer terminal window, or have switched to a text console (e.g. Alt-F2, or Ctrl-Alt-F2 if X is up), copy the alternate bootsector to a file you will be able to read from windows, e.g. on a floppy, USB drive, or FAT partition of somekind. For recent versions of Ubuntu you could write directly onto a mounted NTFS partition, too. Something like:

sudo dd if=/dev/sda2 of=/somewhere_windows_can_read/linux.mbr bs=512 count=1

For windows version older than Vista using C:\boot.ini, boot windows and do

copy \somewhere_windows_can_read\linux.mbr c:\
attrib +r +h +s C:\boot.ini
notepad c:\boot.ini
and add a line similar to C:\linux.mbr="Chain to Linux GRUB"

For Vista/windows 2008/windows 7 etc., either use EasyBCD, or follow the directions Microsoft offered. (http://port25.technet.com/archive/2006/10/13/Using-Vista_2700_s-Boot-Manager-to-Boot-Linux-and-Dual-Booting-with-BitLocker-Protection-with-TPM-Support.aspx)

Rink
November 18th, 2009, 04:44 AM
I must say, I cannot commend the way that Grub has been obfuscated in the latest Karmic release.

After all, Grub is purely for starting the machine, right?

I used to install, configure the way it starts up by briefly editing menu.lst so that the boot order was the way I wanted it, OS titles were simple ("Linux" and "XP"), and erroneously added OSs on Windows hidden partitions were removed.

Now I have to learn a new set of configuration techniques. And for what? So that my boot menu looks prettier? It's just another layer of confusion for very little return. </rant>

Anyway, to the task in hand.

Why don't you use Grub4Dos?

http://grub4dos.sourceforge.net/wiki/index.php/Grub4dos_tutorial

The following is the entry for XP (Vista is slightly different)


Add the following line at the end of boot.ini (this file is hidden):

C:\grldr="Start GRUB4DOS"
Then copy grldr to C:\, and create the GRUB4DOS configuration file at C:\menu.lst.
Next time you start windows, there is a new option "Start GRUB4DOS" which can be used to start GRUB for DOS.

That way the boot is controlled from the Windows side, which I think was what you were seeking. No need to mess around with your MBR.

Forgot to add that the file "grldr" is contained in the grub4dos zip file found here (http://sourceforge.net/projects/grub4dos/files/),

lemming465
November 18th, 2009, 06:16 AM
I cannot commend the way that Grub has been obfuscated in the latest Karmic release.

The problem was, they needed something that supported EFI bios as well as legacy BIOS, non-intel CPU's, kernel mode set graphic boots, and ext4 filesystems. Grub2 was the lesser evil. But "obfuscated" sums it up distressingly well; you have to know more about the boot process, go through an extra step, and be a little comfortable with shell scripting to hack on grub2.

oldfred
November 18th, 2009, 06:30 AM
If you installed grub2 to the MBR of your second hard drive you still can use your existing boot floppy and add a chainboot entry to the mbr of sdb.

This is my entry from a dedicated old grub partition to new grub installed in a partition (which they do not recommend):

title Ubuntu 9.10 Karmic 64 bit @ sdc7
root (hd2,6)
chainloader +1

Your entry could be like this:
title Ubuntu 9.10 Karmic 64 bit @ ?
root (hd1)
chainloader +1

Erwacht
March 5th, 2010, 01:42 AM
lemming465,

Thank you for that! I'm installing Ubuntu 9.10 on a new Dell Windows XP machine and trying to leave the Windows bootloader in charge.

To be honest, I found the technique here:
http://jamesmcdonald.id.au/gnu-linux/linux-tools/shrink-your-windows-xp-ntfs-partition-to-half-size-and-install-linux-while-keeping-the-nt-bootloader

However, it's nice to see it verified somewhere else that it should work. ...

...especially after it doesn't...

I went through the whole procedure, letting Windows boot two or three times for stability and consistency after resizing its partition, checking the C drive for consistency, then installing Ubuntu. For me, the new Linux partition is /dev/sda5, with the swap partition being /dev/sda6. I installed GRUB on /dev/sda5 rather than over the MBR. I edited the boot.ini file.

When it was done, I had an Ubuntu entry in the Windows (F8) alternative boot menu. Using it went to an upper-left-hand blinking cursor. (Neat trick, huh?)

Checking the 512 byte file I was using in C:\, it is all 00's.

Where did I go wrong?

Before posting this, I even went back and tried copying the 512 bytes from /dev/sda3 instead, being the "Extended" partition (and the only one for which the first 512 bytes aren't completely null).

Should I have a separate GRUB partition (seeing I don't)?

Thanks,

Erwacht

Erwacht
March 5th, 2010, 02:10 AM
Here's the Boot Info (just found this neat-o, effort saving thing on another thread):


Boot Info Script 0.55 dated February 15th, 2010

============================= Boot Info Summary: ==============================

=> Windows is installed in the MBR of /dev/sda
=> Windows is installed in the MBR of /dev/sdb

sda1: __________________________________________________ _______________________

File system: vfat
Boot sector type: Dell Utility: Fat16
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files/dirs: /COMMAND.COM

sda2: __________________________________________________ _______________________

File system: ntfs
Boot sector type: Windows XP
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows XP
Boot files/dirs: /boot.ini /ntldr /NTDETECT.COM

sda3: __________________________________________________ _______________________

File system: Extended Partition
Boot sector type: -
Boot sector info:

sda5: __________________________________________________ _______________________

File system: ext4
Boot sector type: -
Boot sector info:
Operating System: Ubuntu 9.10
Boot files/dirs: /boot/grub/grub.cfg /etc/fstab /boot/grub/core.img

sda6: __________________________________________________ _______________________

File system: swap
Boot sector type: -
Boot sector info:

sdb1: __________________________________________________ _______________________

File system: vfat
Boot sector type: Unknown
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files/dirs:

=========================== Drive/Partition Info: =============================

Drive: sda ___________________ __________________________________________________ ___

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xa42d04a3

Partition Boot Start End Size Id System

/dev/sda1 63 96,389 96,327 de Dell Utility
/dev/sda2 * 96,390 751,488,569 751,392,180 7 HPFS/NTFS
/dev/sda3 751,488,570 976,768,064 225,279,495 5 Extended
/dev/sda5 751,488,633 967,530,689 216,042,057 83 Linux
/dev/sda6 967,530,753 976,768,064 9,237,312 82 Linux swap / Solaris


Drive: sdb ___________________ __________________________________________________ ___

Disk /dev/sdb: 2013 MB, 2013265920 bytes
129 heads, 32 sectors/track, 952 cylinders, total 3932160 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xc3072e18

Partition Boot Start End Size Id System

/dev/sdb1 * 32 3,915,775 3,915,744 6 FAT16


blkid -c /dev/null: __________________________________________________ __________

Device UUID TYPE LABEL

/dev/loop0 squashfs
/dev/sda1 07D9-070A vfat DellUtility
/dev/sda2 62ECFD32ECFD0159 ntfs OS
/dev/sda5 d6c1c06d-842d-4a27-ad9b-685655574cce ext4
/dev/sda6 0d4a7623-c872-4ddb-9a84-bd59adf21c61 swap
/dev/sdb1 C2F8-E4F2 vfat Lexar

============================ "mount | grep ^/dev output: ===========================

Device Mount_Point Type Options

aufs / aufs (rw)
/dev/sr0 /cdrom iso9660 (rw)
/dev/loop0 /rofs squashfs (rw)
/dev/sdb1 /media/Lexar vfat (rw,nosuid,nodev,uhelper=devkit,uid=999,gid=999,sh ortname=mixed,dmask=0077,utf8=1,flush)


================================ sda2/boot.ini: ================================

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINDOW S
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
C:\ubuntu91.bin="Ubuntu 9.01 Desktop 64-bit"

=========================== sda5/boot/grub/grub.cfg: ===========================

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set d6c1c06d-842d-4a27-ad9b-685655574cce
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set d6c1c06d-842d-4a27-ad9b-685655574cce
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=d6c1c06d-842d-4a27-ad9b-685655574cce ro quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set d6c1c06d-842d-4a27-ad9b-685655574cce
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=d6c1c06d-842d-4a27-ad9b-685655574cce ro single
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda2)" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 62ecfd32ecfd0159
drivemap -s (hd0) ${root}
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

=============================== sda5/etc/fstab: ===============================

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda5 during installation
UUID=d6c1c06d-842d-4a27-ad9b-685655574cce / ext4 errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=0d4a7623-c872-4ddb-9a84-bd59adf21c61 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0

=================== sda5: Location of files loaded by Grub: ===================


387.6GB: boot/grub/core.img
387.6GB: boot/grub/grub.cfg
385.3GB: boot/initrd.img-2.6.31-14-generic
385.3GB: boot/vmlinuz-2.6.31-14-generic
385.3GB: initrd.img
385.3GB: vmlinuz
=========================== Unknown MBRs/Boot Sectors/etc =======================

Unknown BootLoader on sdb1

00000000 eb 3c 90 28 37 7a 3e 7d 49 48 43 00 02 40 02 00 |.<.(7z>}IHC..@..|
00000010 02 00 02 00 00 f8 ef 00 20 00 80 00 20 00 00 00 |........ ... ...|
00000020 e0 bf 3b 00 00 00 29 f2 e4 f8 c2 4e 4f 20 4e 41 |..;...)....NO NA|
00000030 4d 45 20 20 20 20 46 41 54 31 36 20 20 20 fa 33 |ME FAT16 .3|
00000040 c9 8e d1 bc fc 7b 16 07 bd 78 00 c5 76 00 1e 56 |.....{...x..v..V|
00000050 16 55 bf 22 05 89 7e 00 89 4e 02 b1 0b fc f3 a4 |.U."..~..N......|
00000060 06 1f bd 00 7c c6 45 fe 0f 8b 46 18 88 45 f9 38 |....|.E...F..E.8|
00000070 4e 24 7d 22 8b c1 99 e8 77 01 72 1a 83 eb 3a 66 |N$}"....w.r...:f|
00000080 a1 1c 7c 66 3b 07 8a 57 fc 75 06 80 ca 02 88 56 |..|f;..W.u.....V|
00000090 02 80 c3 10 73 ed 33 c9 8a 46 10 98 f7 66 16 03 |....s.3..F...f..|
000000a0 46 1c 13 56 1e 03 46 0e 13 d1 8b 76 11 60 89 46 |F..V..F....v.`.F|
000000b0 fc 89 56 fe b8 20 00 f7 e6 8b 5e 0b 03 c3 48 f7 |..V.. ....^...H.|
000000c0 f3 01 46 fc 11 4e fe 61 bf 00 07 e8 23 01 72 39 |..F..N.a....#.r9|
000000d0 38 2d 74 17 60 b1 0b be d8 7d f3 a6 61 74 39 4e |8-t.`....}..at9N|
000000e0 74 09 83 c7 20 3b fb 72 e7 eb dd be 7f 7d ac 98 |t... ;.r.....}..|
000000f0 03 f0 ac 84 c0 74 17 3c ff 74 09 b4 0e bb 07 00 |.....t.<.t......|
00000100 cd 10 eb ee be 82 7d eb e5 be 80 7d eb e0 98 cd |......}....}....|
00000110 16 5e 1f 66 8f 04 cd 19 be 81 7d 8b 7d 1a 8d 45 |.^.f......}.}..E|
00000120 fe 8a 4e 0d f7 e1 03 46 fc 13 56 fe b1 04 e8 c1 |..N....F..V.....|
00000130 00 72 d6 ea 00 02 70 00 b4 42 eb 2d 60 66 6a 00 |.r....p..B.-`fj.|
00000140 52 50 06 53 6a 01 6a 10 8b f4 74 ec 91 92 33 d2 |RP.Sj.j...t...3.|
00000150 f7 76 18 91 f7 76 18 42 87 ca f7 76 1a 8a f2 8a |.v...v.B...v....|
00000160 e8 c0 cc 02 0a cc b8 01 02 8a 56 24 cd 13 8d 64 |..........V$...d|
00000170 10 61 72 0a 40 75 01 42 03 5e 0b 49 75 77 c3 03 |.ar.@u.B.^.Iuw..|
00000180 18 01 27 0d 0a 49 6e 76 61 6c 69 64 20 73 79 73 |..'..Invalid sys|
00000190 74 65 6d 20 64 69 73 6b ff 0d 0a 44 69 73 6b 20 |tem disk...Disk |
000001a0 49 2f 4f 20 65 72 72 6f 72 ff 0d 0a 52 65 70 6c |I/O error...Repl|
000001b0 61 63 65 20 74 68 65 20 64 69 73 6b 2c 20 61 6e |ace the disk, an|
000001c0 64 20 74 68 65 6e 20 70 72 65 73 73 20 61 6e 79 |d then press any|
000001d0 20 6b 65 79 0d 0a 00 00 49 4f 20 20 20 20 20 20 | key....IO |
000001e0 53 59 53 4d 53 44 4f 53 20 20 20 53 59 53 7f 01 |SYSMSDOS SYS..|
000001f0 00 41 bb 00 07 80 7e 02 0e e9 40 ff 00 00 55 aa |.A....~...@...U.|
00000200