LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-22-2008, 08:24 PM   #1
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
How to determine which Linux partition w/ Grub controls the MBR?


If I have multiple linux distros installed in separate partitions on my HD, what is a good way to determine exactly which distro (partition) is controlling the MBR? I know I can figure it out by examining the menu.lst files for all the partitions, but is there some Grub command in the grub CLI that will just tell me what partition controls the MBR?

Thanks for any help.
 
Old 06-22-2008, 08:47 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Not that I'm aware of - the code in the MBR only has relative sector number in it, not partition-id. You could eye-ball it and do the math yourself, but ...
 
Old 06-22-2008, 08:49 PM   #3
tungvs
Member
 
Registered: May 2008
Distribution: Centos; Ubuntu; Fedora
Posts: 98

Rep: Reputation: 15
In my opinion, the MBR is independent of OSs. The last-installed OS write its code into the MBR region and the code runs itself, even when you format or delete the OS's partition - if the partition does not contain the MBR, of courses . (reinstalling the OS or installing new OS will overwrite the MBR). So I think there's no OS "controls" the MBR.

Last edited by tungvs; 06-22-2008 at 08:50 PM.
 
Old 06-23-2008, 08:26 AM   #4
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by syg00 View Post
Not that I'm aware of - the code in the MBR only has relative sector number in it, not partition-id. You could eye-ball it and do the math yourself, but ...
Well, I found out from another forum a solution to my question, and it is a true gem of pure linux voodoo:
Code:
sudo dd if=/dev/sda  bs=1 skip=1049 count=2 | hexdump
This command reads the necessary info from your boot drive's MBR. Of course replace /dev/sda with your boot drive if it is different. The output will look something like:
Code:
2+0 records in
2+0 records out
2 bytes (2 B) copied, 0.0177551 s, 0.1 kB/s
0000000 ff04                                   
0000002
The critical piece of info is the "FF04". "FF04" that means (hd0,4) because FF means the controlling linux partition is on the boot drive, and the 04 is the fifth partition. "FF02" is (hd0,2) or the third partition on the boot drive, "FF03" is fourth partition, etc.

If the controlling linux partition is on a HD other than the boot drive, the first two numbers XY in the four-digit hex sequence will correspond to (hdY,X), instead of being "FF". Thus if get "3103" that means (hd1,3) or 2nd HD, 4th partition. Or "5105" means (hd1,5) or 2nd HD, 6th partition.

Last edited by CJS; 06-23-2008 at 12:17 PM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can I build a mbr in a ntfs partition and install grub to it rbees Linux - General 5 02-02-2008 07:22 PM
Messed up my MBR, now GRUB and Extended Partition Info lost Q-Continuum SUSE / openSUSE 16 05-07-2007 02:29 AM
Changing Distro that Controls MBR mcmillan Linux - Newbie 3 04-18-2006 04:02 PM
Getting rid of GRUB on a partition (NOT MBR) KuRe Linux - Newbie 1 03-31-2005 08:06 PM
Help with Grub in MBR and /boot partition! zLinuxz Linux - General 11 11-17-2003 11:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration