LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   nano tip: set a variable in the boot command line to be used later (http://www.linuxquestions.org/questions/slackware-14/nano-tip-set-a-variable-in-the-boot-command-line-to-be-used-later-4175453805/)

Didier Spaier 03-12-2013 01:55 PM

nano tip: set a variable in the boot command line to be used later
 
Seen this in the Current (pre-release) ChangeLog for x86 (32-bit):
Code:

a/syslinux-4.06-i486-1.txz:  Upgraded.
      Actually, dropping back from 5.01, which has a bug that prevents extra
      options given at the boot prompt from being passed to the kernel.
      We'll look at this again when 5.02 comes out.

Slackware's installer make use of this feature and this reminds me that I could share a little tip.

In addition to passing options to the kernel (and possibly modules) it is possible to set a shell variable in the command line and use its value after booting. You can even quote it. For instance if I write following boot command line:
Code:

Linux didier="dumb bunny"
once logged in after booting I get this:

root@slackware:/ echo $didier
dumb bunny
root@slackware:/


I just tried that inside Slackware's installer, I'll check that it works on an installed system.

PS sorry for the missing code tags, there seems to be a bug in the parser used by this forum.

David the H. 03-12-2013 03:08 PM

I'd suggest using the /etc/environment file instead, if you need truly global variables.

But actually, I wouldn't use either of these for trivial settings. When you do this, the value becomes available literally everywhere in the system. All processes inherit it. Just use your /etc/profile or similar shell startup script, the way they're intended.

Didier Spaier 03-12-2013 03:24 PM

Quote:

Originally Posted by David the H. (Post 4910196)
When you do this, the value becomes available literally everywhere in the system.

That's exactly what makes that so handy in some circumstances. For instance if append LANG=fr or kbd=fr.map to the boot command line of Slackware's installer, I can gather the values directly afterwards, no need to even parse /proc/cmdline.


All times are GMT -5. The time now is 02:48 AM.