# Understanding Fdisk, Slice, and the MBR (Master Boot Record)



## fbsd1 (Feb 27, 2010)

Understanding Fdisk, Slice, and the MBR (Master Boot Record)

Users with Microsoft/Windows knowledge of how a hard drive is configured may have a terminology issue with FBSD. Microsoft/Windows and FBSD use the word partition to mean different (but related) things.

The Microsoft/Windows fdisk program is used to allocate partitions on the hard drive. This program allocates two types of partitions, â€˜primary DOS partitionâ€™ and â€˜extended DOS partitionâ€™. DOS means (Disk Operating System) which was the precursor to the Microsoft/Windows desktop GUI (Graphical User Interface).
A single â€˜primary DOS partitionâ€™ occupying all the space on the hard drive would be assigned drive letter C:. 

An alternate method used some times was to allocate a  â€˜primary DOS partitionâ€™ containing only part of the free disk space on the hard drive (50%) then allocate a  â€˜extended DOS partitionâ€™ and sub-divide it into 2 logical dos drives lettered D: and E: each one occupying 25% of the hard drive space. 

The Motherboard Bios Booting Sequence â€˜STANDARDâ€™ was created in the days before windows desktop was even though of yet and at which time Microsoft (command line) DOS was the only thing available. This legacy standard has continued un-updated to this current time and contributes to the limitations imposed on booting, disk layout and selection of which allocation on the hard disk to boot from. 

The motherboard BIOS ROM chip at power up time probes each device (floppies, cdrom, hard drive, usb memory stick) you selected in the BIOS menu to boot from. 

The hard drive has a MBR (Master Boot Record) a (512 byte block) located in sector-0 of the first physical track on the hard drive. This MBR contains bootstrap code and the disk partition table created by the DOS fdisk program. The BIOS boot code reads the MBR code and disk partition table into memory and then transfers control to it. This MBR code is responsible for parsing the partition table and finding the bootable partition that is marked 'active'.  The MBR code then sets up the disk-address-offset information for the bootable partition, and reads 'relative sector zero' from that partition, and transfers control to that one-sector block of code that contains the unique operating system code to load into memory.

This hard drive 512-byte MBR is where all the limitations are. Due to its size the MBR partition table is limited to 4 entries. This means no matter how large your hard drive is (20MB or 200GB) you can only sub-divide it into a maximum 4 partitions. One of which can be an  â€˜extended DOS partitionâ€™ with any number of  â€˜Logical Drivesâ€™ letters D: through Z:.  

All Microsoft/Windows Operating Systems to date (Year 2010) can only boot from a â€˜primary DOS partitionâ€™ flagged as active and access addition drive letters assigned in an â€˜extended DOS partitionâ€™. All other  â€˜primary DOS partitionâ€™ that maybe allocated on that hard drive are inaccessible to the booted Microsoft/Windows operating system. This is really just a Microsoft/Windows limitation rather than being any consequence of the MBR partition table limitations itself.


Now from the FBSD side;
FBSDâ€™s fdisk program allocates disk space into slices. A FBSD slice is the same thing as a Microsoft/Windows  â€˜primary DOS partitionâ€™. The FBSD â€˜disklabelâ€™ program is used to sub-divide the slice into smaller chunkâ€™s called partitions. FBSD partitions are like (but not the same as) the logical drives inside an â€˜extended DOS partitionâ€™. FBSD has to deal with the same MBR partition table limitations. The major difference is FBSD can access the other 3 slices from the slice itâ€™s booted from. Advanced users have created dual-bootable systems where Microsoft/Windows XP is in the first slice/partition, FBSD 7.2 is in the second slice/partition, FBSD 8.0 is in the third slice/partition, and Linux is in the fourth slice/partition. In these cases selecting which slice/partition to boot from is done by the execution of a boot menu that lives in the MBR. 

The FBSD boot0cfg program writes a simple boot menu program to the MBR. Itâ€™s called the â€˜FreeBSD Boot Managerâ€™.
There are other more sophisticated MBR boot menu programs in the FBSD ports collection that you can load into the MBR on the first physical cabled hard drive to scan for other bootable slices/partitions on this hard drive and any other hard drives cabled to the PC. It displays a menu giving you the option to choose which one you want to boot from. This gives you the ability to have more that one operating system installed on your PC at the same time.


----------

