[ipxe-devel] ipxe image for hard drive booting - ipxe.hd ?

Håkan Johansson f96hajo at chalmers.se
Mon Feb 17 18:21:36 UTC 2014


I want to be able to put a small ipxe image on a hard drive in a machine 
to load ipxe, without having to install a bootloader.  (Or using a USB 
stick, as many bioses delete such boot entries if the machine by accident 
is booted without the stick inserted.)  (Basically just 'dd if=ipxe.hd 
of=/dev/sdX'.)  Is ipxe.hd intended for that?  Or some other suggested 
way?  Searching the documentation did not come up with a solution.

However, ipxe.hd does not work as is, as there is no active partition 
(marked 0x80).  Perhaps this is why it is not built as default?
('make bin/ipxe.hd' fixed that.)

Below are two ways that made it work for me (on a Dell Optiplex 620 and 
Dell Dimension 9150 (the first method only tested on the optiplex)).


dd if=ipxe.hd of=/dev/sdX
fdisk /dev/sdX              # create a normal partition, starting at
                             # sector 2048 and mark it active
dd if=ipxe.hd of=/dev/sdX1

Machine boots and loads IPXE.

Here, ipxe.hd is actually placed twice on the harddrive.


In the second solution, the MBR (src/arch/i386/prefix/hdprefix.S) 
partition table is changed so that the first 'partition' includes the 
ipxe.hd (the MBR itself).  The ipxe.hd boot-loader code then sort of 
finds itself and loads.

As far as I understood the loader code, the partition size (end) is not 
used, so can be some arbitrary dummy value.  I guess also zeros, but not 
tested.  Probably makes sense to have some non-zero value to help avoid 
partitioning tools from using the first part of the disk (ipxe.hd), if one 
wants to use the hard-drive for other partitions too.

Something to include into ipxe?

diff --git a/src/arch/i386/prefix/hdprefix.S 
index 876bfe1..5a5a6f1 100644
--- a/src/arch/i386/prefix/hdprefix.S
+++ b/src/arch/i386/prefix/hdprefix.S
@@ -82,6 +82,14 @@ load_failed:
         jmp     boot_error
  10:    .asciz  "Could not load iPXE\r\n"

+       .org 446
+       .byte 0x80 /* Active */
+       .byte 0x00, 0x01, 0x00 /* head, sector, cylinder */
+       .byte 0x83 /* Linux :-) */
+       .byte 0x10, 0x10, 0x00 /* dummy end: head, sector, cylinder */
+       .byte 0x00, 0x00, 0x00, 0x00 /* first sector */
+       .byte 0x00, 0x04, 0x00, 0x00 /* number of sectors: 1024 */
         .org 510
         .byte 0x55, 0xaa

Best regards,

More information about the ipxe-devel mailing list