# iPXE



## balanga (Jan 22, 2018)

Has anyone here ever tried iPXE booting?

https://en.wikipedia.org/wiki/IPXE

I never really got my head around it and wondered if anyone has sample configuration I could try...


----------



## tobik@ (Jan 22, 2018)

https://forums.freebsd.org/threads/55103/


----------



## balanga (Jan 22, 2018)

Almos two years since I started that thread ... but had some problems trying to get iPXE working properly.

Do you still have that repository you set up?


----------



## tobik@ (Jan 22, 2018)

balanga said:


> Do you still have that repository you set up?


No.


balanga said:


> but had some problems trying to get iPXE working properly.


You have to be way more specific than that. What problems did you have?


----------



## balanga (Jan 23, 2018)

Just making notes to remind myself how far I got...
	
	



```
cd
pkg install git lang/gcc7-devel
git clone http://git.ipxe.org/ipxe.git
cd ipxe/src
gmake CC=gcc7 HOST_CC=gcc7
gmake CC=gcc7 HOST_CC=gcc7 bin/ipxe.iso
gmake CC=gcc7 HOST_CC=gcc7 bin/ipxe.usb
dd if=bin/ipxe.usb of=/dev/da0
```


----------



## emmex (Feb 26, 2018)

Thank you balanga, it works. My setup on FreeBSD 11.1-RELEASE-p4 is:

```
cd
pkg install git lang/gcc7-devel cdrkit-genisoimage binutils
git clone http://git.ipxe.org/ipxe.git
cd ipxe/src
gmake CC=gcc7 HOST_CC=gcc7 CROSS=/usr/local/bin/
gmake CC=gcc7 HOST_CC=gcc7 CROSS=/usr/local/bin/ bin/ipxe.usb
```


----------



## tobik@ (Feb 26, 2018)

There is a port for it too which does all of that for you: net/ipxe


----------



## balanga (Feb 26, 2018)

tobik@ said:


> There is a port for it too which does all of that for you: net/ipxe




Thanks, I'll take a look.

Did you ever try this ?


----------



## emmex (Feb 27, 2018)

tobik@ said:


> There is a port for it too which does all of that for you: net/ipxe


Yes I know, but I need to embed a script and installing the port via pkg I receive this message:


```
[1/1] Fetching ipxe-20170924.txz: 100%    1 MiB   1.1MB/s    00:01   
Checking integrity... done (0 conflicting)
[1/1] Installing ipxe-20170924...
Extracting ipxe-20170924: 100%
Message from ipxe-20170924:

The following files have been installed in /usr/local/share/ipxe:
- ipxe.dsk for creating a bootable floppy disk
- ipxe.usb for creating a bootable USB key
- ipxe.iso for creating a bootable CD
- ipxe.pxe for chainloading from a PXE ROM
- ipxe.lkrn for any boot manager that can boot Linux kernels
```

How can I embed an iPXE script ?


----------



## tobik@ (Feb 27, 2018)

balanga said:


> Did you ever try this ?


Yes, it work fine for what it is. It's a little annoying to use it for installing FreeBSD though because it uses mfsBSD. But YMMV.


emmex said:


> Yes I know, but I need to embed a script and installing the port via pkg I receive this message:


Of course the package is prebuilt and if you want to embed a script you'll have to build the port yourself. But that's easy to do.


emmex said:


> How can I embed an iPXE script ?


Update net/ipxe to the lastest revision (ports r463161) and set in your make.conf(5) or in /usr/ports/net/ipxe/Makefile.local

```
IPXE_MAKE_ARGS=    EMBED=/path/to/ipxe/script
# If you build in Poudriere or Synth put the script in e.g. /usr/ports/net/ipxe/ipxe-script
# so that the build can find it:
IPXE_MAKE_ARGS=    EMBED=${.CURDIR}/ipxe-script
```
with older revisions use

```
IPXE_EMBED=/path/to/ipxe/script
```
 instead.

Then proceed to build the port as you usually do.


----------



## emmex (Feb 28, 2018)

Thank you tobik@ it works. Please add a phrase in the pkg-message.in file to explain how to embed a script.


----------



## tobik@ (Feb 28, 2018)

emmex said:


> Thank you tobik@ it works. Please add a phrase in the pkg-message.in file to explain how to embed a script.


Hmm, using pkg-message for that doesn't feel right.  It's a post-installation message for the package with the next steps on how to use what was installed. It should not be a guide on how to customize the package build.  There is also more to it than just IPXE_MAKE_ARGS so the pkg-message would be too long.  I think it's reasonable to expect people to look at the port if they want to customize things.

Maybe I'll write a guide and link to it from the port Makefile or pkg-descr instead but don't expect this to happen anytime soon.


----------



## emmex (Mar 1, 2018)

tobik@ said:


> Hmm, using pkg-message for that doesn't feel right. It's a post-installation message for the package with the next steps on how to use what was installed. It should not be a guide on how to customize the package build. There is also more to it than just IPXE_MAKE_ARGS so the pkg-message would be too long.


In my opinion the phrase should be as short as : "if you need to embed a script please look at net/ipxe/Makefile". In the Makefile few commented lines:

```
# To build iPXE with an embedded script, please  uncomment the next line and rebuild the port
#IPXE_MAKE_ARGS=    EMBED=/path/to/ipxe/script
# If you build in Poudriere or Synth put the script in e.g. /usr/ports/net/ipxe/ipxe-script
# so that the build can find it:
#IPXE_MAKE_ARGS=    EMBED=${.CURDIR}/ipxe-script
```



tobik@ said:


> I think it's reasonable to expect people to look at the port if they want to customize things.


This was my error. net/ipxe isn't an application to run or a driver to load and I didn't look at the port tree.


tobik@ said:


> Maybe I'll write a guide and link to it from the port Makefile or pkg-descr instead but don't expect this to happen anytime soon.


Obviously this is the ideal .
Thank you again for your work.
Regards,
Maurizio


----------

