]> rtime.felk.cvut.cz Git - novaboot.git/blob - README.md
Clarify and simplify starting and killing of DHCP and TFTP servers
[novaboot.git] / README.md
1 # NAME
2
3 novaboot - A tool for booting various operating systems on various hardware or in qemu
4
5 # SYNOPSIS
6
7 __novaboot__ \[ options \] \[--\] script...
8
9 __./script__ \[ options \]
10
11 __novaboot__ --help
12
13 # DESCRIPTION
14
15 This program makes it easier to boot NOVA or other operating system
16 (OS) in different environments. It reads a so called novaboot script
17 and uses it either to boot the OS in an emulator (e.g. in qemu) or to
18 generate the configuration for a specific bootloader and optionally to
19 copy the necessary binaries and other needed files to proper
20 locations, perhaps on a remote server. In case the system is actually
21 booted, its serial output is redirected to standard output if that is
22 possible.
23
24 A typical way of using novaboot is to make the novaboot script
25 executable and set its first line to _\#!/usr/bin/env novaboot_. Then,
26 booting a particular OS configuration becomes the same as executing a
27 local program - the novaboot script.
28
29 With `novaboot` you can:
30
31 1. Run an OS in Qemu. This is the default action when no other action is
32 specified by command line switches. Thus running `novaboot ./script`
33 (or `./script` as described above) will run Qemu and make it boot the
34 configuration specified in the _script_.
35 2. Create a bootloader configuration file (currently supported
36 bootloaders are GRUB, GRUB2, Pulsar and uBoot) and copy it with all
37 other files needed for booting to another, perhaps remote, location.
38
39         ./script --server --iprelay=192.168.1.2
40
41     This command copies files to a TFTP server specified in the
42     configuration file and uses TCP/IP-controlled relay to reset the test
43     box and receive its serial output.
44
45 3. Run DHCP and TFTP server on developer's machine to PXE-boot NOVA from
46 it. E.g.
47
48         ./script --dhcp-tftp
49
50     When a PXE-bootable machine is connected via Ethernet to developer's
51     machine, it will boot the configuration described in _script_.
52
53 4. Create bootable ISO images. E.g.
54
55         novaboot --iso -- script1 script2
56
57     The created ISO image will have GRUB bootloader installed on it and
58     the boot menu will allow selecting between _script1_ and _script2_
59     configurations.
60
61 # PHASES AND OPTIONS
62
63 Novaboot performs its work in several phases. Each phase can be
64 influenced by several options, certain phases can be skipped. The list
65 of phases (in the execution order) and the corresponding options
66 follows.
67
68 ## Configuration reading phase
69
70 After starting, novaboot reads configuration files. By default, it
71 searches for files named `.novaboot` starting from the directory of
72 the novaboot script (or working directory, see bellow) and continuing
73 upwards up to the root directory. The configuration files are read in
74 order from the root directory downwards with latter files overriding
75 settings from the former ones.
76
77 In certain cases, the location of the novaboot script cannot be
78 determined in this early phase. This happens either when the script is
79 read from the standard input or when novaboot is invoked explicitly
80 and options precede the script name, as in the example ["4."](#4.) above.
81 In this case the current working directory is used as a starting point
82 for configuration file search.
83
84 - \-c, --config=<filename>
85
86     Use the specified configuration file instead of the default one(s).
87
88 ## Command line processing phase
89
90 - \--dump-config
91
92     Dump the current configuration to stdout end exits. Useful as an
93     initial template for a configuration file.
94
95 - \-h, --help
96
97     Print short (__\-h__) or long (__\--help__) help.
98
99 - \-t, --target=<target>
100
101     This option serves as a user configurable shortcut for other novaboot
102     options. The effect of this option is the same as the options stored
103     in the `%targets` configuration variable under key _target_. See
104     also ["CONFIGURATION FILE"](#CONFIGURATION FILE).
105
106 ## Script preprocessing phase
107
108 This phases allows to modify the parsed novaboot script before it is
109 used in the later phases.
110
111 - \-a, --append=<parameters>
112
113     Appends a string to the first "filename" line in the novaboot script.
114     This can be used to append parameters to the kernel's or root task's
115     command line.
116
117 - \-b, --bender
118
119     Use `bender` chainloader. Bender scans the PCI bus for PCI serial
120     ports and stores the information about them in the BIOS data area for
121     use by the kernel.
122
123 - \--chainloader=<chainloader>
124
125     Chainloader that is loaded before the kernel and other files specified
126     in the novaboot script. E.g. 'bin/boot/bender promisc'.
127
128 - \--dump
129
130     Prints the content of the novaboot script after removing comments and
131     evaluating all _\--scriptmod_ expressions. Exit after reading (and
132     dumping) the script.
133
134 - \--scriptmod=_perl expression_
135
136     When novaboot script is read, _perl expression_ is executed for every
137     line (in $\_ variable). For example, `novaboot
138     --scriptmod=s/sigma0/omega6/g` replaces every occurrence of _sigma0_
139     in the script with _omega6_.
140
141     When this option is present, it overrides _$script\_modifier_ variable
142     from the configuration file, which has the same effect. If this option
143     is given multiple times all expressions are evaluated in the command
144     line order.
145
146 - \--strip-rom
147
148     Strip _rom://_ prefix from command lines and generated config files.
149     The _rom://_ prefix is used by NUL. For NRE, it has to be stripped.
150
151 ## File generation phase
152
153 In this phase, files needed for booting are generated in a so called
154 _build directory_ (see TODO). In most cases configuration for a
155 bootloader is generated automatically by novaboot. It is also possible
156 to generate other files using _heredoc_ or _"<"_ syntax in novaboot
157 scripts. Finally, binaries can be generated in this phases by running
158 `scons` or `make`.
159
160 - \--build-dir=<directory>
161
162     Overrides the default build directory location.
163
164     The default build directory location is determined as follows: If the
165     configuration file defines the `$builddir` variable, its value is
166     used. Otherwise, it is the directory that contains the first processed
167     novaboot script.
168
169 - \-g, --grub\[=_filename_\]
170
171     Generates grub bootloader menu file. If the _filename_ is not
172     specified, `menu.lst` is used. The _filename_ is relative to the
173     build directory (see __\--build-dir__).
174
175 - \--grub-preamble=_prefix_
176
177     Specifies the _preable_ that is at the beginning of the generated
178     GRUB or GRUB2 config files. This is useful for specifying GRUB's
179     timeout.
180
181 - \--grub-prefix=_prefix_
182
183     Specifies _prefix_ that is put in front of every file name in GRUB's
184     `menu.lst`. The default value is the absolute path to the build directory.
185
186     If the _prefix_ contains string $NAME, it will be replaced with the
187     name of the novaboot script (see also __\--name__).
188
189 - \--grub2\[=_filename_\]
190
191     Generate GRUB2 menuentry in _filename_. If _filename_ is not
192     specified `grub.cfg` is used. The content of the menuentry can be
193     customized with __\--grub-preable__, __\--grub2-prolog__ or
194     __\--grub\_prefix__ options.
195
196     In order to use the the generated menuentry on your development
197     machine that uses GRUB2, append the following snippet to
198     `/etc/grub.d/40\_custom` file and regenerate your grub configuration,
199     i.e. run update-grub on Debian/Ubuntu.
200
201         if [ -f /path/to/nul/build/grub.cfg ]; then
202           source /path/to/nul/build/grub.cfg
203         fi
204
205 - \--grub2-prolog=_prolog_
206
207     Specifies text _preable_ that is put at the begiging of the entry
208     GRUB2 entry.
209
210 - \--name=_string_
211
212     Use the name _string_ instead of the name of the novaboot script.
213     This name is used for things like a title of grub menu or for the
214     server directory where the boot files are copied to.
215
216 - \--no-file-gen
217
218     Do not generate files on the fly (i.e. "<" syntax) except for the
219     files generated via "<<WORD" syntax.
220
221 - \-p, --pulsar\[=mac\]
222
223     Generates pulsar bootloader configuration file named `config-_mac_`
224     The _mac_ string is typically a MAC address and defaults to
225     _novaboot_.
226
227 - \--scons\[=scons command\]
228
229     Runs _scons_ to build files that are not generated by novaboot
230     itself.
231
232 - \--gen-only
233
234     Exit novaboot after file generation phase.
235
236 ## Target connection check
237
238 If supported by the target, the connection to it is made and it is
239 checked whether the target is not occupied by another novaboot
240 user/instance.
241
242 ## File deployment phase
243
244 In some setups, it is necessary to copy the files needed for booting
245 to a particular location, e.g. to a TFTP boot server or to the
246 `/boot` partition.
247
248 - \-d, --dhcp-tftp
249
250     Turns your workstation into a DHCP and TFTP server so that NOVA
251     can be booted via PXE BIOS on a test machine directly connected by
252     a plain Ethernet cable to your workstation.
253
254     The DHCP and TFTP servers require root privileges and `novaboot`
255     uses `sudo` command to obtain those. You can put the following to
256     _/etc/sudoers_ to allow running the necessary commands without
257     asking for password.
258
259         Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/touch dhcpd.leases, pkill --pidfile=dhcpd.pid, pkill --pidfile=tftpd.pid
260         your_login ALL=NOPASSWD: NOVABOOT
261
262 - \-i, --iso\[=filename\]
263
264     Generates the ISO image that boots NOVA system via GRUB. If no filename
265     is given, the image is stored under _NAME_.iso, where _NAME_ is the name
266     of the novaboot script (see also __\--name__).
267
268 - \--server\[=\[\[user@\]server:\]path\]
269
270     Copy all files needed for booting to another location (implies __\-g__
271     unless __\--grub2__ is given). The files will be copied (by __rsync__
272     tool) to the directory _path_. If the _path_ contains string $NAME,
273     it will be replaced with the name of the novaboot script (see also
274     __\--name__).
275
276 - \--concat
277
278     If __\--server__ is used and its value ends with $NAME, then after
279     copying the files, a new bootloader configuration file (e.g. menu.lst)
280     is created at _path-wo-name_, i.e. the path specified by __\--server__
281     with $NAME part removed. The content of the file is created by
282     concatenating all files of the same name from all subdirectories of
283     _path-wo-name_ found on the "server".
284
285 - \--rsync-flags=_flags_
286
287     Specifies which _flags_ are appended to `rsync` command line when
288     copying files as a result of _\--server_ option.
289
290 ## Target power-on and reset phase
291
292 - \--iprelay=_addr\[:port\]_
293
294     Use IP relay to reset the machine and to get the serial output. The IP
295     address of the relay is given by _addr_ parameter.
296
297     Note: This option is expected to work with HWG-ER02a IP relays.
298
299 - \--on, --off
300
301     Switch on/off the target machine. Currently works only with
302     __\--iprelay__.
303
304 - \-Q, --qemu=_qemu-binary_
305
306     The name of qemu binary to use. The default is 'qemu'.
307
308 - \--qemu-append=_flags_
309
310     Append _flags_ to the default qemu flags (QEMU\_FLAGS variable or
311     `-cpu coreduo -smp 2`).
312
313 - \-q, --qemu-flags=_flags_
314
315     Replace the default qemu flags (QEMU\_FLAGS variable or `-cpu coreduo
316     -smp 2`) with _flags_ specified here.
317
318 ## Interaction with the bootloader on the target
319
320 See __\--serial__. There will be new options soon.
321
322 - \--uboot
323
324     Interact with uBoot bootloader to boot the thing described in the
325     novaboot script. Implementation of this option is currently tied to a
326     particular board that we use. It may be subject to changes in the
327     future!
328
329 ## Target's output reception phase
330
331 - \-s, --serial\[=device\]
332
333     Use serial line to control GRUB bootloader and to see the output
334     serial output of the machine. The default value is `/dev/ttyUSB0`.
335
336 - \--stty=<settings>
337
338     Specifies settings passed to `stty` invoked on the serial line
339     specified with __\--serial__. If this option is not given, `stty` is
340     called with `raw -crtscts -onlcr 115200` settings.
341
342 See also __\--iprelay__.
343
344 ## Termination phase
345
346 Daemons that were spwned (`dhcpd` and `tftpd`) are killed here.
347
348 # NOVABOOT SCRIPT SYNTAX
349
350 The syntax tries to mimic POSIX shell syntax. The syntax is defined with the following rules.
351
352 Lines starting with "\#" are ignored.
353
354 Lines that end with "\\" are concatenated with the following line after
355 removal of the final "\\" and leading whitespace of the following line.
356
357 Lines in the form _VARIABLE=..._ (i.e. matching '^\[A-Z\_\]+=' regular
358 expression) assign values to internal variables. See VARIABLES
359 section.
360
361 Otherwise, the first word on the line represents the filename
362 (relative to the build directory (see __\--build-dir__) of the module to
363 load and the remaining words are passed as the command line
364 parameters.
365
366 When the line ends with "<<WORD" then the subsequent lines until the
367 line containing only WORD are copied literally to the file named on
368 that line.
369
370 When the line ends with "< CMD" the command CMD is executed with
371 `/bin/sh` and its standard output is stored in the file named on that
372 line. The SRCDIR variable in CMD's environment is set to the absolute
373 path of the directory containing the interpreted novaboot script.
374
375 Example:
376   \#!/usr/bin/env novaboot
377   WVDESC=Example program
378   bin/apps/sigma0.nul S0\_DEFAULT script\_start:1,1 \\
379     verbose hostkeyb:0,0x60,1,12,2
380   bin/apps/hello.nul
381   hello.nulconfig <<EOF
382   sigma0::mem:16 name::/s0/log name::/s0/timer name::/s0/fs/rom ||
383   rom://bin/apps/hello.nul
384   EOF
385
386 This example will load three modules: sigma0.nul, hello.nul and
387 hello.nulconfig. sigma0 gets some command line parameters and
388 hello.nulconfig file is generated on the fly from the lines between
389 <<EOF and EOF.
390
391 ## VARIABLES
392
393 The following variables are interpreted in the novaboot script:
394
395 - BUILDDIR
396
397     Novaboot chdir()s to this directory before file generation phase. The
398     directory name specified here is relative to the build directory
399     specified by other means (see ["--build-dir"](#--build-dir)).
400
401 - WVDESC
402
403     Description of the wvtest-compliant program.
404
405 - WVTEST\_TIMEOUT
406
407     The timeout in seconds for WvTest harness. If no complete line appears
408     in the test output within the time specified here, the test fails. It
409     is necessary to specify this for long running tests that produce no
410     intermediate output.
411
412 - QEMU
413
414     Use a specific qemu binary (can be overriden with __\-Q__) and flags
415     when booting this script under qemu. If QEMU\_FLAGS variable is also
416     specified flags specified in QEMU variable are replaced by those in
417     QEMU\_FLAGS.
418
419 - QEMU\_FLAGS
420
421     Use specific qemu flags (can be overriden with __\-q__).
422
423 - HYPERVISOR\_PARAMS
424
425     Parameters passed to hypervisor. The default value is "serial", unless
426     overriden in configuration file.
427
428 - KERNEL
429
430     The kernel to use instead of NOVA hypervisor specified in the
431     configuration file. The value should contain the name of the kernel
432     image as well as its command line parameters. If this variable is
433     defined and non-empty, the variable HYPERVISOR\_PARAMS is not used.
434
435 # CONFIGURATION FILE
436
437 Novaboot can read its configuration from a file. Configuration file
438 was necessary in early days of novaboot. Nowadays, an attempt is made
439 to not use the configuration file because it makes certain novaboot
440 scripts unusable on systems without (or with different) configuration
441 file. The only recommended use of the configuration file is to specify
442 custom\_options (see bellow).
443
444 If you decide to use the configuration file, it is looked up, by
445 default, in files named `.novaboot` as described in ["Configuration reading phase"](#Configuration reading phase). Alternatively, its location can be specified with the
446 __\-c__ switch or with the NOVABOOT\_CONFIG environment variable. The
447 configuration file has perl syntax and should set values of certain
448 Perl variables. The current configuration can be dumped with the
449 __\--dump-config__ switch. Some configuration variables can be overriden
450 by environment variables (see below) or by command line switches.
451
452 Documentation of some configuration variables follows:
453
454 - $builddir
455
456     Build directory location relative to the location of the configuration
457     file.
458
459 - %targets
460
461     Hash of shortcuts to be used with the __\--target__ option. If the hash
462     contains, for instance, the following pair of values
463
464         'mybox' => '--server=boot:/tftproot --serial=/dev/ttyUSB0 --grub',
465
466     then the following two commands are equivalent:
467
468         ./script --server=boot:/tftproot --serial=/dev/ttyUSB0 --grub
469         ./script -t mybox
470
471 # ENVIRONMENT VARIABLES
472
473 Some options can be specified not only via config file or command line
474 but also through environment variables. Environment variables override
475 the values from configuration file and command line parameters
476 override the environment variables.
477
478 - NOVABOOT\_CONFIG
479
480     Name of the novaboot configuration file to use instead of the default
481     one(s).
482
483 - NOVABOOT\_BENDER
484
485     Defining this variable has the same meaning as __\--bender__ option.
486
487 # AUTHORS
488
489 Michal Sojka <sojka@os.inf.tu-dresden.de>