2

On a machine that uses UEFI and GRUB to boot I've witnessed Windows decide to change the boot order. I thought boot order was only the business of me and my motherboard and simply non-existent in the eyes of a bootloader, an OS, and everything on up. How is an OS able and allowed to change this?

Questions regarding this behavior have been asked before.

Windows 8 changes boot order

This question is specifically asking "How is this possible?" rather than "Why does this happen?", "Should this happen?", or "Can I enable/disable this from happening?".

1
  • check easyuefi, its running under windows and can rename/modify/reorder uefi boot entries. so yes its definitely possible.
    – lex
    Jul 5, 2015 at 10:34

2 Answers 2

3

Well, the OS is what installs the bootloader in the first place, so clearly it has some control over it.

UEFI firmwares have an integrated boot manager, which stores the menu choices and other parameters as EFI variables such as Boot0001, BootOrder, BootNext.

They're stored in the same NVRAM as other firmware settings – in fact, many firmware settings are also exposed as EFI variables – and operating systems can read/write them by calling EFI code. (It's similar to calling the BIOS via old-style interrupts, except the UEFI interface is somewhat better-defined.)

# ls /sys/firmware/efi/efivars/Boot*
/sys/firmware/efi/efivars/Boot0003-8be4df61-93ca-11d2-aa0d-00e098032b8c
/sys/firmware/efi/efivars/Boot0004-8be4df61-93ca-11d2-aa0d-00e098032b8c
/sys/firmware/efi/efivars/Boot0005-8be4df61-93ca-11d2-aa0d-00e098032b8c
/sys/firmware/efi/efivars/Boot0006-8be4df61-93ca-11d2-aa0d-00e098032b8c
/sys/firmware/efi/efivars/BootCurrent-8be4df61-93ca-11d2-aa0d-00e098032b8c
/sys/firmware/efi/efivars/BootOrder-8be4df61-93ca-11d2-aa0d-00e098032b8c

# efibootmgr --verbose
BootCurrent: 0004
Timeout: 2 seconds
BootOrder: 0004,0003,0005,0006
Boot0003* Windows Boot Manager  HD(1,GPT,785c8ca2-bb16-48fd-917b-19d69543338f,0x800,0x32000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)
Boot0004* Linux Boot Manager    HD(1,GPT,785c8ca2-bb16-48fd-917b-19d69543338f,0x800,0x32000)/File(\EFI\gummiboot\gummibootx64.efi)
Boot0005* Hard Drive    BBS(HD,,0x0)P0: ST9640320AS               .
Boot0006* CD/DVD Drive  BBS(CDROM,,0x0)P1: SlimtypeDVD A  DS8A5SH    .

# efibootmgr --bootnext 0003
BootNext: 0003
BootCurrent: 0004
Timeout: 2 seconds
BootOrder: 0004,0003,0005,0006
...

# efivar --print --name 8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot0004
GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c
Name: "Boot0004"
Attributes:
    Non-Volatile
    Boot Service Access
    Runtime Service Access
Value:
00000000  01 00 00 00 72 00 4c 00  69 00 6e 00 75 00 78 00  |....r.L.i.n.u.x.|
00000010  20 00 42 00 6f 00 6f 00  74 00 20 00 4d 00 61 00  | .B.o.o.t. .M.a.|
00000020  6e 00 61 00 67 00 65 00  72 00 00 00 04 01 2a 00  |n.a.g.e.r.....*.|
00000030  01 00 00 00 00 08 00 00  00 00 00 00 00 20 03 00  |............. ..|
00000040  00 00 00 00 a2 8c 5c 78  16 bb fd 48 91 7b 19 d6  |......\x...H.{..|
00000050  95 43 33 8f 02 02 04 04  44 00 5c 00 45 00 46 00  |.C3.....D.\.E.F.|
00000060  49 00 5c 00 67 00 75 00  6d 00 6d 00 69 00 62 00  |I.\.g.u.m.m.i.b.|
00000070  6f 00 6f 00 74 00 5c 00  67 00 75 00 6d 00 6d 00  |o.o.t.\.g.u.m.m.|
00000080  69 00 62 00 6f 00 6f 00  74 00 78 00 36 00 34 00  |i.b.o.o.t.x.6.4.|
00000090  2e 00 65 00 66 00 69 00  00 00 7f ff 04 00        |..e.f.i.......  |

# efivar --print --name 8be4df61-93ca-11d2-aa0d-00e098032b8c-BootNext
GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c
Name: "BootNext"
Attributes:
    Non-Volatile
    Boot Service Access
    Runtime Service Access
Value:
00000000  03 00                                             |..              |

This list often contains both UEFI bootloaders and "BIOS compatibility mode" MBR disks.


On BIOS systems there is no direct access to this configuration. However, the OS can of course overwrite the existing boot sector with its own, and in fact almost always does because there's no configuration; e.g. installing Windows will always write the Windows boot sector.


Side note: The "EFI variables" aren't really specific to EFI – a similar technique also existed on ARC systems on which Windows NT was originally developed; the NTLDR bootloader and the "boot.ini" file used by Windows are in a way just emulation of what ARC would have provided natively.

-2

It's possible because the OS does have control over the bootloader. You have the bootloader confused with the BIOS, which is entirely different.

When your computer boots up, the following happens:

  1. It does the POST checks
  2. Control is passed to the BIOS to choose which device to boot from. This is what the OS has no control over.
  3. Once it's found a device to boot from, control is passed to that device.
  4. The device loads the bootloader which allows it to boot an OS either automatically or at the user's control.
  5. Control is finally passed to the OS.

Generally, the bootloader is in the MBR section (the first few sectors) of the hard drive and usually references files that are accessible to the OS itself, so the OS can change the boot order whenever it wants to.

3
  • You indicate that it is possible yet you don't explain HOW to change the order.
    – Ramhound
    Jul 5, 2015 at 0:45
  • Well empirically it is possible. This answer could be fleshed out more but it suggests what I think is the trick. Both the motherboard and OS are just writing to hard disk to change boot order rather than changing a setting stored on the motherboard (unlike other motherboard settings which really are stored on the motherboard). That still leaves the situation with multiple physical disks unclear but I'm the asker so I don't know. Jul 5, 2015 at 1:02
  • This answer described the BIOS boot process, but the question is explicitly about the EFI/UEFI boot process, which is significantly different.
    – Rod Smith
    Jul 6, 2015 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .