Results 1 to 3 of 3

Thread: Partitions and Bootloaders 101

  1. #1
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,026 times in 677 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Partitions and Bootloaders 101

    It seems this is a common enough topic, so I felt a quick tutorial was required.

    Partition Tables

    The standard partition format used on almost all PCs (exceptions include Macs) dates back to the early days of MS-DOS. You're allowed two types of partition: Primary (up to four of these) and Extended (up to one of these), totalling four partitions maximum. You can also create Logical partitions inside the Extended partition, for a total of 24 Primary-plus-Logical.

    Every disk in the system must store data using this layout, and it's used not only by MS-DOS but by Linux and recent Windowses too.

    Booting Sectors

    Booting an OS is a multi-stage process. It's easiest to illustrate using the open-source GRUB boot loader, but the same applies for other loaders (such as NTLDR on Windows 2000/XP).

    When the system BIOS is ready to hand booting control over to a hard disk, it begins by reading the first 512-byte sector on the selected disk (or, more commonly, the first disk), which contains the "Boot Sector". Commonly, because 512 bytes isn't enough space for modern sophisticated systems, this will actually pass control on to a boot loader stored elsewhere on disk. Sometimes this can be another boot sector, stored as a file on a partition, or in the first 512 bytes of a partition (i.e. your "E:" drive might have a boot record, but it cannot load by itself, it must be "chain-loaded" by the master boot record)

    Booting a PC with GRUB

    In the case of GRUB, this first 512b is called "Stage 1", and it contains enough knowledge to load "Stage 1.5" (file system drivers, allowing it to read the next stage from a variety of file systems such as FAT32), and "Stage 1.5" contains enough information to load "Stage 2" from disk. This contains complete information such as which OSes you have installed, which settings to allow you to pick, possibly a graphical version of the selection menu, etc, as read from the file "menu.lst"

    When you pick an entry from "Stage 2", a kernel is loaded and executed, and the operating system takes over - or another boot loader is chain-loaded (such as NTLDR from a Windows partition)

    Booting a PC with NTLDR

    NTLDR behaves in a very similar manner to GRUB, albeit with less control. Firstly, the NTLDR boot sector loads the "ntldr" application from the first NTFS/FAT32 partition on the disk. "ntldr" reads the file "boot.ini" from that disk, offering a menu if there's more than one option, or just picking the only entry (containing a path to the windows kernel NTOSKRNL.EXE) and booting it. Alternatively, NTLDR can chain-load another boot record, as long as it's stored as a file on the Windows disk (not as a file on its own disk or as a proper boot sector on a partition)

    Dual-boot Shenanigans

    Firstly, the reason you couldn't properly dual-boot different versions of Windows 9x is that the OLD MSDOS boot loader is rather under-featured - it can only boot the first partition of the first detected hard disk, no exceptions.

    Secondly, if you're trying to dual boot using more than one hard drive, ask yourself "Which disk is the MBR on? If I see a menu, does that menu depend on files on the other disk? If I change my boot order in the BIOS, have I confused the MBR or boot loader?" This is the most common cause of GRUB Error 17, Lilo "LI" error, or the equivalent NTLDR (and now Vista BCD) errors.
    Last edited by directhex; 12-12-2006 at 02:55 PM.

  2. #2
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    68 times in 51 posts
    maybe worth mentioning about setting up booting for 32/64 bit Windows operating systems. Paul Adams sent me a great mail on this and how ntldr's look for specific arch files.

    Was very good.

    Nice type Hex.
    It is Inevitable.....


  3. #3
    Splash
    Guest
    As you mention, there's been a rise in queries regards bootloaders etc of late - nice post and thoroughly deserves a sticky I think.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •