doc/Makefile: fix non posix shell syntax
[grml-autoconfig.git] / doc / grml-autoconfig.1.txt
1 grml-autoconfig(1)
2 ==================
3
4 Name
5 ----
6 grml-autoconfig - main bootup process of a grml system
7
8 Synopsis
9 --------
10 None - it is a framework. See grml-autoconfig(8) for information regarding
11 the interface script.
12
13 Introduction
14 ------------
15
16 By using the config framework, it is possible to customize Grml's startup in a
17 multitude of ways. It allows to:
18
19 - execute one or more scripts on startup
20 - install Debian packages from deb files on startup
21 - unpack configuration on startup
22
23 The combination of Debs, Configuration and Scripts is called DCS in Grml. DCS
24 can be read from the Live Image itself, from an arbitrary file system on the
25 local system which is marked with the volume label GRMLCFG, or from the file
26 system pointed to by the myconfig boot parameter.
27
28 The DCS handling is controlled by a number of boot parameters.
29
30 The scripts save-config and restore-config can be used to create and handle
31 files called 'grml configuration archive', abbreviated GCA. save-config stores
32 the running configuration inside a GCA; restore-config is a script to restore a
33 configuration from a GCA.
34
35 [TIP]
36 A GCA is a plain bzip2 compressed tar archive. All the files are generated
37 starting from the root-directory '/' so it is easy to handle. You can generate
38 configuration archives manually as well. save-config is just a frontend which
39 should make it easier to use.
40
41 The grml-autoconfig code has been re-worked in August 2009. This document
42 handles both the behavior of Grml releases up to 2009.05  (see
43 <<up-to-200905,section 'Behavior up to grml 2009.05'>>) and the current behavior
44 (see <<current-versions,section 'Behavior in current Grml versions'>>). Great
45 care has been taken to provide maximum backwards compatibility during the
46 rewrite.
47
48 [IMPORTANT]
49 Starting with grml release 2009.05 its possible to use root persistency on grml.
50 This means you can store your settings and reuse them on reboot, without having
51 to deal with this config framework. Visit
52 link:http://wiki.grml.org/doku.php?id=persistency for further information.
53
54 [[up-to-200905]]
55 Behavior up to grml 2009.05
56 ---------------------------
57
58 This section applies to all Grml versions older than and including release 2009.05.
59
60 Autoconfiguration
61 ~~~~~~~~~~~~~~~~~
62
63 By default the booting process tries to mount a device labeled 'GRMLCFG'. This
64 provides the possibility to restore a configuration (named config.tbz) and
65 execute a script (named grml.sh) without the need to specify any bootparams. If
66 you want to disable this feature please take a look at the 'noautoconfig'
67 bootparam.
68
69 Boot parameters
70 ~~~~~~~~~~~~~~~
71
72 As you probably know you can adjust boot parameters on the bootprompt.  You want
73 to set some boot parameters permanently? That's possible via adding a directory
74 named 'bootparams' to the Grml-ISO which has to be located at the root-directory
75 /bootparams/ (note: the directory is known as /live/image/bootparams/ on a
76 _running_ grml system then). Place a textfile inside the directory containing
77 the boot parameters which should be appended to default ones (this corresponds
78 to booting without any special parameters). If you want to be able to boot from
79 your Grml-CD you have to create a multisession CD. See the <<X7,usage
80 scenarios>> for more details how to use it or consider booting from a USB device
81 (checkout grml2usb).
82
83 The following boot parameters are supported. Use them at the (isolinux)
84 bootprompt as documented here.
85
86 myconfig::
87
88    This parameter is for restoring configuration using the file config.tbz
89     on the specified device. Usage examples:
90
91   myconfig=/dev/sda1                        => use file config.tbz from usb-device
92   myconfig=/dev/fd0                         => use file config.tbz from floppy-disk
93   myconfig=/dev/sda1 file=config_foobar.tbz => use file config_foobar.tbz from usb-device
94
95 home::
96
97     This parameter is for setting a specific partition as home directory.
98     Usage examples:
99
100   home=/dev/sda3    =>  use /dev/sda3 as the homepartition
101   home=scan         =>  scan through the available partitions and search
102                         for file grml.img
103
104 partconf::
105
106     This parameter mounts the specified device in read-only mode and tries to
107     copy all files specified in /etc/grml/partconf to the Grml system. This
108     provides the possibility to use the configuration of a harddisk
109     installation. For example using the network configuration (which is
110     specified in /etc/network) is possible using this boot parameter. Usage
111     example:
112
113   partconf=/dev/sda2 => try to mount /dev/sda2 and copy files specified
114                         in /etc/grml/partconf to the booted Grml system
115
116 netconfig::
117
118     Use this parameter to restore configuration using wget to download a
119     configuration file from specified destination. Usage example:
120
121   netconfig=server.tld/path/to/config.tbz  =>   restore configuration using wget to download file config.tbz
122
123 extract::
124
125     Extract specific directories from configuration archive. Notice: This
126     bootparam is useful only with bootparams which are able to extract
127     configuration archives.
128
129   extract=/home/grml         => extract only /home/grml from archive
130   extract=/etc               => extract only /etc from archive
131   extract=/home/grml/config  => extract only $HOME/config from archive
132
133 scripts::
134
135     This parameter executes a script located in the root-directory /scripts/ on
136     the Grml media/ISO (note: the directory is known as /live/image/scripts/ on
137     a _running_ Grml system then). Usage examples:
138
139   scripts               =>   run script [/live/image]/scripts/grml.sh
140   scripts=foobar.sh     =>   run script foobar.sh in [/live/image]/scripts/
141
142 config::
143
144     This parameter restores a configuration using root-directory /config/ on the
145     Grml media/ISO (note: the directory is known as /live/image/config on a
146     _running_ Grml system then). Usage examples:
147
148   config                    =>   restore configuration using file config.tbz from directory [/live/image]/config/
149   config=config_foobar.tbz  =>   restore configuration using file config_foobar.tbz from directory [/live/image]/config/
150
151 debs::
152
153     This parameter allows automatic installation of deb packages while booting.
154     The debian packages have to be located in the root-directory /debs/ on the
155     Grml media/ISO (note: the directory is known as /live/image/debs/ on a
156     _running_ Grml system then). Usage examples:
157
158   debs              =>   install all debian packages (suffix .deb) from directory [/live/image]/debs/
159   debs=01           =>   install all debian packages (suffix .deb) starting with 01 in the filename from directory [/live/image]/debs/
160
161
162 noautoconfig::
163
164     Deactivate automounting. By default the command 'mount' tries to mount a
165     device with label 'GRMLCFG'. If you specify the noautoconfig bootparam the
166     automounting will be deactivated.
167
168   noautoconfig            => disables auto mounting of label 'GRMLCFG'
169
170 [[current-versions]]
171 Behavior in current Grml versions
172 ---------------------------------
173
174 This section applies to all Grml versions newer than release 2009.05.
175
176 The central concept of grml-autoconfig is the DCS directory which holds debs,
177 configuration and scripts which are used during system startup.
178
179 Determination of DCS directory
180 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181
182 The DCS directory defaults to the root directory of the GRML live image. If a
183 file system labeled GRMLCFG is found, the DCS directory is the root directory of
184 that file system. Alternatively, the myconfig boot parameter can be used to
185 directly specify a device which is then taken as DCS directory
186 (myconfig=/dev/sda1, for example).
187
188 Without any additional boot parameters, the GCA at DCSDIR/config.tbz is
189 automatically unpacked and DCSDIR/scrips/grml.sh is automaitcally executed on
190 system startup. The 'noautoconfig' boot parameter disables this automatic
191 behavior.
192
193 Boot Parameters
194 ~~~~~~~~~~~~~~~
195
196 The following boot parameters are supported. Use them at the (isolinux)
197 bootprompt as documented here.
198
199 myconfig::
200
201    This parameter directly sets DCSDIR to the root directory of the specified
202    device. Usage examples:
203
204   myconfig=/dev/sda1                        => read DCS from usb-device
205   myconfig=/dev/fd0                         => read DCS from floppy-disk
206
207 home::
208
209     This parameter is for setting a specific partition as home directory.  Usage
210     examples:
211
212   home=/dev/sda3    =>  use /dev/sda3 as the homepartition
213   home=scan         =>  scan through the available partitions and search
214                         for file grml.img
215
216 partconf::
217
218     This parameter mounts the specified device in read-only mode and tries to
219     copy all files specified in /etc/grml/partconf to the Grml system. This
220     provides the possibility to use the configuration of a harddisk
221     installation. For example using the network configuration (which is
222     specified in /etc/network) is possible using this boot parameter. Usage
223     example:
224
225   partconf=/dev/sda2 => try to mount /dev/sda2 and copy files specified
226                         in /etc/grml/partconf to the booted Grml system
227
228 netconfig::
229
230     Use this parameter to restore configuration using wget to download a GCA
231     from the specified destination. Usage example:
232
233   netconfig=server.tld/path/to/config.tbz  =>   restore configuration using wget to download file config.tbz
234
235 extract::
236
237     Extract specific directories from the GCA which needs to be specified by
238     other means.
239
240   extract=/home/grml         => extract only /home/grml from archive
241   extract=/etc               => extract only /etc from archive
242   extract=/home/grml/config  => extract only $HOME/config from archive
243
244 scripts::
245
246     This parameter executes scripts. If an optional path is given, it is
247     relative to DCSDIR. If it points to a directory, all scripts inside this
248     directory are executed. If the path points to a file, this single file is
249     executed. If no path is given, it defaults to scripts/grml.sh. Usage
250     examples:
251
252   scripts               =>   run script DCSDIR/scripts/grml.sh
253   scripts=foobar.sh     =>   run script foobar.sh in DCSDIR
254   scripts=foobar        =>   run all scripts inside DCSDIR/foobar directory
255
256 config::
257
258     This parameter restores a configuration using a GCA. If an optional path is
259     given, it is relative to DCSDIR. If no path is given, it defaults to
260     DCSDIR/config.tbz. Usage examples:
261
262   config                    =>   restore configuration using file DCSDIR/config.tbz
263   config=config_foobar.tbz  =>   restore configuration using file DCSDIR/config_foobar.tbz
264
265 debs::
266
267     This parameter allows automatic installation of deb packages while booting.
268     The path is relative to DCSDIR, not optional and is a shell wildcard. All
269     Files matching the wildcard are installed in a single dpkg --install call.
270     For backwards compatibility, if no slash is contained in the path, it is
271     taken relative to DCSDIR/debs.
272
273     Usage examples:
274
275   debs=*.deb        =>   install all debian packages (suffix .deb) from directory DCSDIR/debs/
276   debs=foo/01*.deb  =>   install all debian packages (suffix .deb) starting with 01 in the filename from directory DCSDIR/foo
277
278
279 noautoconfig::
280
281     Deactivate automounting. By default the scripts try to mount a device with
282     label 'GRMLCFG'. If you specify the noautoconfig bootparam this automounting
283     will be deactivated.
284
285   noautoconfig            => disables auto mounting of label 'GRMLCFG'
286
287
288 Permanently adjust boot parameters
289 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290
291 As you probably know you can adjust boot parameters on the bootprompt.  You want
292 to set some boot parameters permanently? That's possible via adding a directory
293 named 'bootparams' to the Grml ISO which has to be located at the root-directory
294 /bootparams/ (note: the directory is known as /live/image/bootparams/ on a
295 _running_ Grml system then). Place a textfile inside the directory containing
296 the boot parameters which should be appended to default ones (this corresponds
297 to booting without any special parameters).
298
299   mkdir bootparams
300   echo lang=de > bootparams/my_bootparams
301
302 Then burn a multisession CD where directory bootparams is located in the root
303 directory of the CD.
304
305 [NOTE]
306 Not all boot parameters can be used via /bootparams/. This is a limitation of
307 the way the kernel and userspace retrieve boot parameters. Boot parameter
308 regarding the kernel definitely do *NOT* work. Boot parameter related to
309 grml-autoconfig (the main part of the boot process in Grml running in userspace,
310 being all the stuff after startup of udev) are expected to work. Boot parameter
311 related to initrd/initramfs (the part between 'Searching for GRML file' and
312 startup of udev) are *NOT* covered by /bootparams/ as well yet.
313
314 TIP: the application k3b (not available on the live-CD but available through the
315 Debian repositories) provides an easy to use interface for doing the
316 multisession task.
317
318 [[X7]]
319 Usage scenarios
320 ---------------
321
322 Personal configuration files
323 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324
325 You are a fan of the editor vim? Great. You probably have your own ~/.vimrc and
326 want to use it on the Grml system. You also don't like the default zsh
327 configuration and want to use your own ~/.zshrc?  How to procede? Copy your
328 .vimrc and .zshrc to $HOME of user 'grml'.  Place additional files in
329 $HOME/config. Now create a configuration for your files running:
330
331   save-config -home -configdir
332
333 Now you should have a file named config.tbz containing your configuration files.
334 You can copy the archive to a webserver and restore it via downloading during
335 reboot using the following commandline on bootprompt:
336
337   grml netconfig=server.tld/path/to/config.tbz
338
339 You don't have network access but own a floppy drive? Copy the file to a floppy
340 disk and boot with:
341
342   grml myconfig=/dev/fd0
343
344 Floppy is to small or to slow? Ok, let's use a usb device:
345
346   grml myconfig=/dev/sda1
347
348 Network configuration
349 ~~~~~~~~~~~~~~~~~~~~~
350
351 You need a specific network setup and want to use your own
352 /etc/network/interfaces by default? Generate the configuration archive running
353 the following command as user root:
354
355   save-config -etc
356
357 Now you should have a file named config.tbz containing your configuration files.
358 If you want to use it with a floppy disk copy the file to a floppy and boot via
359 using the following command on bootprompt:
360
361   grml myconfig=/dev/fd0
362
363 Floppy is to small or to slow? Ok, let's use a usb device:
364
365   grml myconfig=/dev/sda1
366
367 You do have an existing harddisk installation and want to use its configuration?
368 Let's say the debian system is located in /dev/sda2. You want to use the
369 directory /etc/network. This directory is activated by default in
370 /etc/grml/partconf so we don't have to do any further work.  We just need to
371 activate it via using the following commandline on bootprompt:
372
373   grml partconf=/dev/sda2
374
375 Automatic installation of debian packages
376 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377
378 You have a specified debian package named 'foobar.deb' and want to use it with
379 (therefore: install it on) Grml by default? Notice: this feature is useful
380 especially for grml-small (a ~100 MB ISO). If you want to use it with the large
381 version of Grml you might have to overburn the ISO.
382
383 Let's assume you have burned the Grml iso to a CD-RW using a commandline like:
384
385   cdrecord dev=/dev/hdc -v -multi -tao grml_0.5.iso
386
387 Now create a directory named debs and place foobar.deb in it:
388
389   mkdir debs/ && cp foobar.deb debs/
390
391 Notice: This directory will be located in /live/image after burning the second
392 session.
393
394 Now create the second session containing this directory:
395
396   mkisofs -M grml_0.5.iso -C `cdrecord -msinfo dev=/dev/hdc` -R -o 2nd_session.iso debs
397
398 Finally append the second session to the cd using:
399
400   cdrecord dev=/dev/hdc -v -multi -tao 2nd_session.iso
401
402 TIP: the application k3b (not available on the live CD but available through the
403 Debian repositories) provides an easy to use interface for doing the
404 multisession task.
405
406 Now boot from your new personalized Grml CD using the debs parameter:
407
408   grml debs
409
410 Run your own commands on startup
411 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412
413 You know that booting with 'grml service=foobar' executes /etc/init.d/foobar
414 when booting Grml. But you want to setup a more complex network configuration,
415 adjust some other stuff and so on on your own? Just write a script named grml.sh
416 which does the job and use own of the mentioned bootparams. Let's say you have
417 placed grml.sh on your usb device (usb stick) then use the following commandline
418 on bootprompt:
419
420   grml myconfig=/dev/sda1
421
422 Or even better: create a floppy disk with label GRMLCFG running:
423
424   fdformat /dev/fd0   # format the floppy disk if not done already
425   mkfs.ext2 -L GRMLCFG /dev/fd0   # now create ext2 filesystem with label GRMLCFG on it:
426
427 TIP: several filesystems provide the possibility to provide a label.  For
428 example FAT provides this through: 'mkfs.vfat -n GRMLCFG /dev/sda1' (attention:
429 this will destroy data on /dev/sda1 of course!). Take a look at the
430 documentation/manpage of the filesystem you want to use.
431
432 Now place your configuration archive (see save-config and the other usage
433 scenarios) and the script grml.sh on the floppy disk. Now you can boot your
434 system without specifying any bootparameters on bootprompt because devices
435 labeled with GRMLCFG are mounted readonly and used by default. If you did not
436 label your device you can use the device anyway using 'grml myconfig=/dev/ice'
437 on the bootprompt.
438
439 Debug remote systems
440 ~~~~~~~~~~~~~~~~~~~~
441
442 You are responsible for a customer's system in her data center. The system has
443 failed and you need to debug from remote, and the remote hands available in the
444 data center do not have enough knowledge to get Grml booted and configure the
445 network without external help?
446
447 If the hard disk of the system is still available, you hopefully have saved a
448 configuration file with IP address, netmask and default gateway somewhere on
449 that hard disk. Grml can use the information found on a partition. Take a look
450 at the 'partconf' boot parameter.  Usage example: 'grml partconf=/dev/sda2'
451 copies files defined in /etc/grml/partconf from /dev/sda2 to the Grml system. As
452 /etc/network is predefined in /etc/grml/partconf the configuration from
453 /dev/sda2 will be taken.
454
455 Or you use a standard Grml medium and have grml read IP address, netmask and
456 default gateway from another medium like a floppy or an USB stick. Take a look
457 at the script saveconfig and the boot parameter myconfig.
458
459 Or you put a grml.iso file on your hard disk (maybe in /boot/grml) or on an USB
460 stick, use grub to boot from there and place debs, configuration scripts or Grml
461 configuraton archives alongside the .iso.
462
463 Use persistent home directory
464 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465
466 You want to use a persistent home directory which includes all the files located
467 in $HOME. Use the script mkpersistenthome to create such a persistent home
468 directory. You have the options to either use a specific partition as your home
469 directory or add a loopback file named grml.img on the specified partition (the
470 default).
471
472 TIP: /dev/external in the partition selection of mkpersistenthome is an usb
473 device without partitions. /dev/external1 corresponds to the first partition on
474 an usb device (usually an usb stick).
475
476 After running the script mkpersistenthome you can use the boot parameter home to
477 activate the home directory. If you are using the option with the loopback file
478 (grml.img) you can boot via:
479
480   grml home=scan
481
482 which will scan through the partitions and if a file grml.img is found it will
483 be mounted as your $HOME-directory. If you want to use a partition as your home
484 directory specify the device as an option. If you want to use /dev/sda2 as your
485 $HOME boot via:
486
487   grml home=/dev/sda2
488
489 Notice: the files located in /etc/skel will be copied to the partition (but will
490 not overwrite any files).
491
492 Bugs
493 ----
494 If you find a bug please report it. See link:http://grml.org/bugs/ for details
495 about how to report bugs.
496
497 See also
498 --------
499 grml-autoconfig(8), mkpersistenthome(1), restore-config(1), save-config(1)
500
501 Author
502 ------
503 (c) 2005++, Michael Prokop <mika@grml.org>