Passing variable from ipxe menu to FOS


  • Hello, I am wondering if there is any way to pass a variable from a custom ipxe menu item that can then be read and used by FOS?
    I duplicated the fog.deployimage menu item and would want to pass a variable that would be used in my post download scripts.

    What I would want to do, is have my post download scripts only run some scripts depending if that variable is true/1 or false/0. So if I select that new menu item it would have the variable.


  • @rodluz I don’t understand the hiding of private ip addresses, never have and never will. Either way, glad you were able to get this working for you!


  • @george1421 Thanks so much! So what fixed it for me was just removing all the other iPXE commands. So now my parameters are:

    login
    kernel bzImage loglevel=4 initrd=init.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://10..../fog/ consoleblank=0 nvme_core.default_ps_max_latency_us=0 rootfstype=ext4 mac=${net0/mac} ftp=10.... storage=10....:/images/ storageip=10.... irqpoll chkdsk=0 capone=1 type=down img=1909GoldenImage imgType=n imgPartitionType=all imgid=43 osid=9 imgFormat=0 auditMode=1
    imgfetch init.xz
    boot || menu
    

    This works perfectly for what I need.

  • Moderator

    @rodluz No I’m seeing this as two discrete actions.

    Instead of creating an advanced menu item, create a ipxe menu item as I do here for any one of the OS’. https://forums.fogproject.org/topic/10944/using-fog-to-pxe-boot-into-your-favorite-installer-images You need to have all of the fields filled out like I show in the tutorial.

    Lets bypass the password requirement for the moment. And the params section since you don’t need it.

    kernel bzImage loglevel=4 initrd=init.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://10..../fog/ consoleblank=0 nvme_core.default_ps_max_latency_us=0 rootfstype=ext4 mac= ftp=10.... storage=10....:/images/ storageip=10.... irqpoll chkdsk=0 capone=1 type=down img=1909GoldenImage imgType=n imgPartitionType=all imgid=43 osid=9 imgFormat=0 auditMode=1 isdebug=yes
    imgfetch init.xz
    boot | menu
    

    When you make this menu selection you should see it transfer bzImage and then init.xz then boot the linux kernel. With loglevel of 4 you won’t see the kernel boot messages, but if you temp set it to 7 you will see the kernel log messages on the screen as the kernel boots. Realize that you need to make move the cursor on the iPXE menu within 3 seconds or the default menu item will be selected (SANBOOT for bios and rEFInd for uefi) which should load the OS off the hard drive.


  • @george1421 I did make a selection but maybe I made I mistake on the kernel command?
    Also where would I put the sanboot option?

  • Moderator

    @rodluz said in Passing variable from ipxe menu to FOS:

    Booting from SAN device 0x80
    Boot from SAN device 0x80 failed: No such device (http://ipxe.org/2c222087)
    Could not boot: No such device (http://ipxe.org/2c222087)

    This makes me think you did not make a selection and it tried to boot from the local hard drive and not from your custom menu.

    The SAN device is what what FOG uses to boot the local hard drive for bios system “SANBOOT”. Sanboot is not listed in your custom menu.


  • @george1421 Thanks for the response. I am not super familiar with all the ipxe menu stuff so I am doing something wrong.

    My custom menu parameters are:

    login
    params
    param mac0 ${net0/mac}
    param arch ${arch}
    param username ${username}
    param password ${password}
    isset ${net1/mac} && param mac1 ${net1/mac} || goto bootme
    isset ${net2/mac} && param mac2 ${net2/mac} || goto bootme
    kernel bzImage loglevel=4 initrd=init.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://10..../fog/ consoleblank=0 nvme_core.default_ps_max_latency_us=0 rootfstype=ext4 mac= ftp=10.... storage=10....:/images/ storageip=10.... irqpoll chkdsk=0 capone=1 type=down img=1909GoldenImage imgType=n imgPartitionType=all imgid=43 osid=9 imgFormat=0 auditMode=1 isdebug=yes
    imgfetch init.xz
    boot
    

    I have the Menu Show with option set to All Hosts

    When I try to run it, I get this error:

    http://10..../fog/service/ipxe/boot.php... ok
    Booting from SAN device 0x80
    Boot from SAN device 0x80 failed: No such device (http://ipxe.org/2c222087)
    Could not boot: No such device (http://ipxe.org/2c222087)
    Could not boot: No such device (http://ipxe.org/2c222087)
    Chainloading failed, hit 's' for the iPXE shell: reboot in 10 seconds
    
  • Moderator

    @rodluz In short yes there is a way to create a custom key value that FOS will see. I think it would be best to show you where to look instead of telling you do this, poke that approach. Once you understand how it works it will make things a bit easier.

    First if you want to see the FOG ipxe menu (command language behind the menu) key in http://<fog_server_ip>/fog/service/ipxe/boot.php?mac=00:00:00:00:00 from a browser. This will display the fog iPXE menu.

    So if you look through the code you will see this section (If you are writing a custom iPXE menu, I’m sure you are already familiar with the ipxe menu structure).

    :fog.sysinfo
    kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=https://10.96.150.53/fog/ consoleblank=0 rootfstype=ext4 mdraid=true storage=10.96.150.53:/images/ storageip=10.96.150.53 loglevel=4 mode=sysinfo
    imgfetch init_32.xz
    boot || goto MENU
    

    You see in the kernel arguments FOG passes commands to FOS Linux. You would add your custom kernel parameters here.

    For debugging purposes add this kernel parameter to the end of your kernel args for your custom menu. isdebug=yes

    Now pxe boot and go into your custom FOS Linux menu. After a few pages of text where you need to clear with an enter key you should be dropped to the FOS Linux command prompt.

    key in cat /proc/cmdline This should show you your kernel parameters. Make sure your custom parameter is listed. If it is then go to the next step.

    At the FOS Linux command prompt key in fog and press enter. At the first debug pause press ctrl-C to exit out of the imaging code. Now key in set Your kernel parameter should be listed as a bash variable. If the variable is listed there then it should be listed for your post install script.

    Actually I’m working on a new install where we will be doing a load and go deployment (no fog client registration). The name of the system will be calculated during a post install script. But in this case we need to add a sequence number to the calculated name. I’m planning on asking the imaging tech a question in the postinit script for the sequence ID and then hopefully it will be passed along to the post install script to calculate the system name and update the unattend.xml file. Similar concept of passing variable information. For your variable name it just needs to be something that is globally unique (within FOG) and not something the FOG programmers might have used inside the FOG environment (i.e. hostname is not a good choice).

334
Online

8.8k
Users

15.5k
Topics

144.5k
Posts