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