注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Stacked Runlevels"

From Funtoo
Jump to navigation Jump to search
(Created page with "It is common for a laptop user to use DHCP most of the time; however, they may also need to periodially connect to network where a static network configuration is required. This ...")
 
Line 3: Line 3:
The recommended approach for doing this is to use multiple, stacked runlevels. To do this, you will need to create two new runlevels which are children of the <tt>default</tt> runlevel. This can be done like this:
The recommended approach for doing this is to use multiple, stacked runlevels. To do this, you will need to create two new runlevels which are children of the <tt>default</tt> runlevel. This can be done like this:


<pre># install -d /etc/runlevels/static
<console># ##i##install -d /etc/runlevels/static
# install -d /etc/runlevels/dynamic</pre>
# ##i##install -d /etc/runlevels/dynamic</console>
Two new runlevels, <tt>static</tt> and <tt>dynamic</tt>, have now been created. Now, we will make these runlevels children of the <tt>default</tt> runlevel using the following commands:
Two new runlevels, <tt>static</tt> and <tt>dynamic</tt>, have now been created. Now, we will make these runlevels children of the <tt>default</tt> runlevel using the following commands:


<pre># rc-update --stack add default static
<console># ##i##rc-update --stack add default static
# rc-update --stack add default dynamic</pre>
# ##i##rc-update --stack add default dynamic</console>
Now, the runlevels <tt>static</tt> and <tt>dynamic</tt> will consist of anything in <tt>default</tt> '''plus''' any additional scripts you add to each new runlevel.
Now, the runlevels <tt>static</tt> and <tt>dynamic</tt> will consist of anything in <tt>default</tt> '''plus''' any additional scripts you add to each new runlevel.


To complete our multiple network configuration, we would now do something like this:
To complete our multiple network configuration, we would now do something like this:


<pre># rc-update add netif.eth0 static
<console># ##i##rc-update add netif.eth0 static
# rc-update add dhcpcd dynamic</pre>
# ##i##rc-update add dhcpcd dynamic</console>
To switch to or between each runlevel, we would type:
To switch to or between each runlevel, we would type:


<pre># rc static</pre>
<console># ##i##rc static</console>
Or:
Or:


<pre># rc dynamic</pre>
<console># ##i##rc dynamic</console>
If we wanted to boot into <tt>dynamic</tt> by default, this could be done by editing <tt>/etc/inittab</tt> and modifying this line:
If we wanted to boot into <tt>dynamic</tt> by default, this could be done by editing <tt>/etc/inittab</tt> and modifying this line:



Revision as of 19:16, January 11, 2014

It is common for a laptop user to use DHCP most of the time; however, they may also need to periodially connect to network where a static network configuration is required. This is a situation where a Funtoo Linux machine will require multiple network configurations. Funtoo Linux supports this.

The recommended approach for doing this is to use multiple, stacked runlevels. To do this, you will need to create two new runlevels which are children of the default runlevel. This can be done like this:

root # install -d /etc/runlevels/static
root # install -d /etc/runlevels/dynamic

Two new runlevels, static and dynamic, have now been created. Now, we will make these runlevels children of the default runlevel using the following commands:

root # rc-update --stack add default static
root # rc-update --stack add default dynamic

Now, the runlevels static and dynamic will consist of anything in default plus any additional scripts you add to each new runlevel.

To complete our multiple network configuration, we would now do something like this:

root # rc-update add netif.eth0 static
root # rc-update add dhcpcd dynamic

To switch to or between each runlevel, we would type:

root # rc static

Or:

root # rc dynamic

If we wanted to boot into dynamic by default, this could be done by editing /etc/inittab and modifying this line:

l3:3:wait:/sbin/rc default

To read as follows:

l3:3:wait:/sbin/rc dynamic