LinuxQuestions.org
Help answer threads with 0 replies.
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 07-20-2007, 02:21 AM   #1
Benanzo
Member
 
Registered: Sep 2005
Location: Seattle
Distribution: Ubuntu, Debian flavors
Posts: 119

Rep: Reputation: 15
Curious about MBR


I have a question about the data that is stored in the MBR on my disk and individual partitions. I am not having any specific problems, I am just curious about some apparent discrepencies.

I have my disk split into four partitions:
Code:
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  10.2GB  10.2GB  primary  ext3              
 2      10.2GB  12.3GB  2097MB  primary  linux-swap        
 3      12.3GB  150GB   137GB   primary  ext3              
 4      150GB   160GB   10.5GB  primary  ext3         boot
Feisty / (root) installed on /dev/sda1, swap is /dev/sda2, /home is /dev/sda3 and I have Gutsy installed on /dev/sda4. I have been playing around and investigating the MBR data on my disk recently and found something that perplexes me just a little.

When I use dd to copy out the MBR for the disk (/dev/sda) and then for each partition (/dev/sda1 sda2 etc) and then get info about the file using file I get this:

/dev/sda
Code:
mbr_sda: x86 boot sector; partition 1: ID=0x83, starthead 1, startsector 63, 19920537 sectors; partition 2: ID=0x82, starthead 254, startsector 19920600, 4096575 sectors; partition 3: ID=0x83, starthead 254, startsector 24017175, 268076655 sectors; partition 4: ID=0x83, active, starthead 254, startsector 292093830, 20482875 sectors, code offset 0x48
/dev/sda1 (Feisty / (root)
Code:
mbr_sda1: x86 boot sector, code offset 0x48
/dev/sda2 (swap)
Code:
mbr_sda2: data
/dev/sda3 (Feisty /home)
Code:
mbr_sda3: data
/dev/sda4 (Gutsy)
Code:
mbr_sda4: data
My question is regarding the lack of anything that indicates "active" or "bootable" on the Gutsy partition. parted clearly shows that the boot flag is set, but the MBR just says data. However, the boot flag is not set on /dev/sda1 (Feisty) but the MBR indicates that it contains a boot sector.

Am I misunderstanding the way this works? Like I said, I am experiencing no trouble booting into either Feisty or Gutsy with GRUB. I am just curious so I can understand what is going on.

Thanks!

Last edited by Benanzo; 07-20-2007 at 02:22 AM.
 
Old 07-20-2007, 07:48 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Read these articles for an explanation of MBR.

http://www.cpqlinux.com/mbr.html
http://wiki.linuxquestions.org/wiki/Partition_table
 
Old 07-20-2007, 08:19 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
As it is generally referred to, the partition table for a disk only exists in the first sector of that disk. This contains all the relevant flags for (primary) partitions. Partitions themselves have equivalent records, but are boot sector records, and generally don't contain much of interest.
Logical partitions do use the partition table structure, but only for defining themselves, and allow chaining to the next logical partition. The whole extended/logical design was a bit of a hack added later to allow more than 4 partitions on a disk.

Stick to the partition table in the (real) MBR.
 
Old 07-20-2007, 08:26 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
linux does not use the boot flag.
Each partition contains a boot sector.
 
Old 07-20-2007, 08:32 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
The MBR is the first sector of the drive and is not part of any partition. Assuming just one drive, there MUST be boot code here to boot from the hard drive.

Each partition has what is usually called the "boot sector" which is the first sector of the partition. This can also contain boot code---e.g. when using chain-loading to boot multiple OSes.

In either case, the sector (512 bytes), breaks down as follows:
446 bytes boot code
64 bytes partition table
2 bytes "signature"

Primary and Extended partitions are listed in the MBR. Logicals are listed in the appropriate boot sector.

This is old, but is still useful:
http://www.ata-atapi.com/hiw.htm

Also, my site has articles on booting and partitions
 
Old 07-20-2007, 03:13 PM   #6
Benanzo
Member
 
Registered: Sep 2005
Location: Seattle
Distribution: Ubuntu, Debian flavors
Posts: 119

Original Poster
Rep: Reputation: 15
Wow, a lot a great info.

Thanks!
 
  


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
Restoring MBR :partitions are detected only after the reboot after MBR restoration? sharathksin Linux - Newbie 2 04-14-2006 07:48 AM
MBR zeroed. Can I verify backup MBR? TomF Linux - General 7 06-20-2005 05:28 PM
by tring to fix the MBR i damage the MBR that was help... AKAKAK Fedora 4 03-21-2005 08:18 AM
GRUB MBR overwritten by WIN98 MBR TOuseef Linux - General 7 11-14-2004 04:25 PM
Lilo - Writing to MBR - Curious Problem streamalot Linux - General 8 04-07-2002 09:43 PM

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

All times are GMT -5. The time now is 08:20 AM.

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