Menu

Variables in grub.cfg

2019-06-14
2019-11-25
  • Rainer Friedrich

    Hello, can I set own variables in grub.cfg and use them in ocs_prerunXX? Tried a couple of thing, did not work and Google could not help.

    Shalom
    F. :-)

     
  • Bryan Cooper

    Bryan Cooper - 2019-06-17

    What were the variables you have used? Please show some examples so that people can judge for you.

     
  • Rainer Friedrich

    Tried set variable="mount......"

    Then using it in ocs_prerun="%variable%" and "$variable" and so.

     
  • Bryan Cooper

    Bryan Cooper - 2019-06-17

    You were right. In this case these variables will not be honored.
    However, you can have a script to do that. I meant to put your variables in your scripts, then assign ocs_prerun to run your script. This is more flexable.

     
  • Rainer Friedrich

    This would be fine, where do I have to put the file in my pen drive? Serahced for a while in the web (maybe with the wrong search..) and did not find anything enlightning.

     
  • Bryan Cooper

    Bryan Cooper - 2019-06-17

    For live USB flash drive, the root (/) directory is mounted as /run/live/medium/, hence you can put your script in the root (/) directory of USB flash drive, and when it's booted, assign it as something like ocs_prerun="bash /run/live/medium/myscript.sh"

     
  • Rainer Friedrich

    sounds great, will test it. Thanks for the help.

     
  • Rainer Friedrich

    The script hint was great, I used it since. A problem with variables in grub ist also, that variables are not accessible if you try to use them in submenues, eveything defined outside the submenu is inaccessible, because this menue is started in a new context. Discovered it recently as I tried to use variables for the parameters in once. If I use onyl a flat menue everthing runs smooth.

     

Log in to post a comment.

Auth0 Logo