4

I know the general story of why we have separate boot partitions historically:

What is the /boot partition really for?

and on a new computer, I might not bother with one. However - I'm installing Linux on a 20-yro system, with a non-UEFI BIOS (which can't even boot from USB). This will not be a multi-boot machine, or anything complicated: No LVM, no disk encryption, no RAID etc.

How can I tell whether my specific computer, with my specific HDD, needs a boot partition?

Note:

  • In case it matters - the distribution I intended to install is antiX Linux 19.3 i386. It invokes gparted to let you edit the partitions.
  • The boot loader will naturally be the one my distribution installs, which AFAICT is grub2.
muru
  • 72,889
einpoklum
  • 9,515

3 Answers3

6

If a system is about from year 1994 or older, its BIOS might not be able to handle disks with Clusters/Heads/Sectors geometry larger than 1024/16/63, which works out to a limit of 504 MiB (528.4 MB). The reason for this was an inconvenient interaction of two sets of limits:

  • the classic unextended BIOS INT 13h function accepted a maximum disk geometry of 1024/255/63
  • the IDE (PATA) hardware would accept a maximum geometry of 65536/16/63
  • so far, trivial implementations just picked the smallest limit in each value, resulting in a limit of 1024/16/63.

In July 1994, a new BIOS feature "Enhanced Disk Drive Services" (EDD for short) was developed to work around this limit. It shifted bits between the Clusters and Heads parts of the geometry between BIOS representation and the IDE hardware interface (called "geometry translation"), as a workaround for this limit.

Some BIOS versions also had bugs at disk geometry 4096/16/16 or its "translated" form 1024/64/63.

At disk geometry of 16383/16/63 (or 1024/255/63 in translated form), the maximum limit of classic C/H/S disk addressing was reached: the data input formats of the BIOS functions handling this kind of disk addressing simply did not have enough bits to handle disks bigger than this. This limit was reached at disk size of 7.87 GiB (8.45 GB), or exactly 16 450 560 disk blocks.

The IDE (PATA) specification included a feature that could work around this, but it was initially specified as optional feature, and not all BIOSes implemented it. It was called Logical Block Addressing, or LBA for short. As disk sizes grew, most disks released after 1996 or so did support LBA.

But then another BIOS bug was discovered: some BIOSes had a faulty LBA implementation that failed if more than 26 bits was required to represent the disk block number. This affected some BIOS versions released in August 1999 or older, and it caused a limit at disk size of exactly 32 GiB (33.8 GB).

The LBA specification that was released in 1994 had allocated only 28 bits for the disk block number, and this caused a yet another disk size limit at exactly 128 GiB disk size. The ATA-6 specification released in year 2003 specified 48-bit versions of the LBA disk access functions, which is what we're currently using with modern SATA disks. It should work until disk sizes grow to 128 PiB.


It was often possible to work around these limitations by deliberately specifying an incorrect disk geometry in BIOS, telling it that the disk was smaller than the offending limit, and making /boot a partition that fit completely within the fake geometry.

Sometimes (after the LBA support was introduced) it was enough that the /boot partition was within the appropriate size limit.

The bootloader would use BIOS routines to load the Linux kernel (and optionally an initrd file) from this partition, and once the kernel was started, its drivers would take over disk access, bypassing BIOS altogether and making its limitations irrelevant as long as the OS was running. At this point, the real disk geometry would usually be auto-detected by the kernel.

So, what does this mean?

  • if your system has a BIOS release date in year 2004 or older, you may need to create a /boot partition that fits entirely within the first 128 GiB of the disk, or else the BIOS might fail to boot the OS. (This is usually a problem for dual-boot and other multi-OS setups only.)
  • if your system has a BIOS release date of before year 2000, you might want to create a separate /boot partition within the first 32 GiB of the disk, just to be safe from LBA implementation bugs.
  • if the system is from 1996 or older and does not mention "LBA" anywhere in BIOS settings, you might have to specify a fake disk geometry and make sure your /boot partition is both within the fake geometry and within the first 7.87 GiB of the disk.
  • anything older than that: "It belongs to a museum." :-) But if you must, see above for the relevant limits.

If a system's BIOS release date is only just after the date of a particular specification update, it might or might not have the updated specification: after each specification update was released, it took some time for the new implementations to become ubiquitous.

telcoM
  • 96,466
  • Grub2 bypass all the bios problems you list. It directly may load a sequence of sectors without using BIOS. –  May 07 '21 at 20:42
  • What about a BIOS originally released in 1999 but updated after 2000? Is there a way to check how far into the disk it can reach? Anyway, +1. – einpoklum May 07 '21 at 21:00
  • Now-a-days it doesn't matter which BIOS it is. Providec you partition with gparted, use grub2, and install the bootloader to the MBR. @einpoklum –  May 07 '21 at 21:17
  • 1
    @Isaac From GRUB documentation: "Direct ATA/AHCI support allows to circumvent various firmware limitations but isn’t needed for normal operation except on baremetal ports." If the ATA/AHCI direct support is compiled in, then you're correct - but not every distribution offers a version of GRUB with ATA/AHCI support compiled in by default. – telcoM May 07 '21 at 21:17
  • @telcoM: Well, how can I tell if it has or hasn't? – einpoklum May 07 '21 at 21:20
  • Most distros use GRUB2 now. It knows which modules to load as needed. A distro with other bootloaders is not in discussion. –  May 07 '21 at 21:22
  • @einpoklum Make a minimal installation, interrupt GRUB at boot, go to GRUB command prompt, type ls ( and press TAB. If it displays devices like (ahci0) or (ata0), then you have a baremetal-capable GRUB. If you see (hd0), it's using BIOS support. https://www.gnu.org/software/grub/manual/grub/grub.html#Device-syntax – telcoM May 07 '21 at 21:30
  • @Isaac But if the direct ATA support is built as a module, it needs to be loaded first... by using the BIOS support to load the module! At that point, the module directory /boot/grub/i386-pc needs to be within the BIOS support limitations anyway. The alternative is to use grub-mkimage to build a custom GRUB image that embeds the appropriate module to the main GRUB image and install it, then do it again every time the distribution releases a GRUB update. I've yet to see an installer that would do this automatically. – telcoM May 07 '21 at 21:35
  • @telcoM: If I need to make an installation to figure this out, I can just try no having a boot partition and seeing whether that works... :-P – einpoklum May 07 '21 at 21:54
  • @TelcoM Yes, direct access is a capability that GRUB could load if needed. But actually what I meant is that grub has his own routines to access the disk which don't need nor use buggy BIOS routines. The routines to access specific filesystems is loaded with core.img (generally) and it allows GRUB to access any file directly (without third parties). –  May 08 '21 at 03:34
  • @telcoM Yes, it needs to be loaded (filesystem access I mean), but what to load is decided (dynamically) with the rule set in the grub-mkimage program. It is funny that an almost complete OS has to be built (GRUB) to load the actual OS. –  May 08 '21 at 03:38
  • @Isaac Please show me where that ruleset is in the source code. I would be very interested in seeing it, and I haven't been able to find it. grub-mkimage.c seems to just do what it's told on the command line, and the logic in grub-install.c selects the disk_module based on command line options, defaulting to biosdisk on i386-pc architecture. – telcoM May 08 '21 at 08:32
  • @Isaac: telcoM is right. I performed my antiX installation (with a boot partition), and old drivers grub2 sees are hdN's. – einpoklum May 08 '21 at 08:38
  • @einpoklum The way used to select the name of a disk doesn't make anyone right. –  May 08 '21 at 12:01
  • @telcoM (1) It seems that the biosdisk doesn't do what you believe: biosdisk - This module provides GRUB with the ability to boot off of LiveDisks.. The default is to load all modules. (2) Please look at the image core.img contains all that is needed to read a filesystem –  May 09 '21 at 04:17
3

tl;dr: You don't need a boot partition.

Even for an old computer from the 1990s, you don't need a boot partition.

... "but how can this be," you might ask, "considering how we've been told for years that we need one because of the BIOS limitations?"

The reason is that a modern Linux distribution (like your antiX 19.3) will install the grub2 boot loader; and a grub2 installation can include drivers, with which the boot loader can access your partitions with no limits; it will not need the BIOS facilities for HDD access.

There is, however, a caveat: those drivers need to actually get installed, and they don't necessarily get installed automatically.

... but you must leave space for the grub2 drivers

First, grub2 needs space to store these drivers. Luckily, if your first partition is not situated immediately after the MBR, at the start of the disk, the grub2 installation will store the drivers in this non-partition space (it only needs a small amount of space, perhaps just 20KiB) and you're good to go.

So, you will need to make sure you create your first partition with 1MiB alignment (and perhaps all partitions with this alignment).

In your specific case of the antiX installer, the gparted utility is used for defining/creating partitions. gparted defaults to 1 MiB alignment, and shows you this choice when creating a partition:

enter image description here

so just don't change that setting.

... and make sure the appropriate drivers are installed

Linux distro installers, specifically antiX' installer, default to having grub2 using BIOS/UEFI facilities rather than its own driver. You need to make sure that grub2 is installed with grub-install --disk-module=native. Doing that is covered in another question:

How to make sure grub2 has the drivers it needs during a Linux installation?


Thanks goes to @cas, @isaac and @telcoM for their insightful answers and helping me synthesize this one.

einpoklum
  • 9,515
2

Whether or not your system needs a /boot directory is entirely defined by the distro you choose to install.

Whether that directory (/boot) is in a separate partition is also optional (not required), but quite useful in some conditions.

The distro you selected (AntiX) is a Debian derivative. Debian may use a /boot partition but it is not a requirement. Debian is also able to use several bootloaders (lilo, grub, etc.).

It is the bootloader the part that is affected by the BIOS ability to load sectors at some distance of the start. But GRUB2 is perfectly capable of bypassing any such limitation provided it could use about 80 sectors (́~20k) after the MBR. Which it normally could, especially with a 1M aligned partition.

In short: create a /boot partition as the first one of about 200 Mbyte (plenty of space), make it bootable (a DOS requirement), and install grub to the MBR. You could additionally install grub to that partition, but there is no real need for the complexity.

You need not to concern about any of several DOS disk limits, Grub2 is perfectly capable of solving any configuration (with access to MBR and following sectors).

Please read the detail in the grub documentation.

there are two ways to install GRUB: it can be embedded in the area between the MBR and the first partition (called by various names, such as the "boot track", "MBR gap", or "embedding area", and which is usually at least 31 KiB)

And the description of core.img in the grub documentation

This is the core image of GRUB.

built dynamically from the kernel image and an arbitrary list of modules by the grub-mkimage program.

Depending on the filesystem (for example) a module that reads ext4, zfs, or else will be used. Other conditions will trigger the loading of more modules.

Usually, it contains enough modules to access /boot/grub, and loads everything else (including menu handling, the ability to load target operating systems, and so on) from the file system at run-time.

In a nutshell, the inner workings of GRUB.

The modular design allows the core image to be kept small, since the areas of disk where it must be installed are often as small as 32KB.

One of the conditions GRUB has to operate.


If you are willing to try:

  1. Leave a big chunk of space, bigger than any DOS limit, as the first partition of the disk (or as free space). No need to format it, you will not use it in this test.
  2. Make a partition (for /) far ahead in the disk of Say 50GB to install a test OS. To make things even harder for GRUB, don't make a partition for /boot.
  3. DO format this partition on a filesystem that grub understand, maybe ext4.
  4. Make other partitions as you wish (after the free space).
  5. Make sure to install GRUB to the main disk (sda, not sda1 or sdaX).
  6. End installation, reboot. Does it work?

If it works, GRUB has just shown that it can manage the old BIOS you've got.

  • 1
    @einpoklum (1) I do know what a /boot partition is. You are falling on the aparent, read carefully. (2) Defining the kernel (Linux) doesn't define the boot loader. :-) –  May 07 '21 at 19:08
  • This answer might look better now, does it? @einpoklum –  May 07 '21 at 21:14
  • It's better now, but not there yet: 1. You're telling me to always create a boot partition, while it seems I don't always have to. 2. How can I tell whether grub2 is using 20k after the MBR? If I used gparted to partition my disk and it had 1M-alignment checked, is that a sufficient guarantee? – einpoklum May 07 '21 at 21:23
  • 200MB isn't really "plenty of space", especially if you want to have several kernels (~6 MB each) and initrds (~85 MB each) in /boot. Or a rescue CD ISO (size varies a lot, but probably 250 MB minimum). – cas May 08 '21 at 02:33
  • I agree 100% with what you're saying about grub2 - if you have grub2 (and are using a modern fs known by grub), then you don't need a separate /boot. But the distro is basically irrelevant - they all use grub2 now, and have done so for a very long time. The other significant factor is the filesystem used for / or /boot (if separate) - it needs to be one that grub's MBR code can read from. This is mostly handled automagically these days by grub-install....but it (and paranoia) is the reason why I still have an ext4 /boot on my zfs rootfs systems. I wouldn't bother if using ext4 rootfs. – cas May 08 '21 at 02:40
  • grub2 has a zfs module, so I almost certainly don't need a separate /boot partition. But i'd rather have it and not need it than need it and not have it. Also, it's a convenient place to store a few rescue CD images, with grub menu entries for them....just in case my tftp server is down (or in case its my tftp server that needs to boot a rescue cd). paranoia and disaster planning. – cas May 08 '21 at 02:42
  • @cas Well, yes, you are correct. But I meant that that is "plenty of space" for one kernel on one system. And yes, a CD ISO should be around 650 M at least. Today disks tend to be BD, which are in the order of several G. But an additional directory could be Bind mounted if space is really needed. So, not such a hard limit, anyway. In retrospect, and depending on use, a 1 G partition might be more useful. –  May 08 '21 at 03:03
  • @cas Yes, an ext4 partition for /boot also gets my vote. –  May 08 '21 at 03:04
  • @einpoklum (1) Well, yes I am stacking odds in my favor, having a /boot partition from the start reduces the distance where data files will end being and helps avoid any possible limit. Not that those DOS limits matter much in present days but nice to be on the safer side. (And: please read CAS comments about additional CDs). –  May 08 '21 at 03:18
  • @einpoklum (2) As explained here, boot.img is what goes into the MBR (only 512 byte). Then what gets placed right after the MBR is core.img mostly limited to 32K (may be a little bigger in most today installs). So, documentation tells you that around 32K after the MBR are being used. (3) The 1Mbyte alignment just increase the space for core.img to close to 1 Mega byte. –  May 08 '21 at 03:19
  • On a GPT-partitioned disk, it's useful (but not required) to have a tiny partition for grub's core.img. It needs to be type 0xEF02, with a minimum size of 32KB, starting from sector 34 or higher. I usually make mine from sector 40 to sector 2047 (for the 1MB alignment). grub2 will use this for core.img if it exists, otherwise it'll just start writing ~32KB starting from sector 34. – cas May 08 '21 at 03:48
  • On an MBR-partitioned drive, the MBR & partition table is in sector 0, and the first partition has to start from sector 64 or higher in order to leave space for grub's core.img (starting from sector 1) and the volume boot record (sector 63). – cas May 08 '21 at 03:49
  • Yes, @cas I agree on both counts. Thanks. –  May 08 '21 at 03:51
  • @cas Answer edited just now, by the way. –  May 08 '21 at 03:51
  • @cas: And under those conditions, and with a modern distro installing grub2, I don't need a boot partition? – einpoklum May 08 '21 at 07:50
  • @einpoklum nope, not needed. It doesn't hurt to have one, though. – cas May 08 '21 at 07:52