How to set custom Environment Variables during boot?


I’m doing a multiboot system where I need one of the boot options ( using Grub ) to set a number of custom environment variables e.g. “distro”.

Been googling for a solution but have come up empty handed.

Any ideas?

How do you mean environment variables, kernel options, at what stage of
the boot process do you need to set them? maybe some real examples of
the ones your wanting would help.

Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel
up 6 days 18:51, 4 users, load average: 0.45, 0.46, 0.42
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

Hi Malcolm.

The scenario is :

I boot the machine and I then select one of a number ( e.g. 3 ) boot options in Grub ( Normally “OpenSuse”, “Safe Mode” etc., but in this case “System Restore Dev.”, “System Restore Test” ). The only difference between these options are the settings ( e.g. “vga=378” ) in these cases something like “distro=dev” / “distro=test”.

In a script run on the booted system I can extract the value of the “distro” parameter ( in this case “test” ) and use it as input for a command line tool. Meaning that name entered as the value for the “distro” parameter is used for loading a file when the system is up and running.

You can read the kernel parameters out of /proc/cmdline and decide what to do depending on the values.

Hi ken_yap

I tried using the /proc/cmdline. However, it’s empty despite Grub having e.g. vga=0x314 during boot. Any ideas or code fragment to use?


Please disregard my last post… Misunderstood you… Solved the issue… Thx.