Bug #5520


GRUB Error 21 booting from USB stick on Dell BIOS

Added by Alex Wilson about 8 years ago. Updated over 6 years ago.

Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:
External Bug:


So I've seen this now on:
  • Dell PE R710, latest BIOS and previous release
  • Dell PE 2950, latest BIOS
  • Dell PE R815, unknown (possibly oldish) BIOS
With USB sticks:
  • Kingston DT3 16GB
  • A no-name 4GB

Booting from the USB stick produces the following output:

GRUB Loading stage 1.5.

GRUB loading, please wait...
Error 21

Error 21 corresponds to ERR_NO_DISK -- in this particular case using printf it can be seen that the failing call is to get_diskinfo, which is returning error code 0x60. This error code is produced in stage2/asm.S after calling int 13h with ah = 0x08, when %cl & 0x3f == 0 -- ie, the BIOS is claiming that there is a disk there, but its sectors per track is zero, which GRUB interprets as "you're lying to me, there's no disk there", thanks to ancient BIOS bugs.

However, in the same function in stage2/bios.c, GRUB has already called int 13h with ax = 0x4800 (an extended BIOS call) and gotten valid data back, including the "real" CHS geometry for this disk.

So there's two parts to this:
  • The Dell BIOS should not be returning 0 sectors per track in ah=0x08
  • But GRUB should probably trust the geometry data it already got from the extended call -- at least in this case

Just for testing, I patched GRUB to never made the ah=0x08 call if it got CHS geometry with the ax=0x4800 first, and it successfully boots into Illumos on all the affected BIOSes listed above. Patch is attached, but may not be appropriate for merging -- just because the Dell BIOS returns valid data in that extended call for CHS doesn't mean everybody does...


dell-bios-grub.patch (1.83 KB) dell-bios-grub.patch testing patch Alex Wilson, 2015-01-10 12:00 AM
grub-patch2 (2.76 KB) grub-patch2 Alex Wilson, 2015-01-15 07:19 AM
Actions #1

Updated by Rich Ercolani about 8 years ago

May or may not be related to ?

Actions #2

Updated by Alex Wilson about 8 years ago

Rich Ercolani wrote:

May or may not be related to ?

I think the most they probably have in common is that they both involve a Dell BIOS being amazingly awesomely perfect at everything.

ROGUE-4 seems to involve the BIOS not seeing the disk within parts of its own code, whereas in this bug the disk appears properly in the boot options menus etc and only GRUB refuses to see it. GRUB never gets to start in ROGUE-4.

Actions #3

Updated by Alex Wilson about 8 years ago

So, it turned out that the USB stick I tried that patch out on works with it, but when I try some other Kingston DT3s (the exact same part, even the same batch number on them), it isn't enough. They seem to return 0 sectors per track even in the ax=4800h call as well.

I've attached a revised patch that fixes these up by returning fake data in these two fields if they come out as zero (the standard ATA fake geometry of 16/63) This patch also only attempts to use the data from 4800h if 08h returns an error.

The reason why putting non-zero faked data in these two fields is necessary is not because this is ever used by GRUB for reading/writing (since these disks always come up as LBA, GRUB will always talk to them with LBA) -- rather, the partition table autodetection magic that GRUB has does some maths with these numbers which will fail if they are zero. I had a look at changing the logic there to cope instead, but it's hairy old code, and returning fake data seems to work fine.

Actions #4

Updated by Robert Mustacchi about 8 years ago

  • Category set to kernel
  • Assignee set to Alex Wilson
  • Tags deleted (needs-triage)
Actions #5

Updated by Electric Monk over 6 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 2f7f7a62d7a3e8a2e75eb88b95bc65871b6b90cb

commit  2f7f7a62d7a3e8a2e75eb88b95bc65871b6b90cb
Author: Alex Wilson <>
Date:   2016-08-13T01:45:43.000Z

    5520 GRUB Error 21 booting from USB stick on Dell BIOS
    Reviewed by: Robert Mustacchi <>
    Reviewed by: Patrick Mooney <>
    Approved by: Dan McDonald <>


Also available in: Atom PDF