What''s the "earliest" place one can set an environment variable during Linux boot process?

1

I know I can set a variable in a shell startup file, but the thing is, I am trying to set up a POSIX-compatible environment, and a POSIX shell does not parse any startup files other than the one specified by the environment variable ENV. This presents a problem - currently my login starts the shell as bash, which I will try to replace with sh so Bash runs as POSIX shell - however then it will not parse the default startup files and I need ENV set to specify these. Which means as far as I understand that I need to specify ENV before login starts the shell, correct?

Now, how would I do that? I hope my question is clear, if not I will gladly redact it.

amn

Posted 2013-10-23T09:51:26.063

Reputation: 1 622

Try adding ENV= to the kernel command line. You would have to edit this in grub or whatever bootloader is used. – sawdust – 2013-10-23T18:59:33.330

I did, but the variable doesn't show up in any shell and is not even listed under any of the relevant processes (init, systemd-*, login, agetty) when inspecting /proc/$pid/environ. I too thought that was the solution, but it didn't work. I am suspecting that the variable is passed to the kernel, however it is supressed/removed shortly thereafter. – amn – 2013-10-24T07:45:09.173

No answers