Disable options in menu based on CPU
|
2016-03-16, 18:30
Post: #1
|
|||
|
|||
Disable options in menu based on CPU
Hello,
I'm trying to write a dynamic boot menu using php. However, since i'll have to support different CPU types and architectures, i'd like to remove certain menu options (or do not display) based on the CPU type. I know that I can use CPUID --ext29 to check if the machine supports x64; and I already supply the machines with different ipxe versions (undionly.kpxe, ipxe_x86.efi and ipxe_x64.efi) However, somehow I need to provide the architecture while calling the PHP script; or I need an if statement in ipxe to not display the item. I've tried putting the following options in my DHCP: Code: if exists user-class and option user-class = "iPXE" { however, the x64 machines do receive the ipxe_x64.efi file (so the first time it requests the arch it is indeed 00:07; however, when booted to my boot menu, it display 'arch=unknown', so the 'arch=Uefix64' is not relevant A machine booted to undionly.kpxe does display 'Legx86'. Also, if there is a better way to pass the arch variable into the php url, please let me know. I'm using an if statement because that works in the first load-out of ipxe |
|||
2016-03-16, 18:45
Post: #2
|
|||
|
|||
RE: Disable options in menu based on CPU
Here is an example of my ipxe bootstraping script,
as you can see here arch (among other things) is sent to PHP so that the correct menu items can be added to the script (also platform is used for this) Code: #!ipxe This do require an extra roundtrip, an alternative would be to add this as an embeded script into ipxe where you use dhcp at the top and then "chain -ar ${filename}&arch=${arch}" at the end, that way you still keep the option to modify filename on the dhcp server but get the arch in the actuall request. Use GitHub Discussions VRAM bin |
|||
2016-03-16, 19:07
Post: #3
|
|||
|
|||
RE: Disable options in menu based on CPU
(2016-03-16 18:30)Fimlore Wrote: However, somehow I need to provide the architecture while calling the PHP script; or I need an if statement in ipxe to not display the item. You can use the ${buildarch} and ${platform} variables in iPXE. For example, with the standard 32-bit BIOS version of iPXE you would get ${buildarch}="i386" and ${platform}="pcbios". You can pass these to the server (e.g. "http://10.168.51.5/bmenu.php?arch=${buildarch}-${platform}"), or you can use them in client-side tests. For example: to conditionally include a menu item to run the UEFI shell, which will appear only if running the UEFI version of iPXE: Code: iseq ${platform} efi && item --key e uefishell UEFI shell || Note that ${buildarch} is the architecture for which iPXE was built, not the architecture of the CPU on which iPXE is currently running. In a standard 32-bit BIOS build of iPXE, ${buildarch} will be "i386" even if the CPU itself can run both 32-bit and 64-bit code. You need to use the cpuid command if you want to do a runtime check to see if the CPU is 64-bit-capable. Michael |
|||
2016-03-16, 19:33
Post: #4
|
|||
|
|||
RE: Disable options in menu based on CPU
Thanks for your quick and clear replies. This was exactly what I was looking for and I was certain not to find out myself
The solution provided by Michael, the platform option is actually what I need, because dhcp decides the best ipxe to load for the platform, so if the efi file loads, the legacy options are invalid so should not be displayed and vice versa. The ipxe script you provided nikize is also very interesting, it provides great insight into advanced ipxe scripting. I know I am asking a lot of questions. But I'm adopting ipxe as our booting method and i'd love to be able to support everything in one system, instead of having 3 solutions that do all the same but limited. It however involves a lot of know-how in both bash and Linux.. And I'm a Windows scripting guy, so it's a challenge but fun to do. Thanks for both of your replies. |
|||
2016-03-16, 19:45
Post: #5
|
|||
|
|||
RE: Disable options in menu based on CPU
(2016-03-16 19:33)Fimlore Wrote: Thanks for your quick and clear replies. This was exactly what I was looking for and I was certain not to find out myself You're very welcome! If you'd like some more realtime assistance, then both of us are regularly available in the #ipxe IRC channel on Freenode, along with a host of other people who will be happy to point you in the right direction! Michael |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)