How to build your own version of PicoBSD 0.31?
-
Get the file picobsd031.pax.gz.
It contains the scripts you'll need. You'd need to have a full 2.2.5-RELEASE
system with full sources installed.
Unpack the archive in some place with at least 5MB free space.
-
Contrary to previous versions, you shouldn't need to edit any of the scripts.
Just
cd scripts
and run the
./build
script. Select target language, size of MFS and one of pre-canned setups
(personal dialup, dialin server or router-like). Details of each setup
are contained in dial/, isp/ and net/ directories respectively. You should
at least check ${TYPE}/config/PICOBSD file to make sure it contains drivers
you want.
I also recommend to adjust the ISA devices parameters to match the ones
of your hardware - this version of PicoBSD can save the changes from userconfig,
but this way it will produce smaller /kernel.config file.
-
I assume you will use 1.44MB floppy. If not, please edit the file scripts/stage3.
-
There are several directories which contain some sources and config files:
ash/ a Shell - ancestor of venerable /bin/sh
chuck/ a friendly daemon :-)
daemon/ a tool to "daemonize" a text file :-))
dial/ config files for dialup setup
conf/ kernel config file
crunch1/ crunch of system programs
mfs.tree/ contains the MFS directory structure
lang/ contains language-dependent files
floppy.tree/ contains the startup floppy hierarchy
isp/ config files for dialin server setup
... (as above)
net/ config files for router-like setup
... (as above)
scripts/ scripts which do the actual build
You MUST cd here in order to build the floppy
tools/ additional tools - some of them needed
during build, some of them are special to
PicoBSD
NOTE: the mfs.tree/etc directory is, so to speak, ephemeric. It contains
enough config files to suck in the real /etc contents from the floppy (floppy.tree/etc)
right after bootup. This setup is a little weird, but it allows you to
edit the configuration without rebuilding the whole floppy (because you
can't change the MFS permanently, can you? :-))
Also, there are no /etc/passwd nor /etc/pwd.db files on the "dial" floppy
- in case of other types, they are reconstructed from /etc/master.passwd
on each startup (and then put on MFS with the rest of /etc). In case of
"dial" type floppy, you don't need them at all.
NOTE2: thanks to the above, the floppy is needed only during startup,
and then only if you want to synchronize (possibly changed) MFS /etc with
the one on the floppy. It means that you can pull off the floppy from the
drive as soon as login: prompt appears. In other words, it is almost equal
to read-only floppy. Do not write protect the floppy, however, as
kernel configuration is written to the floppy during the boot process.
-
Edit the set of installed programs.
-
Go to ${TYPE}/crunch1 directory.
There is a fundamental change from the previous version concerning use
of crunched binaries. As it was patiently explained to me by Mike Smith,
gzipping the crunch only made matters worse, because it had to be loaded
in whole to memory, then ungzipped, and there was one non-shared copy of
the monster for each started process. Contrary to this, when the crunch
is not gzipped, its .text section can be loaded page by page as necessary,
and also it can be shared between processes. It makes MFS size bigger to
hold the non-gzipped binaries, but it really pays off.
-
There are some patches included in these directories, which are applied
during build process to some of the Makefiles in your /usr/src. These patches
attempt to decrease the size of some programs by cutting off rarely/unlikely
used parts. The patches are reversed when you do a 'make clean' (or scripts/clean
for that matter).
NOTE: patches may fail to apply, if your sources are too different from
the ones I used. Don't worry: they are so straightforward that you can
apply them by hand.
-
In order to have a functioning system you MUST install at least /stand/init,
or /stand/oinit, or /stand/sysinstall. Of course these can be your own
programs... But if you install the stock /sbin/init, you also have to install
some others, like sh, getty, login etc...
-
I found that it confuses people to see the links from e.g. ${TYPE}/mfs.tree/bin
pointing to their /stand directory on the hard disk. It does NOT mean that
you have to have this /stand around when you boot the floppy. It also does
NOT mean that PicoBSD has to use your HDD and existing FreeBSD installation
in order to work. Quite contrary! Please remember that symlinks are just
what they are - they just _point_ somewhere, and their target even doesn't
have to exist. In our case, their target is actually your ${TYPE}/mfs.tree/stand
directory, but only after booting the floppy, when the MFS filesystem is
mounted on '/'.
-
Make sure that the system you're running has /dev/[r]vn0* entries in /dev
directory (if not, you can make them with 'MAKEDEV vn0'), AND that your
running kernel has built-in vnode driver (there should be a line in your
kernel config file stating 'pseudo-device vn').
-
You'll need at least 9MB of free disk space, and free /mnt directory.
-
cd scripts/ and fire off the './build' script. Select the build parameters
or 'n' for 'no change'. If all is well, after some time (like 10-30m) you
end up with a 'picobsd.flp' file in this directory.
WARNING: make sure you don't have stale .depend files around!!! You'll
encounter many strange errors in that case.
If there were any errors, please execute each script by hand and try
to find what causes this error. Most often this will be one of the following
reasons:
-
crunchgen can't find the source directory for a program 'proggy':
-
make sure that the source directory for 'proggy' is called 'proggy', otherwise
the crunchgen won't find it
-
make sure that the Makefile allows crunchgen to deduce the set of objects
to build. You can manually add an OBJS= ...
-
crunch fails to build.
-
check your system source tree for stale .depend files and/or *.o
-
see if the individual programs can be built using original Makefiles. If
not, cvsup the correct sources.
-
/: write failed - file system is full
-
this one is obvious - you wanted to put too many programs on the MFS and/or
the target floppy.
-
also, you can check if the MFS size is correctly reported while it's still
mounted (right after stage1).
You can also remove 2>&1 redirections from Makefiles to see the stderr.
-
Transfer this file to the floppy:
dd if=picobsd.flp of=/dev/rfd0
(The 'build' script asks you if you want to do this.)
That's all. You're welcome to change and improve these scripts. If you
stumble upon something which looks like a good idea to have it here, let
me know.
If, for some reason, the scripts don't work for you at all, also let
me know.
For those of you who really want to know what's going on behind the
scene, and can't quite deduce it from scripts themselves, here's short
description of the build process:
-
The './build' script sets the basic parameters of the floppy, such as:
-
LANGUAGE: language of the various system messages, and C locale.
-
SIZE: size of the memory filesystem (MFS), which will contain all the binaries
(except the kernel). Make it big enough for all the pieces to fit, but
keep it as small as possible (remember that running system needs some space
in /var and /tmp!). Presently, "dial" type of floppy requires at least
SIZE=2200, and others require ca. 2800 (numbers are in kB).
-
TYPE: determines which set of programs and which trees will be installed
on the floppies. This simply acts as a selector to dive into respective
subdirectories in ../. Presently, the TYPE can be one of: "dial" (dialup
floppy), "net" (router-like floppy) or "isp" (work in progress - not really
usable in v.0.3).
-
Then the './build' scripts checks if there is a kernel built on basis of
previously set parameters. The check is error prone, but is simple: the
target config file is called PICOBSD-${TYPE}.${SIZE}, and if there exists
a file called /sys/compile/PICOBSD-${TYPE}.${SIZE}/kernel, then it is assumed
it's the right one.
If there is no such file, the script starts compilation of the kernel,
using template in ../${YTPE}/conf/PICOBSD, and adding parameters which
determine the built-in MFS size.
-
Then the './build' script starts the consecutive stages of the build process,
which are performed by scripts (in the following order): stage1, populate,
stage2, stage3.
-
'stage1' prepares the file called fs.PICOBSD with given size - it's a placeholder
for the future MFS. Next, it turns it into device (using vnconfig), and
then performs some tricks :-) which allow for doing 'disklabel'. I use
the 'auto' option to disklabel(8), which behaves strangely in 2.2.x - what
it's supposed to do is to automagically determine the disk parameters from
the underlying device (in this case, /dev/rvn0). This works ok in 3.0-current,
and allows for using arbitrary (>1024kB) MFS sizes.
After the file is labelled, the newfs(8) is run. Here you can adjust
the parameter -i, which can gain you some space on the MFS (sacrificing
available number of inodes, so be careful).
Such prepared blank filesystem is mounted on /mnt. Here the stage1 ends.
-
'populate', as its name suggests, transfers all the pieces which will reside
in MFS, to the filesystem mounted on /mnt. This includes:
-
copying language dependent files from ../${TYPE}/lang/
-
transfering the MFS hierarchy, contained in from ../${TYPE}/mfs.tree/ subdir.
This tree includes the /etc, which contains the startup file /etc/rc.
This file in turn doesn't do anything useful except copying the real /etc
hierarchy from the floppy filesystem. (There's one possible improvement
which comes to my mind - to have the whole /etc on the floppy in tar.gz
- this would require only one inode to store the whole /etc, and we could
gain some kB on the floppy)
This tree includes also several symbolic links to /stand - of course,
what they really are going to point to (at runtime) is the floppy's /stand
directory, not your /stand on HDD (though it seems so at the moment :-).
-
making and installing the set of crunched programs, basing on the description
in ../${TYPE}/crunch1/crunch.conf. This involves making the 'crunch', copying
it to /mnt and making hard links to the names of all the programs contained
therein.
-
preparing a short list of kernel symbols, which will be used by various
utilities at runtime. In case of "net" floppy, it also prepares the kvm_kernel.db
database, which will be used by such programs as ps, netstat and others
-
preparing the list of "virgin" configuration of devices in kernel - this
list will be used by kget(8) program to save the changes to /kernel.config
file.
-
'stage2' prepares the target kernel. It takes the filesystem contained
in fs.PICOBSD (which has all the above pieces inside), and writes it into
the target kernel. Then it kzip(8)'s such construed kernel. This process
also strips the symbols from the kernel (that's why we prepared the symbol
list earlier).
-
'stage3' does almost the same as 'stage1', but this time it prepares the
filesystem of the target floppy. Default size for the floppy is set at
1440kB.
After preparing the filesystem (which again involves doing disklabel(8)
and newfs(8) - here you can notice that the resulting FS has very small
number of inodes in order to save space), the script transfers the floppy
hierarchy (which is taken from ../${TYPE}/floppy.tree). Notice that it
also contains the /etc directory - its contents is copied right after bootup
to the real /etc in MFS. This allows for changing the system behaviour
(because you can't change the MFS contents without recompiling).
The script finally copies previously prepared kernel to the floppy filesystem.
The filesystem is unmounted, and here the build process ends.
Last modified: Fri May 22 19:10:15 MYT 1998