2

I need to add network driver to GRUB.

I tried to follow this manual provided by GNU but it only says

Although GRUB is a disk-based boot loader, it does provide network support. To use the network support, you need to enable at least one network driver in the GRUB build process. For more information please see `netboot/README.netboot' in the source distribution.

I can't seem to find this netboot/README.netboot file anywhere online. Does anyone know how to install network driver to GRUB? How do I build GRUB with liveCD?

In case you need it, my network card according to lspci:

01:00.0 Network controller: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter (rev 31)

1 Answer 1

2

You're looking at the manual of the obsolete GRUB Legacy (i.e. GRUB versions 0.9x).

Armed with this information, I found a copy of the README file you are looking for. You'll find it only supports a range of old wired network interfaces, mostly in the 10/100 Mbps range.

But GRUB was completely rewritten in the 1.xx versions, and the documentation for old GRUB Legacy does not apply at all to modern versions of GRUB (versions 2.0x).

Here is the manual for modern versions of GRUB.

The standard way to boot from network is using the PXE specification. That requires the network card to provide its own extension to system firmware (either a BIOS extension or an embedded UEFI driver) that will activate the card and allow it to send out a DHCP request with additional PXE attributes set. The DHCP server will then have to include the boot file location in its response.

The firmware will then download a network-based bootloader from the location indicated in the DHCP response, usually using the TFTP protocol, but in newer UEFI implementations using HTTP may also be an option. After that, the control is transferred to the downloaded bootloader, which will be able to download more files using a standardized firmware API to control the network card.

The problem is, most wireless network interfaces won't include such a PXE boot firmware extension (i.e. I've never seen a wireless network interface with a functional PXE boot capability yet).

This is because there is a pretty serious "chicken vs. egg" problem in your specific case, and with most wireless NICs in general: before a wireless network adapter can start working, you need to load one or more firmware files into the network adapter. But if you want to boot from network, it usually means you don't want to (or can't) use any local disks at all, so you won't have any place to get the firmware files from.

If you had a GRUB driver for a NIC, it would most likely be a compile-time configuration option. It might also be a GRUB module, loadable using the insmod command. But as far as I know, nobody has written any wifi drivers for GRUB.

The only network drivers available for GRUB 2.xx are currently included in the grub-core/net/drivers directory of GRUB source package. They are:

  • efinet for UEFI systems, relies on hardware support provided by either firmware or UEFI driver.
  • emunet on QEMU virtualization (I think)
  • pxe on BIOS-based x86 systems, relies on hardware support provided by firmware (typically as a PXE boot BIOS extension for the network adapter)
  • ofnet for systems using Open Firmware (systems from Sun, Apple, IBM, ARM)
  • ubootnet for systems using the U-Boot firmware (mostly embedded Power Architecture, ARM and MIPS systems)

Alternatively, if your target system has UEFI firmware, it might have an .efi driver available, and you could define an UEFI NVRAM boot variable (e.g. with the efibootmgr --driver command with appropriate options) to load the driver from the local EFI System Partition just before loading the bootloader, and then relying on UEFI's native network support. But I've not seen any .efi drivers for wireless NICs either.

If you have enough local disk space to fit GRUB (or any other bootloader), a Linux kernel file, and a Linux initramfs file that includes the Linux driver for the wifi NIC, any kernel modules it depends on, the firmware file(s) for the NIC, wpa_supplicant, its configuration, and a DHCP client, you could instead just have the Linux kernel boot locally and use the initramfs environment to start up the wifi connection. Then you could either have the initramfs download a ramdisk/tmpfs-based root filesystem image from the network and use that, or use a root filesystem located on a NFS server. This might be the easiest way to reach your goal without needing to start a "write my own wifi driver" project.

2
  • So if I had some disk space is it possible for GRUB to load up wifi driver? If so what kind of command am I supposed to use? I couldn't find any sets of command in the provided newer version of GRUB manual. I have all else setup on vm but for physical client device I'm planning to use have no ethernet port so I need to figure out the way to include the driver when setting up GRUB. Commented Jan 28, 2021 at 16:18
  • Please see my edit above. Commented Jan 29, 2021 at 10:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.