NANOBSD(8) | MidnightBSD System Manager's Manual | NANOBSD(8) |
nanobsd.sh
—
utility used to create a FreeBSD system image suitable for
embedded applications
nanobsd.sh |
[-bfhiKknqvwX ] [-c
config-file] |
The nanobsd.sh
utility is a script which
produces a minimal implementation of FreeBSD (called
NanoBSD
), which typically fits on a small media such
as a Compact Flash card, or other mass storage medium. It can be used to
build specialized install images, designed for easy installation and
maintenance.
The following options are available:
-b
-c
config-file-f
-h
-i
-K
installkernel
stage of the build.-k
buildkernel
stage of the build.-n
buildworld
stage and adds
-DNO_CLEAN to the make command line used for each build stage (world and
kernel).-q
-v
-w
buildworld
stage of the build.-X
native-xtools.
The features of NanoBSD
include:
NanoBSD
image, the same way as in
FreeBSD.NanoBSD
, unless the specific feature or features
were explicitly removed from the NanoBSD
image
when it was created.The mass storage medium is divided into three parts by default (which are normally mounted read-only):
code#1
and
code#2
.The /etc and /var directories are md(4) (malloc backed) disks.
The configuration file partition persists under the /cfg directory. It contains files for /etc directory and is briefly mounted read-only right after the system boot, therefore it is required to copy modified files from /etc back to the /cfg directory if changes are expected to persist after the system restarts.
NanoBSD
A NanoBSD
image is built using a simple
nanobsd.sh
shell script, which can be found in the
src/tools/tools/nanobsd directory. This script
creates a bootable image, which can be copied on the storage medium using
the dd(1) utility.
The necessary commands to build and install a
NanoBSD
image are:
cd /usr/src/tools/tools/nanobsd sh nanobsd.sh cd /usr/obj/nanobsd.full dd if=_.disk.full of=/dev/da0 bs=64k
NanoBSD
This is probably the most important and most interesting feature
of NanoBSD
. This is also where you will be spending
most of the time when developing with NanoBSD
.
Customization is done in two ways:
With configuration settings, it is possible to configure options
passed to both the buildworld
and
installworld
stages of the
NanoBSD
build process, as well as internal options
passed to the main build process of NanoBSD
. Through
these options it is possible to cut the system down, so it will fit on as
little as 64MB. You can use the configuration options to trim down the
system even more, until it will consist of just the kernel and two or three
files in the userland.
The configuration file consists of configuration options, which override the default values. The most important directives are:
uname -p
.boot0
's behaviour.boot0
loader to use relative to the
NANO_WORLDDIR variable. This defaults to
boot/boot0sio and should be overridden to
boot/boot0 to provide a VGA console.buildworld
stage of the
build.installworld
stage of the
build.buildworld
and
installworld
stages of the build.For more configuration options, please check the
nanobsd.sh
script.
To build NanoBSD
image using the
nanobsd.conf configuration file, use the following
command:
sh nanobsd.sh -c nanobsd.conf
It is possible to fine-tune NanoBSD
using
shell functions in the configuration file. The following example illustrates
the basic model of custom functions:
cust_foo () ( echo "bar=topless" > \ ${NANO_WORLDDIR}/etc/foo ) customize_cmd cust_foo
There are a few pre-defined customization functions ready for use:
cust_comconsole
cust_allow_ssh_root
cust_install_files
NanoBSD
build script.Making persistent changes to /etc/resolv.conf:
vi /etc/resolv.conf ... mount /cfg cp /etc/resolv.conf /cfg umount /cfg
A more useful example of a customization function is the following, which changes the default size of the /etc directory from 5MB to 30MB:
cust_etc_size () ( cd ${NANO_WORLDDIR}/conf echo 30000 > default/etc/md_size ) customize_cmd cust_etc_size
The nanobsd.sh
utility first appeared in
FreeBSD 6.0.
NanoBSD
was developed by
Poul-Henning Kamp
<phk@FreeBSD.org>.
This manual page was written by Daniel Gerzo
<danger@FreeBSD.org>.
May 19, 2016 | midnightbsd-3.1 |