LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-21-2009, 12:44 AM   #1
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Rep: Reputation: 34
Question how can a boot sector be repaired to then allow grub to install for chainload booting


I need to know how can a boot sector be repaired to then allow grub to be installed, and boot by chainload. This is for a Ubuntu 9.04 new install on the first logical partition inside the extended partition on a SATA external hard drive, (connected by eSATA). I boot multiple systems from a main grub on the internal IDE drive, including some Linux such as Ubuntu on the external hard drive by the normal method with root, kernel, and the initrd lines added into the /boot/grub/menu.lst file. But since I do have the other Linux installs with grub onto their root partitions, I do like to be able to chainload to some as well. The error message from grub when a boot attempt is made by chainload is; "Invalid device requested", error 12, or just a dark screen with a cursor. And when I try to install grub to that boot sector from a grub prompt at the main grub boot loader screen, it says stage 1.5 fails, but stages 1 and 2 succeed. Then when I boot into the Ubuntu 9.04, and try a grub install from terminal as sudo root, it gives error 17, "cannot mount partition". So is there a command which will fix corrupt boot sectors ?
 
Old 09-21-2009, 05:42 AM   #2
Larry Webb
LQ Veteran
 
Registered: Jul 2006
Location: Crystal Beach, Texas
Distribution: Suse for mail +
Posts: 5,100
Blog Entries: 7

Rep: Reputation: 229Reputation: 229Reputation: 229
From any linux distro that you can get to boot from terminal as root please post the results of 'fdisk -l'.
 
Old 09-28-2009, 03:19 PM   #3
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Post

fdisk -l drive partitions from Ubuntu 8.04, on 9-28-09;

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x44fdfe06

Device Boot Start End Blocks Id System
/dev/sda1 1 7310 58717543+ c W95 FAT32 (LBA)
/dev/sda2 * 7311 9529 17824117+ 83 Linux
/dev/sda3 9530 11749 17832150 83 Linux
/dev/sda4 11750 60801 394010190 5 Extended
/dev/sda5 11750 13838 16779861 83 Linux
/dev/sda6 13839 14099 2096451 82 Linux swap / Solaris
/dev/sda7 14100 15927 14683378+ 83 Linux
/dev/sda8 15928 17885 15727603+ 83 Linux
/dev/sda9 17886 19843 15727603+ 83 Linux
/dev/sda10 19844 23759 31455238+ c W95 FAT32 (LBA)
/dev/sda11 23760 25717 15727603+ 83 Linux
/dev/sda12 25718 60801 281812198+ 83 Linux

Disk /dev/sdb: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x89518951

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 7833 62918541 7 HPFS/NTFS
/dev/sdb2 7834 10444 20972857+ 83 Linux
/dev/sdb3 10445 12402 15727635 83 Linux
/dev/sdb4 12403 24321 95739367+ 5 Extended
/dev/sdb5 12403 12663 2096451 82 Linux swap / Solaris
/dev/sdb6 12664 14621 15727603+ 83 Linux
/dev/sdb7 14622 16580 15735636 83 Linux
/dev/sdb8 18147 19974 14683378+ 83 Linux
/dev/sdb9 19975 24321 34917246 b W95 FAT32
/dev/sdb10 16581 18146 12578863+ 83 Linux

Partition table entries are not in disk order
 
Old 09-28-2009, 06:32 PM   #4
Larry Webb
LQ Veteran
 
Registered: Jul 2006
Location: Crystal Beach, Texas
Distribution: Suse for mail +
Posts: 5,100
Blog Entries: 7

Rep: Reputation: 229Reputation: 229Reputation: 229
The first logical partition sdb5 is a swap partition. Try installing grub to sdb6 then change your menu,lst to chainload
(hd1,5).
 
Old 09-29-2009, 02:54 PM   #5
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Smile

The /dev/sdb 200 GB is a internal IDE drive, and that sda 500 GB drive is my eSATA connected external drive, which has Ubuntu 9.04 on sda5 and is the parttion boot sector I have not been able to fully install grub to. On that external SATA drive; sda1 is a fat32 storage, and sda2 is PCLinux installed with it's grub on it's root, which does chainload from the main grub on the internal sdb where windows XP is installed also. Within the extended partition can there be unallocated space, or should there be only formatted partitions inside the extended, and have any unused space be outside of the extended partition ? Thanks for the help.
 
Old 09-29-2009, 03:09 PM   #6
Larry Webb
LQ Veteran
 
Registered: Jul 2006
Location: Crystal Beach, Texas
Distribution: Suse for mail +
Posts: 5,100
Blog Entries: 7

Rep: Reputation: 229Reputation: 229Reputation: 229
First you should not have to partition the extended partition, but it will be unusable space.

I do not understand what exactly you want to boot.

Which hd do you want to boot from and what partition?
 
Old 10-02-2009, 03:26 PM   #7
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Thumbs up

All my operating systems boot fine now from my main grub on the internal drive, but I also like to chainload to Linux partitions installed on the external drive too. So I put grub on each Linux root boot sector to have that chainload option. Only the new Ubuntu 9.04 on sda5 is not able to do this method, but boots by the normal method, (root, kernel, and initrd).
 
Old 10-02-2009, 08:17 PM   #8
Larry Webb
LQ Veteran
 
Registered: Jul 2006
Location: Crystal Beach, Texas
Distribution: Suse for mail +
Posts: 5,100
Blog Entries: 7

Rep: Reputation: 229Reputation: 229Reputation: 229
Use your ubuntu cd and in terminal see if you can get a grub command with 'sudo grub' without the quotes then enter:

grub> root (hd0,4)
setup (0,4)
exit

Then make sure your menu.lst has the partition numbered right.

Last edited by Larry Webb; 10-02-2009 at 08:19 PM.
 
Old 10-02-2009, 10:01 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,096

Rep: Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979
I'd be guessing the external isn't bootable. From the grub boot menu - not the grub command from a terminal - (with the external plugged in) go to command mode and enter "root (hd" (no quotes) and hit the <tab> key. It will either auto-complete hd0, or offer you an option to pick a disk.
What happens ?.
 
Old 10-04-2009, 03:50 AM   #10
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Smile

Larry Webb; For the BIOS drive order and how grub sees them also, the first drive as; hd0, is the internal hard drive, so that the external is as hd1, and my Ubuntu 9.04 is on the external drive as; (hd1,4) so 2nd drive and fifth partition. The exception is the Fedora 11 installed on the internal drive, which views the drives switched from that.
syg00; I will try that idea, and post back soon, thanks.
 
Old 10-04-2009, 10:47 PM   #11
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Lightbulb

When I did try that; root (hd), and hit the tab key, from my main grub at a grub prompt it gave this error; "error 23, error while parsing number", so what the heck does that mean then ?
 
Old 10-05-2009, 12:00 AM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,096

Rep: Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979
If you had typed what I had suggested, it would have been more meaningful. No closing bracket.
 
Old 10-05-2009, 01:03 AM   #13
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Smile

I see then, so like this; root (hd0 , without the other ). Thanks for the correction, I thought that was a typing error with the ) missing. I will try that on the next reboot.

Last edited by james2b; 10-05-2009 at 01:05 AM. Reason: more
 
Old 10-05-2009, 03:32 PM   #14
james2b
Member
 
Registered: Feb 2007
Location: Washington state, USA
Distribution: Fedora 13, SUSE 11, Ubuntu 10.04, Mandriva 2010, Mint 8
Posts: 336

Original Poster
Rep: Reputation: 34
Smile

So here is the result of that root (hd and hit tab key; "Possible disks are: hd0 hd1", that's all it said from the grub prompt, thanks.
 
Old 10-05-2009, 04:04 PM   #15
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
Larry Webb's suggestion is the one I used but with a small correction. (I use setup (hd0,4) and not setup (0,4) which I believe is just a typo)

If you have Linux in (hd0,1), (hd0,2), (hd0,3).....(hd0,15)

You can make all of them chainloadable in one operation in any Grub prompt or Grub shell
Code:
root (hd0,1)
setup (hd0,1)

root (hd0,1)
setup (hd0,2)

root (hd0,3)
setup (hd0,3)
...
...
...
root (hd0,15)
setup (hd0,15)
Thereafter the command in menu.lst to boot them are
Code:
title Linux in (hd0,1)
root (hd0,1)
chainloader +1

title Linux in (hd0,2)
root (hd0,2)
chainloader +1

title Linux in (hd0,3)
root (hd0,3)
chainloader +1
...
...
...

title Linux in (hd0,15)
root (hd0,15)
chainloader +1
The only exception is the Linux controlling the MBR must be booted directly using the "kernel" and "initrd" command. Why? Simple, if you don't Grub will chase its own tail on this one!

The above is the exact method I used to boot 145 OSes. I even wrote the Grub menu.lst before I installed the OSes! I hosted Grub alone in a data-only Fat partition so that every one of the 145 system was chainloaded.

-------------------
Theory

Each partition has a reserved boot sector just for the boot loader right at the beginning of the partition. Every M$ system uses it from Dos to Win7 so it is a standard. A M$ system by default must install its boot loader there. Most Linux filing systems also have it but a few odd filing systems apparently have none. The Grub's "setup" command will install the Grub sourced from the partition specified by the "root" command.

Grub is laughingly simple. Don't make it more complicated than what it is.

Last edited by saikee; 10-05-2009 at 04:39 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GRUB stage 1.5 on partition boot sector ? Vilius Linux - Software 1 03-02-2009 04:54 PM
Reinstalled Win XP and repaired Grub, now I can't boot Linux or Windows. Please help. MegaSvensk Linux - Newbie 27 10-13-2007 05:12 PM
help on installing grub on first sector of /boot kirtikjr Linux - Software 1 06-27-2007 04:16 PM
How to grub-install to the 1st sector of /boot? subaruwrx Linux - General 2 09-23-2004 01:52 PM
Install Grub/Lilo at the First Sector of the Boot Partition?? ckamheng Linux - General 2 08-21-2004 09:35 AM


All times are GMT -5. The time now is 03:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration