Multiple network configurations at boot time. HOW?
Hi there,
Guys I have done some searching in here and could not find answer to my question. Here is my definition of what I am intend to do: When my Laptop starts I have this Lilo menu with two choices, Linux and WinXP. Then I liked to modify it a bit to something like this: - LinuxWork - LinuxHome - LinuxDHCP - WinXP no problem so far, I added those options into Lilo menu without any problems. So next idea was to pass an parameter that is telling my Linux to use different network configuration files. Before that I created few additional config files: - rc.inet1.work.conf - rc.inet1.home.conf - rc.inet1.dhcp.conf It can be that names are bit different(i can not see them becouse I am working on WinXP at the moment) but it is idea that I try to explain. So if I look at rc.inet1.conf, I can see that it calls an external file to get system network configuration. Once again do not try to fix your self on names of files, I am typing out of my head... so my idea is this: - LILO promts - I choose an option (LinuxDHCP) - My rc.d network configuration files read my boot option and configurates my network. now... how do I acomplish that??? How can I pass any information to my system? I hope that I was clear about my explanation and that You can help me. Sorry for my English. thanks for any hints Fairy PS Pleas do not post anything to switching to GRUB or any other options like that, I like to stick with my Lilo :Pengy: |
This isn't as easy as it maybe should be. The kernel can be told to run a small DHCP client,
but when it does this it also expects the root filesystem to be NFS mounted. . . The kernel command line doesn't allow for passing parameters on to the rest of the system, but one option is to abuse this command line. In your /etc/lilo.conf, for each "image=" section (each section you describe above, LinuxWork, etc.), have an "append=" line with one of the options (If you have a default/global "append=", you need to include all of the options from the global "append=" in your specific "append=" lines) one that you know will be ignored by the kernel, but that describes where you are. For example: Code:
image = /boot/vmlinuz-2.6.2 Code:
#!/bin/sh This may be dangerous if, for example, the kernel developers decide that Location is a reserved word for some reason. . . |
Compile 3 differents kernel, each time with a different EXTRAVERSION flag. Then you can choose which config to load in function of uname -a output ;)
|
After reading my post above, I realized that this is essentially already done for you via the "label=" option in /etc/lilo.conf. . .
if you cat /proc/cmdline, you'll notice that the parameter BOOT_IMAGE= has a value that is the label given in your /etc/lilo.conf, so you don't have to abuse the kernel command line, you just change the search for Location= to a search for BOOT_IMAGE=, and the rest is similar to my post above (except that you don't need to use the append= option for each image). |
tnx moses you feel me :-)
but You lost me... ;) this is my lilo.conf: ... image = /boot/vmlinuz root = /dev/hdc4 label = Work read-only image = /boot/vmlinuz root = /dev/hdc4 label = Home read-only image = /boot/vmlinuz root = /dev/hdc4 label = DHCP read-only ... so if I understand You well, now I have to look into my /proc/cmdline and find something in it... correct? if so then I have bad news there is nothing in it... or I am missing something? |
moses, hold a sec...
after reading your post over and over again... ;) I found this out: I have to write this script into file: /proc/cmdline am I correct? |
if so... I can not write anything in it... file is 444
so as I am new to Linux; I do not know of I may play with this file just liek that and change promissions... :newbie: |
No, you add it to your network initialization script. Your network init script currently has one setup procedure (maybe one static and one DHCP) for your network device, and you'll have to change the script to reflect the fact that you want it to do different things depending on where you say you are. So, you'll have to modify the file so that it first checks to see where you are (by looking at /proc/cmdline, pulling out the label of your boot option, and naming that something like "Location"), then does the appropriate thing, which depends on where you say you are.
So, your lilo.conf has the labels, Work, Home, and DHCP. This means that if you Code:
cat /proc/cmdline Code:
auto BOOT_IMAGE=Work ro root=301 Hope this helps. |
me bows to moses!!!
Man, You made my day (night actually...). I like to thank You very much for this very helpfully informations and understanding. As my problem is solved, I like to post my config files that rest of the community can use it too. Once again the idea: - by choosing a boot profile in LILO we determine what network configuration will we use. So here is my lilo.conf: Code:
# LILO configuration file Code:
# Get the configuration information from /etc/rc.d/rc.inet1.conf: I am not saying that this is most clean solution but it is good start to make it work. moses thank You very much cheerz Fairy |
Code:
cat /proc/cmdline | awk 'BEGIN {FS = "="} { if ($1 == "BOOT_IMAGE") print $2}' | awk 'BEGIN {FS = " "} {print $1}' To explain why I'm confused, here's the result of cat /proc/cmdline on my machine: Code:
auto BOOT_IMAGE=Slack9_262 ro root=301 idebus=66 ide0=dma ide1=dma Code:
cat /proc/cmdline | awk 'BEGIN {RS = " "} {FS= "=" } { if ($1 == "BOOT_IMAGE") print $2}' Your way (using the awk on my machine, GNU Awk version 3.1.1) actually first sets the field separator to "=" (so I have only one record, which is the entire line), this means that my $1 will never actually be equal to "BOOT_IMAGE" because the first field is, "auto BOOT_IMAGE" Since the first field doesn't match, the "print $2" never happens, so I get a NULL piped to the second awk. This means that the second awk command doesn't parse anything and all I get is a NULL. Just curious. . . I assume your command works for you, which really has me wondering what are the differences between our machines. . . |
here you go:
Code:
cat /proc/cmdline 2. my machine with my command Code:
cat /proc/cmdline | awk 'BEGIN {FS = "="} { if ($1 == "BOOT_IMAGE") print $2}' | awk 'BEGIN {FS = " "} {print $1}' sorry that I did not explained that before... |
Thanks! I screwed up with my awk statement. . . Try this:
Code:
awk 'BEGIN {RS = " "; FS = "=" } {if ($1 == "BOOT_IMAGE") print $2}' My bad. . . Thanks! =-} |
Actually it is funny... I do not know thing about awk or stuff in /proc/...
But with your help, moses, I have laptop that works great at my work and at home :p ... As I sed I am n00b in Linux world, but one thing I have learned about Linux is that it is harder to get it optimized but it is possible to optimized it VERY well. I have still some things that I will like to improve on my Laptop but one step at the time. Even more funny is fact that most people that I know are saying that Slack is hard to use... My answer is: Once You Slack You never go back. This laptop of mine I put CD-ROM in it, half hour later Slack was working :) moses, thank You for your help. |
Good luck!
Remember to return the favor by helping someone else whenever you can. That's the way (and really, the only way) Linux will stay alive and well. =-} |
Quote:
But this one is a bit far call... But present on my wish list ;) |
All times are GMT -5. The time now is 04:24 PM. |