Remove lfs-uefi.txt symlink
[linux_from_scratch_hints.git] / PREVIOUS_FORMAT / inittab.txt
blob4c9985ae73f65ac6e5ac46db45fc5366f29e3775
1 TITLE:          Adding extra stuff to inittab
2 LFS VERSION:    3.0-rc1
3 AUTHOR:         Laurence Withers <lwithers@lwithers.demon.co.uk>
5 SYNOPSIS:
6         Adding extra things to inittab gives you options such as more
7         consoles (if 6 isn't enough!), log files on a virtual terminal, and
8         programs such as `top'.
10 HINT:
14 0. Contents
15 -----------
17     1. Introduction
18     2. Adding extra consoles
19     3. Log files on a virtual terminal
20     4. Top on a virtual terminal
21     5. Caveats
23     Appendix A. Format of /etc/inittab explained
27 1. Introduction
28 ---------------
30     By editing /etc/inittab, you can achieve all sorts of nifty and
31 useful things. This file is the configuration of `init', the utility
32 which controls booting, shutting down, etc.; look at the LFS book for
33 some details, and also examine the /etc/inittab file given.
35     In this hint, I will show you how to add extra consoles (if, like
36 me, you appreciate having 10 or so consoles available), how to have a
37 virtual terminal display a log file, and how to run `top' (or any other
38 utility you like) on a virtual terminal.
40     Note that the virtual terminals used in this hint, /dev/tty1 to
41 /dev/tty12, correspond to the screens you get when you press Alt+F1 to
42 Alt+F12. If a VT is unused, then it won't pop up when you press its key;
43 it will only appear once some data has been sent to it.
47 2. Adding extra consoles
48 ------------------------
50     With the /etc/inittab that ships with LFS, you get six consoles (on
51 VTs 1 through 6). First, decide which VTs you want to have terminals on.
52 Then, add the following line to /etc/inittab for each console that you
53 want:
55 XXX:2345:respawn:/sbin/agetty ttyXXX 9600
57 (replace XXX with the number of the VT, 7-12).
59     If, like me, you don't want other people to see what was on the
60 screen after you finished with your console, you can use some trickery
61 to clear the screen after you logout. Firstly, create a script:
63 # cat >/sbin/agetty-init.sh <<EOF
64 >#!/bin/sh
65 ># /sbin/agetty-init.sh
66 >#  For clearing the screen after you have finished with a console.
68 >/sbin/agetty tty$1 9600
69 >clear >/dev/tty$1
71 >EOF
72 # chmod +x /sbin/agetty-init.sh
74     Then, in /etc/inittab, change the console lines. These are in the
75 same format as above. The stock LFS file will contain entries starting
76 1:, 2:, 3:, 4:, 5: and 6: (not l1: et al.; these are something else).
77 Find each such line and delete it. Now add the following line once for
78 each console you want:
80 cXXX:2345:respawn:/sbin/agetty-init.sh XXX
82 (replace XXX with the number of the VT you want, 1 through 12).
84     Remember that agetty will print the contents of /etc/issue to the
85 screen before its login prompt; you can use this to customise the
86 appearance of your login screens. Also, you can put any additional
87 actions into `agetty-init.sh' (before or after agetty is called); these
88 allow you to customise your system even more.
92 3. Log files on a virtual terminal
93 ----------------------------------
95     If you want a VT to display the contents of a log file, you can use
96 a simple entry in /etc/inittab. Add a line like the following:
98 log:2345:respawn:/usr/bin/tail -f --retry /var/log/sys.log >/dev/ttyXXX
100     Replace the initial `log:' with any 4-character name you like; as
101 long as each identifier is unique, there is no problem. For instance,
102 you could use `9x3d:', if it meant something to you. Replace the final
103 filename with the name of the log file you want to examine. Finally,
104 replace XXX with the number of the VT you want to output to.
108 4. Top on a virtual terminal
109 ----------------------------
111     `top' is a great program to have running on a spare VT! It lets you
112 see which processes are running, what your CPU is up to, how much memory
113 is in use, and so on. To get it running on a spare VT, use the following
114 line in /etc/inittab:
116 top:2345:respawn:/usr/bin/top d 1 s S c >/dev/ttyXXX </dev/ttyXXX
118     Replace XXX with the number of the VT you want to use. Also note the
119 parameters we pass to top: `d 1' sets the delay between updates to 1s
120 (change this if you want), `s' runs top in secure mode (see the man page
121 for details; basically, this stops any old user from killing processes),
122 and `S c' are aesthetic options. See `man top' for more info.
124     You can use this sort of line to add any program you like on a VT.
125 Note that you need to redirect both output and input for an interactive
126 program like top to work.
130 5. Caveats
131 ----------
133     If you are trying anything ambitious, please read the information
134 in Appendix A, below. This explains the format of /etc/inittab, so you
135 are less likely to make a mistake which needs rectifying. Also, before
136 you start messing with /etc/inittab, you should probably have some
137 backup way of booting into your system (for instance, I use an old SuSE
138 6.3 bootable CDROM).
140     Although nothing can really go disastrously wrong with this sort of
141 setup, sometimes your VTs can get scrambled by programs such as X and
142 any sort of graphical login manager. I don't know when this happens, or
143 how to avoid or rectify it, but it hasn't caused me any problems. Note
144 that I don't use a graphical login, however.
146     Jurgen Nagel has reported that his extra consoles don't work
147 correctly. He has fixed this by adding an initialisation field to the
148 agetty call:
150 c2:2345:respawn:/sbin/agetty -I \e[H\e[J tty2 9600
152     The initialisation is <escape>[H<escape>[J and this fixes his
153 problem. I can't reproduce this on any of my systems but if you get this
154 problem, just add the -I parameter to the agetty call. Thanks Jurgen!
158 Appendix A. Format of /etc/inittab explained
159 --------------------------------------------
161     For the version of init used in LFS, the /etc/inittab file has the
162 following format:
164 identifier:runlevels:actiontype:command
166 `identifier' is a unique identifier, from 1 to 4 characters. Make sure
167 you don't use duplicate identifiers in your file. The identifier has no
168 bearing on how init works; the names don't have to mean anything.
170 `runlevels' is a list of the runlevels in which this line should be
171 activated. Read `man init' for more detail about runlevels.
173 `actiontype' is one of the following:
174     respawn         run the command every time it finishes
175     wait            run the command when entering the runlevel, and wait
176                         for it to finish before moving on
177     once            run the command once when entering the runlevel
178     boot            executed only during system bootup (ignores
179                         runlevels)
180     bootwait        as above, only wait for finish
181     off             ignore this entry
182     initdefault     this actually specifies which runlevel is considered
183                         the default on the system (usually 3)
184     sysinit         executed during bootup, before boot/bootwait
185     ctrlaltdel      what to do when the user hits ctrl+alt+del
187     There are some more actions, but these are more advanced. Details
188 are available (see `man inittab' and possibly `man init').
190 `command' is the commandline to run. Note that the PATH environment
191 variable isn't set: you need to specify the whole path to any executable
192 files.