How to pass options to the booted system via PXECONFIG script - Printable Version +- iPXE discussion forum (https://forum.ipxe.org) +-- Forum: iPXE user forums (/forumdisplay.php?fid=1) +--- Forum: General (/forumdisplay.php?fid=2) +--- Thread: How to pass options to the booted system via PXECONFIG script (/showthread.php?tid=7090) |
How to pass options to the booted system via PXECONFIG script - knatesan - 2013-11-01 20:16 I have a script that automatically runs after system has been pxebooted. that script needs some information like IP address and path to some file. I would like to specify in my PXEconfig file. Does anyone have gone through this? any clue on how to do this? Thanks in advance.. Below is my PXE config file("Bootloader.cfg") "kernel nfs://192.168.13.5/var/www/nfsshare/casper/vmlinuz initrd nfs://192.168.13.5/var/www/nfsshare/casper/initrd.gz echo now booting... imgargs vmlinuz root=/dev/nfs boot=casper netboot=nfs nfsroot=192.168.13.5:/var/www/nfsshare/ boot" I have placed my script in /usr/bin and i have a entry in /etc/rc.local aswell. I want to pass some arguments for my script like IP address.. something like "autoexe" .. Any clue? RE: How to pass options to the booted system via PXECONFIG script - knatesan - 2013-11-01 22:19 Is it possible to pass some argument? RE: How to pass options to the booted system via PXECONFIG script - robinsmidsrod - 2013-11-03 22:40 Not sure why you'd need an external file for that. Just add them to the imgargs line like this my_ip=${ip}. Then you can just read the value out of /proc/cmdline once Linux has booted. Since you already control /etc/rc.local it shouldn't be too hard. Remember you can also add a custom file to the initrd by doing something like this: Code: kernel nfs://192.168.13.5/var/www/nfsshare/casper/vmlinuz The specific "chip" file for your network card would then be available inside Linux as /tmp/chip.txt after the system is booted. If you point it at a web server instead of nfs you could even dynamically generate it with a simple CGI script. Lots of options available. RE: How to pass options to the booted system via PXECONFIG script - knatesan - 2013-11-07 20:35 Thanks for the response.. Here is what i wanted to achieve.. i want to Pass "test.txt" file to the pxebooted linux image. Below is what i tried.. "kernel nfs://192.168.13.5/var/www/nfsshare/casper/vmlinuz initrd nfs://192.168.13.5/var/www/nfsshare/casper/initrd.gz initrd nfs://192.168.13.5/var/www/nfsshare/test.txt /tmp/test.txt echo now booting... imgargs vmlinuz root=/dev/nfs boot=casper netboot=nfs nfsroot=192.168.13.5:/var/www/nfsshare/ boot" but its not working though.. any help/clue on how to pass file to the linux image ? RE: How to pass options to the booted system via PXECONFIG script - robinsmidsrod - 2013-11-08 12:57 The file is only available in memory until the pivot_root call is used to switch out of the ramdisk environment to your real root device (NFS). If you add init=/bin/bash (or /bin/sh or /bin/ash) you'll be dumped into a shell while the initrd is loaded, and you should be able to cat /tmp/test.txt. Not sure if you need to disable root=/dev/nfs or not to avoid the pivot_root call (as you're using the kernel-based NFS client). If it is still not there, you have another issue in your system which require more debugging information/logs to figure out. RE: How to pass options to the booted system via PXECONFIG script - knatesan - 2013-11-13 01:35 Thanks for the response! i dont want to get in to shell. Let me reiterate my situation: 1. I have a start up script"xyz.sh" that loads automatically when it PXE boots- - for this i have placed my script"xyz.sh" in /etc/rc.local 2. Now i need to pass one dynamic file"abc.txt" to the pxebooted kernel so that my script can parse it. - i need to put this in some folder after it pxeboots. Any clue or recommendations? Note: "xyz.sh" file is a static file and "abc.txt" is a dynamic file which i can place it in nfsshare folder. RE: How to pass options to the booted system via PXECONFIG script - robinsmidsrod - 2013-11-14 09:13 /etc/rc.local is too late to execute whatever script you want to interact with this abc.txt file, because it is already gone. When the kernel mounts your NFS-based root filesystem, the /tmp/test.txt file (as I explained earlier) that was injected into your initrd will no longer be available. Once the root filesystem is mounted the initrd in memory is destroyed to reclaim memory. At least that is how I understand it. Because of that, you'll need to do the following BEFORE the root filesystem is mounted: Mount another filesystem (could be another ramdisk mounted at /ramdisk), copy the /tmp/test.txt somewhere onto that filesystem, and THEN let the initrd continue its process with mounting the real root filesystem and so on. Then /ramdisk/test.txt should be available once /etc/rc.local is executed. All of this means you'll need to modify the initrd, unless casper (or the Ubuntu/Debian ramdisk) has a place you can inject your xyz.sh file so that it is executed before the real root fs is mounted. You'll need to read up on how the initrd is generated and what options are available for customization. Or you could just unpack it and study how it works. Remember /sbin/init is the process started by the kernel once it's done. |