Next: Using GRUB via a serial line, Previous: Theme file format, Up: GNU GRUB manual [Contents][Index]

## 8 Booting GRUB from the network

The following instructions don’t work for *-emu, i386-qemu, i386-coreboot, i386-multiboot, mips_loongson, mips-arc and mips_qemu_mips

To generate a netbootable directory, run:

    grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/<platform>

E.g. for i386-pc:

    grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i386-pc

Then follow instructions printed out by grub-mknetdir on configuring your DHCP server.

The grub.cfg file is placed in the same directory as the path output by grub-mknetdir hereafter referred to as FWPATH. GRUB will search for its configuration files in order using the following rules where the appended value corresponds to a value on the client machine.

    ‘(FWPATH)’/grub.cfg-‘(UUID OF MACHINE)’
    ‘(FWPATH)’/grub.cfg-‘(MAC ADDRESS OF NIC)’
    ‘(FWPATH)’/grub.cfg-‘(IPv4 OR IPv6 ADDRESS)’
    ‘(FWPATH)’/grub.cfg

The UUID is the Client Machine Identifier Option Definition as specified in RFC 4578. The client will only attempt to loouk up a UUID config file if it was provided by the DHCP server.

The client will only attempt to look up an IPv6 address config once, however, it will try the IPv4 multiple times. The concrete example below shows what would happen under the IPv4 case.

    UUID: 7726a678-7fc0-4853-a4f6-c85ac36a120a
    MAC:  52:54:00:ec:33:81
    IPV4: 10.0.0.130 (0A000082)

    ‘(FWPATH)’/grub.cfg-7726a678-7fc0-4853-a4f6-c85ac36a120a
    ‘(FWPATH)’/grub.cfg-52-54-00-ec-33-81
    ‘(FWPATH)’/grub.cfg-0A000082
    ‘(FWPATH)’/grub.cfg-0A00008
    ‘(FWPATH)’/grub.cfg-0A0000
    ‘(FWPATH)’/grub.cfg-0A000
    ‘(FWPATH)’/grub.cfg-0A00
    ‘(FWPATH)’/grub.cfg-0A0
    ‘(FWPATH)’/grub.cfg-0A
    ‘(FWPATH)’/grub.cfg-0
    ‘(FWPATH)’/grub.cfg

This feature is enabled by default but it can be disabled by setting the ‘`feature_net_search_cfg`’ to ‘`n`’. Since this happens before the configuration file is read by GRUB, this option has to be disabled in an embedded configuration file (see Embedding a configuration file into GRUB).

After GRUB has started, files on the TFTP server will be accessible via the ‘`(tftp)`’ device.

The server IP address can be controlled by changing the ‘`(tftp)`’ device name to ‘`(tftp,server-ip)`’. Note that this should be changed both in the prefix and in any references to the device name in the configuration file.

GRUB provides several environment variables which may be used to inspect or change the behaviour of the PXE device. In the following description <interface> is placeholder for the name of network interface (platform dependent):

‘`net_<interface>_ip`’

  The network interface’s IP address. Read-only.

‘`net_<interface>_mac`’

  The network interface’s MAC address. Read-only.

‘`net_<interface>_hostname`’

  The client host name provided by DHCP. Read-only.

‘`net_<interface>_domain`’

  The client domain name provided by DHCP. Read-only.

‘`net_<interface>_rootpath`’

  The path to the client’s root disk provided by DHCP. Read-only.

‘`net_<interface>_extensionspath`’

  The path to additional DHCP vendor extensions provided by DHCP. Read-only.

‘`net_<interface>_boot_file`’

  The boot file name provided by DHCP. Read-only.

‘`net_<interface>_dhcp_server_name`’

  The name of the DHCP server responsible for these boot parameters. Read-only.

‘`net_<interface>_next_server`’

  The IP address of the next (usually, TFTP) server provided by DHCP. Read-only.

‘`net_default_interface`’

  Initially set to name of network interface that was used to load grub. Read-write, although setting it affects only interpretation of ‘`net_default_ip`’ and ‘`net_default_mac`’

‘`net_default_ip`’

  The IP address of default interface. Read-only. This is alias for the ‘`net_${net_default_interface}_ip`’.

‘`net_default_mac`’

  The default interface’s MAC address. Read-only. This is alias for the ‘`net_${net_default_interface}_mac`’.

‘`net_default_server`’

  The default server used by network drives (see How to specify devices). Read-write, although setting this is only useful before opening a network device.

Next: Using GRUB via a serial line, Previous: Theme file format, Up: GNU GRUB manual [Contents][Index]