2 .\" $FreeBSD: src/share/man/man8/picobsd.8,v 1.1.2.14 2002/12/29 16:35:39 schweikh Exp $
8 .Nd floppy disk based FreeBSD system
12 .Op Ar floppy-type Op Ar site-name
15 is a script which can be used to produce a minimal implementation of
19 which typically fits on one floppy disk, or can be downloaded as a
20 single image file from some media such as CDROM, flash memory, or through
24 was originally created to build simple standalone systems
25 such as firewalls or bridges, but because of the ability to
26 cross-build images with different source trees than the one
27 in the server, it can be extremely useful to developers to
28 test their code without having to reinstall the system.
30 The boot media (typically a floppy disk) contains a boot loader and a
31 compressed kernel which includes a memory file system.
32 Depending on the media, it might also contain a number of
33 additional files, which can be updated at run time, and are
34 used to override/update those in the memory file system.
36 The system loads the kernel in the normal way, uncompresses
37 the memory file system and mounts it as root.
38 It then updates the memory
39 filesystem with files from the boot media (if present),
40 and executes a specialized version of
42 The boot media (floppy, etc.) is
43 required for loading only, and typically used read-only.
44 After the boot phase, the system runs entirely from RAM.
46 The following options are available (but also check the
48 script for more details):
50 .Bl -tag -width indent
51 .It Fl -src Ar SRC_PATH
52 Use the source tree at
56 This can be useful for cross-building floppy images.
57 When using this option, you must also create and initialize the subtree at
58 .Ao Ar SRC_PATH Ac Ns Pa /../usr
59 with the correct header files, libraries, and tools (such as the
61 program) that are necessary for the cross-build (see the
64 The source files are unmodified by the
67 However the source tree is not completely read-only,
70 expects the kernel configuration file to be in one of
71 its subdirectories, and also the process of initializing the
73 subtree touches some parts of the source tree (this is a bug
74 in the release build scripts which might go away with time).
76 When used together with the
78 option, this initializes the
79 .Ao Ar SRC_PATH Ac Ns Pa /../usr
80 subtree as necessary to subsequently build
84 Also build kernel modules.
85 These are not stored on the floppy
86 image but are left available in the build directory.
88 Make the script non-interactive.
89 Do not show the initial menu, and
90 proceed to the build process without requiring user input.
92 Make the script verbose, showing
93 commands to be executed and waiting for user
94 input before executing each of them.
97 Put the entire contents of the filesystem in the
98 memory filesystem image which is contained in the
100 This is the default behaviour, and is
101 extremely useful as the kernel itself can be loaded,
106 as a fully functional system.
107 .It Fl -no_all_in_mfs
108 Leaves files contained in the
110 on the floppy image, so they can be loaded separately
111 from the kernel (and updated individually to
112 customize the floppy image).
113 .It Fl -floppy_size Ar size
114 Set the size of the floppy image.
116 than 1440 can be used for images that are burned
119 Clean the product of previous builds.
122 As a result of extreme size limitations, the
124 environment differs from the normal
129 There are no dynamic libraries, and there is no directory
131 As a result, only static executables may be executed.
133 In order to reduce the size of the executables, all executables on a specific
134 floppy are joined together as a single executable built with
137 Some programs are supplied in minimalistic versions, specifically
139 a cut-down version of
143 a cut-down version of
149 sources reside in the hierarchy
150 .Pa /usr/src/release/picobsd .
151 In the following discussion, all relative path names are relative to this
155 build process has changed slightly over time, in order to cope
156 with the unavoidable increase of code size, which requires more and more
157 tricks to cram as much as possible onto the floppies.
160 the supported build script is
161 .Pa /usr/src/release/picobsd/build/picobsd
162 which can be run from anywhere.
163 When run in interactive mode (the default without the
165 option), the script will let you configure the various parameters
166 used to build the floppy image.
167 The following kinds of floppy are envisaged, and we try to keep them
168 functional and fitting in the 1.44MB floppy despite the unavoidable
169 increases in the size of the kernel and its applications:
170 .Bl -hang -width ".Pa bridge"
172 configuration suitable for bridges, routers and firewalls.
175 The following configurations are also present but for reference
177 Many of them are irremediably out of date and no effort
178 is done to keep them in good shape:
179 .Bl -hang -width ".Pa bridge"
181 configuration suitable for dial-out
185 configuration suitable for dial-in
189 configuration suitable for general networking.
191 configuration suitable for use as a router.
192 This particular configuration
193 aims to work on minimal hardware.
196 These configurations serve only as examples for
197 your own modification.
198 Not all of them have been tested,
199 and you might need small tweaks to the configuration
200 files to make them work or even fit into the
201 available disk space as code size increases.
203 You can define your own floppy type, by creating a directory
204 with a name of your choice (e.g.\&
207 some of the following files and directories.
209 information on how to construct these files, look at one
212 configurations as a reference.
213 .Bl -tag -width indent
215 The kernel configuration file (required).
216 This is a mostly standard
217 kernel configuration file, possibly stripped down by removing
218 unnecessary drivers and options to reduce the kernel's size.
220 To be recognised as a
222 kernel config file, the file must also contain the line
225 below, and a matching
228 .Bd -literal -offset indent
229 #marker def_sz init MFS_inodes floppy_inodes
230 #PicoBSD 4200 init 8192 32768
231 options MD_ROOT_SIZE=4200 # same as def_sz
234 This informs the script of the size of the memory filesystem and
235 provides a few other details on how to build the image.
238 configuration (required).
239 It contains the list of directories containing program sources,
240 the list of binaries to be built, and the list of libraries that
244 manpage for the exact details on the syntax of this file.
246 The following issues are particularly important when dealing
252 we can pass build options to those Makefile's which understand
253 that, in order to reduce the size of the programs.
254 This is achieved with a line of the form
255 .Bd -literal -offset indent
256 buildopts -DNOPAM -DRELEASE_CRUNCH ...
259 When providing the list of directories where source files are, it
260 is convenient to list the following entry first:
262 srcdirs /usr/src/release/picobsd/tinyware
266 -specific versions of the programs will be found there.
270 is replaced with the full pathname of the directory where the
272 configuration resides (i.e. the one where we find
273 .Pa PICOBSD , crunch.conf ,
275 This can be useful to refer source code that resides within a
277 .Bd -literal -offset indent
278 srcdirs @__CWD__@/src
282 Shell variables, sourced by the
285 The most important variables here are:
286 .Bl -tag -width MY_DEVS
288 (not used in -CURRENT where we have DEVFS).
289 Should be set to the list of devices to be created in the
291 directory of the image (it is really the argument passed to
293 so refer to that manpage for the names).
295 Size (in kilobytes) of the
301 which produces an image suitable for a standard floppy.
303 If you plan to store the image on a CDROM (e.g. using
306 floppy emulation), you can set
309 If you are planning to dump the image onto a hard disk
310 (either in a partition or on the whole disk), you
311 are not restricted to one of the standard floppy sizes.
312 Using a large image size per se does not waste RAM at runtime,
313 because only the files that are actually loaded from the image
314 contribute to the memory usage.
316 Contains a list of files to be imported in the floppy_tree.
317 Absolute names refer to the standard filesystem, relative
318 names refer to the root of the source tree being used
322 You can normally use this option if you want to import
323 files such as shared libraries, or databases, without
324 having to replicate them first in your configuration
330 .It Pa floppy.tree.exclude
331 List of files from the standard floppy tree which
332 we do not want to be copied (optional).
334 Local additions to the standard floppy tree (optional).
335 The content of this subtree will be copied as-is into the
337 .It Pa floppy.tree. Ns Aq Ar site-name
338 Same as above, but site-specific (optional).
341 More information on the build process can be found in the
345 Sample configurations can be found in
346 .Pa /usr/src/release/picobsd/ Ns Ao Ar floppy-type Ac Ns Pa /
347 .Sh USING ALTERNATE SOURCE TREES
348 The build script can be instructed to use an alternate source tree
352 The tree that you specify must contain full sources for the kernel
353 and for all programs that you want to include in your image.
354 As an example, to cross-build the
357 using RELENG_4 sources, you can do the following:
358 .Bd -literal -offset indent
359 cd <some_empty_directory>
361 (cd FOO; cvs -d<my_repository> co -rRELENG_4 src)
362 picobsd --src FOO/src --init # this is needed only once
363 picobsd --src FOO/src -n -v bridge
366 If the build is successful, the directory
367 .Pa build_dir-bridge/
370 that can be downloaded with
372 a floppy image called
374 plus the products of the compilation in other directories.
375 If you want to modify the source tree in
377 a new image can be produced by simply running
379 .Dl "picobsd --src FOO/src -n -v bridge"
381 whereas if the change affects include files or libraries
382 you first need to update them, e.g. by running first
384 .Dl "picobsd --src FOO/src --init # this is needed only once"
386 as you would normally do for any change of this kind.
387 .Sh INSTALLING PicoBSD
391 is run from a floppy disk, where it can be installed with a simple
393 .Dl "dd if=picobsd.bin of=/dev/rfd0"
395 and the floppy is ready to boot.
396 .Ss Hard Disk Install
397 The same process can be used to store the image on a hard disk
398 (entire volume or one of the slices):
399 .Bd -literal -offset indent
400 dd if=picobsd.bin of=/dev/ad2
401 dd if=picobsd.bin of=/dev/ad2s3
402 dd if=picobsd.bin of=/dev/ad2 oseek=NN
405 The first form will install the image on the entire disk, and it
406 should work in the same way as for a floppy.
408 The second form will install the image
409 on slice number 3 (which should be large enough to store the
410 contents of the image).
411 However, the process will only have success if the
412 partition does not contain a valid disklabel, otherwise the kernel will
413 likely prevent overwriting the label.
414 In this case you can use the
415 third form, replacing
417 with the actual start of the partition
418 (which you can determine using
420 Note that after saving the image to the slice, it will not yet be
424 command to properly initialize the label (do not ask why!).
425 One way to do this is
426 .Bd -literal -offset indent
427 disklabel -w ad0s2 auto
431 and from the editor enter a line corresponding to the actual partition, e.g.\&
432 if the image has 2.88MB (5760 sectors) you need to enter the following
433 line for the partition:
435 .Dl "a: 5760 0 4.2BSD 512 4096"
437 At this point the partition is bootable.
438 Note that the image size can be smaller than the slice size
439 (indicated as partition
442 Another option is to put the image on a CDROM.
448 then you can produce a bootable
450 image (and burn it) with the
452 .Bd -literal -offset indent
453 mkisofs -b picobsd.bin -c boot.catalog -d -N -D -R -T \\
454 -o cd.img build_dir-foo
455 burncd -f /dev/acd0c -s 4 data cd.img fixate
458 Note that the image size is restricted to 1.44MB or 2.88MB, other sizes
459 most likely will not work.
460 .Ss Booting From The Network
461 Yet another way to use
463 is to boot the image off the network.
464 For this purpose you should use the uncompressed kernel which is
465 available as a byproduct of the compilation.
466 Refer to the documentation
467 for network booting for more details, the
469 kernel is bootable as a standard
475 insert the floppy and reset the machine.
476 The boot procedure is similar to the
480 Booting from a floppy is normally rather slow (in the order of 1-2
481 minutes), things are much faster if you store your image on
482 a hard disk, Compact Flash, or CDROM.
486 to load the preloaded, uncompressed kernel image
487 which is a byproduct of the
491 the load time is a matter of a few seconds, even on a 10Mbit/s
496 loads the root filesystem from the memory file system, starts
498 and passes control to a first startup script,
500 The latter populates the
504 directories with the default files, then tries to identify the boot
505 device (floppy, hard disk partition) and possibly override the contents
506 of the root filesystem with files read from the boot device.
507 This allows you to store local configuration on the same media.
508 After this phase the boot device is no longer used, unless the
509 user specifically does it.
511 After this, control is transferred to a second script,
513 (which can be overridden from the boot device).
514 This script tries to associate a hostname to the system by using
515 the MAC address of the first ethernet interface as a key, and
518 Then control is passed to the main user configuration script,
520 which is supposed to override the value of a number of configuration
521 variables which have been pre-set in
522 .Pa /etc/rc.conf.defaults .
525 variable to create different configurations from the same file.
526 After taking control back,
528 completes the initializations, and as part of this
529 it configures network interfaces and optionally calls the
530 firewall configuration script,
531 .Pa /etc/rc.firewall ,
532 where the user can store his own firewall configuration.
536 runs entirely from main memory, and has no swap space, unless you
537 explicitly request it.
538 The boot device is also not used anymore after
540 takes control, again, unless you explicitly request it.
541 .Sh CONFIGURING a PicoBSD system
544 system can be configured through a few files which are read at boot
545 time, very much like a standard
548 There are, however, some minor differences to reduce the
549 number of files to store and/or customize, thus saving space.
550 Among the files to configure we have the following:
551 .Bl -tag -width indent
553 Traditionally, this file contains the IP-to-hostname mappings.
554 In addition to this, the
556 version of this file also contains
557 a mapping between Ethernet (MAC) addresses and hostnames, as follows:
558 .Bd -literal -offset indent
559 #ethertable start of the ethernet->hostname mapping
560 # mac_address hostname
561 # 00:12:34:56:78:9a pinco
566 where the line containing
568 marks the start of the table.
570 If the MAC address is not found, the script will prompt you to
571 enter a hostname and IP address for the system, and this
572 information will be stored in the
574 file (in memory) so you can simply store them on disk later.
576 Note that you can use wildcards in the address part, so a line
577 like the last one in the example will match any MAC address and
580 This file contains a number of variables which control the
581 operation of the system, such as interface configuration,
582 router setup, network service startup, etc.
583 For the exact list and meaning of these variables see
584 .Pa /etc/rc.conf.defaults .
586 It is worth mentioning that some of the variables let you
587 overwrite the contents of some files in
589 This option is available at the moment for
592 .Pa /etc/resolv.conf ,
593 whose contents are generally very short and suitable for this
595 In case you use these variables, remember to use newlines
596 as appropriate, e.g.\&
597 .Bd -literal -offset indent
598 host_conf="# this goes into /etc/host.conf
603 Although not mandatory, in this file you should only set the
604 variables indicated in
605 .Pa /etc/rc.conf.defaults ,
606 and avoid starting services which depend on having the network running.
607 This can be done at a later time: if you set
608 .Va firewall_enable Ns = Ns Qq Li YES ,
611 script will be run after configuring the network interfaces,
612 so you can set up your firewall and safely start network services or enable
613 things such as routing and bridging.
614 .It Pa /etc/rc.firewall
615 This script can be used to configure the
620 variable is set to the pathname of the firewall command,
622 contains the value set in
626 contains the name assigned to the host.
629 There is a small script called
631 which can be used to edit and/or save to disk a copy of the files
632 you have modified after booting.
633 The script takes one or more absolute pathnames, runs the
634 editor on the files passed as arguments, and then saves a
635 compressed copy of the files on the disk (mounting and
636 unmounting the latter around the operation).
638 If invoked without arguments,
641 .Pa rc.conf , rc.firewall ,
645 If one of the arguments is
647 (the directory name alone),
648 then the command saves to disk (without editing)
649 all the files in the directory for which a copy
650 already exists on disk (e.g. as a result of a previous update).
658 .An Andrzej Bialecki Aq abial@FreeBSD.org ,
659 with subsequent work on the scripts by
660 .An Luigi Rizzo Aq luigi@iet.unipi.it
665 .An Greg Lehey Aq grog@lemis.com .
669 the kernel of the system on which it is built must have the
673 The build process must be run as
675 because of the need of running
683 is still a black art.
684 The biggest problem is determining what will fit on the
685 floppies, and the only practical method is trial and error.