Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using Gentoo's Runlevels
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
ka0ttic
Retired Dev
Retired Dev


Joined: 23 Oct 2003
Posts: 46
Location: Ormond Beach, FL

PostPosted: Tue Feb 17, 2004 11:48 am    Post subject: Using Gentoo's Runlevels Reply with quote

Using Gentoo's Runlevels
Aaron Walker <ka0ttic at cfl dot rr dot com>

Introduction

This guide attempts to dive further into the topic of using Gentoo's runlevels, than is discussed in the Gentoo RC Init Guide. Laptop owners should find this guide especially useful, since they often find themselves needing different “Profiles”. Desktop users can also benefit from playing around with Gentoo's runlevels. I assume that you know basic UNIX commands, how to edit files, and how to use rc-update (if you are reading this, then you probably have Gentoo installed, so you must've used rc-update).

Runlevels in Gentoo are a bit different from the traditional Init runlevel system. Init's runlevels are still there and being used, as we will see shortly, however Gentoo decided to extend on them a bit to allow more flexibility. When I mention numbered runlevels, I am referring to init's runlevels and when talking about named runlevels, I am referring to Gentoo's runlevels, which live in /etc/runlevels. By default, Gentoo has three runlevels: boot, default, and nonetwork. With the exception of the boot runlevel (Gentoo's RC Init Guide says changing the name will break the system), the names of the others do not matter, provided they match up with what is in /etc/inittab.


Basics

In this section I will attempt to describe how the Gentoo Init system works. I am not an expert, so please correct me if anything in this section is incorrect. What follows is just what I have deduced from reading the relevant documents (Gentoo RC Init Guide, init's various man pages, etc).

Creating a new runlevel is as simple as making a new directory. Just create a new directory in /etc/runlevels, naming the directory whatever you want the runlevel to be called. For example, to create a new runlevel called noX just do:

Code:

# mkdir /etc/runlevels/noX


You can then use rc-update to add services to that runlevel. To switch between runlevels on the fly, just use rc. For example, to switch to our noX runlevel, we would just do:

Code:

# rc noX


This will stop any services that are running in the current runlevel that aren't in the noX runlevel, as well as start any services that are in the noX runlevel that aren't in the current runlevel.

If you only plan on switching runlevels on the fly, then you can skip the next section. However, if you are planning on being able to boot directly into a runlevel that you have created, then a little /etc/inittab hacking is in order.


Booting a custom runlevel

If you want to be able to boot directly into a non-default runlevel, you must edit /etc/inittab (as well as your boot loader config file, but more on that below).

I will not attempt to describe the traditional runlevel system (read the init(8 ) man page for that), other than to say that runlevels 0,1 and 6 are reserved by the system (they are used by shutdown, single-user mode, and reboot respectively). Init's runlevels are defined in /etc/inittab. As stated in the inittab(5) man page, an entry in /etc/inittab follows the general form:

id:runlevel:action:process

We will mainly be dealing with the last part of the entry, process, which defines which command to run for that particular runlevel. In Gentoo, the command that we will run is /sbin/rc name_of_runlevel (the same command used to switch runlevels on the fly). The default /etc/inittab is setup for runlevels 3-5 to run the default runlevel. Only one of these are needed, however. I would recommend leaving runlevel 3 to run the default runlevel (because by default runlevel 3 is the one that is booted if no runlevel is specified in the kernel boot parameters). So to continue with our example, to boot directly into the noX runlevel (we will use init's runlevel 4), we would change the line for runlevel 4 to:

l4:4:wait:/sbin/rc noX

There is one last step we need to take in order to be able to boot directly into a custom runlevel. We must edit the configuration file for our boot loader (you could also just append the runlevel number to the kernel boot parameters at boot time if that's what you want). In my grub.conf, I decided to create a seperate entry for the noX runlevel:

Code:

title=Gentoo Linux (no X)
    root (hd0,1)
    kernel (hd0,1)/vmlinuz root=/dev/hda7   4


It is identical to the normal entry, except you just append 4 (or whatever runlevel you chose in /etc/inittab) to the boot parameter line.


Examples

In this section, I provide some examples of how you could possibly use runlevels for various things. If anyone can think of any other nifty uses, PLEASE let me know, so I can add them (and maybe use them myself :wink: ).

noX

This is one I use fairly often. This runlevel contains everything in the default runlevel with the exception of XFS and XDM. Whenever I recompile a kernel, I usually boot into this runlevel to re-emerge kernel specific things (nvidia-kernel for example). This runlevel also comes in handy when you need to boot just to do something really quick and don't need X.

network connections

This is one that I use every day on my laptop. My HP ze4630 includes a National Semiconductor 10/100 NIC as well as a Broadcom 54G wireless chip. Since I use wireless the majority of the time, I load the wireless driver and interface in the default runlevel, and created a different runlevel for using the NatSemi module (I called it wired). So whenever I hook up the network cable, I can just run rc wired (if I have already booted), or just boot straight into the wired runlevel. I also use the default nonetwork runlevel when I am at work, since I have no network access (unfortunately).

Comments/corrections encouraged.

Have fun!
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Tue Feb 17, 2004 3:07 pm    Post subject: Reply with quote

I thought of creating different runlevels for Power Management. I'll have a closer look at this as soon as my laptop arrives :)
Back to top
View user's profile Send private message
CharlieS
Tux's lil' helper
Tux's lil' helper


Joined: 06 Nov 2003
Posts: 146
Location: Texas, USA

PostPosted: Tue Feb 17, 2004 4:16 pm    Post subject: Reply with quote

ka0ttic, how are you getting your broadcom wireless to work? i have emachine M5312 with 54 MB/s Broadcom and do not know how to get working.. please list all details....
Back to top
View user's profile Send private message
ka0ttic
Retired Dev
Retired Dev


Joined: 23 Oct 2003
Posts: 46
Location: Ormond Beach, FL

PostPosted: Tue Feb 17, 2004 11:40 pm    Post subject: Reply with quote

Quote:

ka0ttic, how are you getting your broadcom wireless to work? i have emachine M5312 with 54 MB/s Broadcom and do not know how to get working.. please list all details....


Unfortunetly, there is not an open-source driver. Instead, it uses some kind of emulation of the windows driver for the broadcom chip.

Check out Linuxant.com

BTW, its not free.. there is a 30 day free trial, and then $20 for a permanent liscence.

HTH,
Aaron
Back to top
View user's profile Send private message
El_Presidente_Pufferfish
Veteran
Veteran


Joined: 11 Jul 2002
Posts: 1179
Location: Seattle

PostPosted: Tue Feb 17, 2004 11:48 pm    Post subject: Reply with quote

is there an advantage to using a wired runlevel vs something like ifplugd?
Back to top
View user's profile Send private message
ka0ttic
Retired Dev
Retired Dev


Joined: 23 Oct 2003
Posts: 46
Location: Ormond Beach, FL

PostPosted: Tue Feb 17, 2004 11:57 pm    Post subject: Reply with quote

Quote:

is there an advantage to using a wired runlevel vs something like ifplugd?


Since I have never used ifplugd (nor heard of it either), I cannot comment on (dis)advantages of it. I rarely use my network cable (can't remember the last time I did), unless I need to transfer HUGE files.
Back to top
View user's profile Send private message
CharlieS
Tux's lil' helper
Tux's lil' helper


Joined: 06 Nov 2003
Posts: 146
Location: Texas, USA

PostPosted: Wed Feb 18, 2004 5:25 am    Post subject: Reply with quote

ka0ttic wrote:
Quote:

ka0ttic, how are you getting your broadcom wireless to work? i have emachine M5312 with 54 MB/s Broadcom and do not know how to get working.. please list all details....


Unfortunetly, there is not an open-source driver. Instead, it uses some kind of emulation of the windows driver for the broadcom chip.

Check out Linuxant.com

BTW, its not free.. there is a 30 day free trial, and then $20 for a permanent liscence.

HTH,
Aaron


How does this work ? Did you actually pay or is there a way around this? what if a format PC. will i have to pay again? how does that work? and with win driver will it run at a full 54MB/s?
Back to top
View user's profile Send private message
ka0ttic
Retired Dev
Retired Dev


Joined: 23 Oct 2003
Posts: 46
Location: Ormond Beach, FL

PostPosted: Wed Feb 18, 2004 11:04 am    Post subject: Reply with quote

Quote:

How does this work ? Did you actually pay or is there a way around this? what if a format PC. will i have to pay again? how does that work? and with win driver will it run at a full 54MB/s?


Well, my 30 days is up today, so I am getting ready to go to their site and pay. Not really any way around paying until someone develops some linux drivers. It's only $20 anyways.... Even if I gave you the license number, it would do you no good, since it's only valid for my MAC address.

You would not have to pay again. Provided you don't forget your password, then you will always be able to view your license details on their site.

So, at this point in time, if you have this chip/card (others are supported as well), then you don't really have any other choice (except not using it, of course).

According to iwconfig (part of the wireless-tools package), the speed gets up to 54.

--
Aaron
Back to top
View user's profile Send private message
CharlieS
Tux's lil' helper
Tux's lil' helper


Joined: 06 Nov 2003
Posts: 146
Location: Texas, USA

PostPosted: Wed Feb 18, 2004 6:41 pm    Post subject: Reply with quote

ka0ttic wrote:
Quote:

How does this work ? Did you actually pay or is there a way around this? what if a format PC. will i have to pay again? how does that work? and with win driver will it run at a full 54MB/s?


Well, my 30 days is up today, so I am getting ready to go to their site and pay. Not really any way around paying until someone develops some linux drivers. It's only $20 anyways.... Even if I gave you the license number, it would do you no good, since it's only valid for my MAC address.

You would not have to pay again. Provided you don't forget your password, then you will always be able to view your license details on their site.

So, at this point in time, if you have this chip/card (others are supported as well), then you don't really have any other choice (except not using it, of course).

According to iwconfig (part of the wireless-tools package), the speed gets up to 54.

--
Aaron


So the License number goes along with your MAC address i guess?? have you tried ndiswrapper or anything?
Back to top
View user's profile Send private message
Ian Goldby
Guru
Guru


Joined: 18 May 2002
Posts: 539
Location: (Inactive member)

PostPosted: Wed Feb 18, 2004 9:40 pm    Post subject: Reply with quote

Brilliant! I've been looking for a simple way to do this sort of thing for a while.

The Intel i810 graphics chipset doesn't allow 3D acceleration in modes greater than 1024x786, 16 bits per pixel. This is woefully too small for anything other than playing games.

I've now got one runlevel for normal (1280x960, 32 bpp) that I use almost all the time. And another runlevel for 1024x786, 16 bpp, 3D acceleration enabled for games (on those rare occasions :wink: )

In addition to the instructions, I just created a copy of my /etc/X11/XF86Config file with the modified settings, and a copy of /etc/init.d/xdm with the save_options line changed to
Code:
save_options "service" "${EXE} -config /etc/X11/XF86Config.accel"
This passes the location of the alternate XFree86Config.accel file to kdm when it starts up.

I haven't actually tested this yet as I'm in the middle of a long emerge, but I don't expect any problem.

Edit: It didn't work. It seems that the init file xdm must be called that. If you rename it, kdm won't start. In the end, I used sed to rewrite the colour depth setting in XFree86Config in an init script that has its dependency set to execute before xdm. This only works when starting kdm from a non-X run-level though, because it doesn't otherwise know it has to restart kdm. :evil:


Last edited by Ian Goldby on Tue Feb 24, 2004 11:56 am; edited 1 time in total
Back to top
View user's profile Send private message
sekh
n00b
n00b


Joined: 20 Dec 2002
Posts: 55

PostPosted: Mon Feb 23, 2004 11:35 pm    Post subject: Reply with quote

Thanks to ka0ttic for this post :) i was looking for something like this to manage my various networking profiles on my new laptop (wired static setup, wired dhcp or wlan dhcp) and this might be something along the lines of what i'm looking for :)

CharlieS: reguarding the wireless broadcom thing. My new laptop also includes a broadcom wireless. The card is a dell truemobile 1300 and the chipset is a broadcom 94306 or something along those lines. I've had great success using a free alternative to linuxants driver. There's one called ndiswrapper which is totally free and will also load linux drivers for you. I've heard that there are supposed to be a few bugs, but so far i haven't encountered any. You can check it out at http://ndiswrapper.sourceforge.net/
Also here is a nice thread about setting up the ndiswrapper thing:
https://forums.gentoo.org/viewtopic.php?t=125627
Back to top
View user's profile Send private message
ka0ttic
Retired Dev
Retired Dev


Joined: 23 Oct 2003
Posts: 46
Location: Ormond Beach, FL

PostPosted: Tue Feb 24, 2004 12:25 pm    Post subject: Reply with quote

sekh,

Glad you found it useful. Figures I find out about ndiswrapper AFTER I pay Linuxant for their driver..... :?

--
Aaron
Back to top
View user's profile Send private message
JSharku
Apprentice
Apprentice


Joined: 09 Feb 2003
Posts: 189
Location: Belgium

PostPosted: Sat Oct 01, 2005 10:52 pm    Post subject: Reply with quote

I found this thread through the Rediscovered Docs (compilation) and would like to add a few updates. First, the gentoo init documentation has been moved here. Next, you no longer have to mess with /etc/inittab, you can use bootlevel and softlevel instead, both are explained in the document; don't know if this was available at the time of writing this guide.

Sharku
_________________
If only life were portage-driven:
Code:
USE="-bitch -in-laws nice gorgeous smart" emerge girlfriend
*sigh*
--
Open Source for Windows!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum