Build PXE boot image

Use the following command to generate a pxe boot image:

    grub-mkimage --output=core.img --prefix="(pxe)/boot/grub" pxe pxecmd
    cat pxeboot.img core.img > grub2pxe

Copy grub2pxe, *.mod, *.lst, to the tftp server, and use grub2pxe as pxe boot file.

NOTE: The *.mod and *.lst files must be accessible under the tftproot's boot/grub/ subdirectory, as specified by the grub-mkimage command above.

After startup, files in the tftp server can be accessed using the (pxe) device.

Control PXE device

You can use command pxe to communicate with the pxe device.

    pxe --info

This command shows some information about PXE, including block size, client ip, server ip and gateway ip.

    pxe --bsize=size

Set block size of tftp transfer. Minimal size is 512, which is also the default. Maximal size is 1432. Normally, you can increase download speed a bit by setting larger block size, but some old tftp server may not support it. For example, qemu doesn't support block size other than 512.

    pxe --unload

Unload the pxe runtime environment.

Testing with qemu

You can test PXE boot with qemu. First, copy files to a local directory such as /tftp, then run qemu with the following options:

    qemu -boot n -tftp /tftp -bootp /grub2pxe

NOTE: Again, the *.mod and *.lst files must be in the boot/grub subdirectory under the /tftp path.

Notes

First of all, tftp doesn't support listing file, so ls doesn't work on (pxe) device. But you can still open file if you know its name.

Second, due to the limitation of pxe boot protocol, tftp access must be sequential, and only one file can be accessed at one time. Therefore, whenever we seek backward or switch to another file, we must reinitialize tftp connection again. This means random access operation, such as reading font, can be extremely ineffective.

GrubWiki: PXEBOOT (last edited 2009-11-01 17:26:25 by Jason.McMullan)