Date: Wed, 28 Apr 1999 22:28:49 -0700 (PDT) From: papowell@astart4.astart.com To: freebsd-small@FreeBSD.ORG Cc: papowell@astart4.astart.com Subject: Revised picobsd Build Procedures and Scripts (Not official) Message-ID: <199904290528.WAA08070@astart4.astart.com>
next in thread | raw e-mail | index | archive | help
The following is NOT repeat NOT an official update. Beware! Your milage may vary, not valid in states with right angle corner borders (quick! How many is that?) and has been shown to cause brain damage in student assistants. Enjoy. Note: My best regards, wishes, thanks, and admiration to Andrzej Bialecki <abial@webgiro.com> Michael Bretterklieber <mbretter@sbox.tu-graz.ac.at> Patrick ("Documentation? Hell, most of the staff here can't even THINK in sentences. Forth, PostScript, Perl, and Tcl/Tk has taken their toll.") Powell Patrick Powell Astart Technologies, papowell@astart.com 9475 Chesapeake Drive, Suite D, Network and System San Diego, CA 92123 Consulting 619-874-6543 FAX 619-279-8424 LPRng - Print Spooler (http://www.astart.com) Revised picobsd Build Procedures and Scripts For Compliance with FreeBSD 3.1-RELEASE Patrick Powell <papowell@astart.com> Wed Apr 28 20:26:09 PDT 1999 1. Modifications The modifications to the picobsd build procedures was done as a result of working only with the FreeBSD 3.1-RELEASE and reflects the current use of the various utilities. These include a. VNODE support b. disklabel utility c. newfs utility In addition, the scripts have been modified to allow a user specified configuration similar to the net, isp, router, dialer and custom provided by the original Build procedures. Finally, an effort was made to extend the scripts to handle more (and less) number of files in the various crunch, mfs.tree, and floppy.tree systems. 2. Missing kzip /usr/lib/aout files on FreeBSD 3.1-RELEASE The necessary library files for the kzip utility are missing on the FreeBSD 3.1-RELEASE. Do the following steps to create and install them: cd /usr/src/sys/i386/boot/kzipboot make all install Note: kzip is present, but for completeness, you create and install using: cd /usr/src/usr.bin/kzip make all install 3. Build Script Modifications build -> build + build_script The build script was modified and the 'build_kernel' function was extracted and made a separate file. This allows the set -e to be used and greated control of error detection and reporting during the build_kernel phase. The set -e option was used in all scripts to terminate at the first error. Checks for file existence were added to prevent the copying of a non-existent file to terminate operation. You can also specify a 'configuration' in a fashion similar to the isp, router, etc. The kernel naming conventions have been changed slightly to allow more flexibility in this. There were a bunch of initializations that needed to be fixed up when the user configuration stuff was done. 4. MFS and Floppy Image Generation The following modificiations were made in order to be compliant with the current VNODE support commands vnconfig, disklabel, and newfs. MFS Creation (stage1 script) umount /dev/vn0 2> /dev/null || true umount /mnt 2> /dev/null || true vnconfig -u /dev/rvn0 2> /dev/null || true dd of=fs.PICOBSD if=/dev/zero count=${SIZE} bs=1k 2> /dev/null vnconfig -s labels -c /dev/rvn0 fs.PICOBSD 2>/dev/null disklabel -rw vn0 auto INODES=4096 newfs -i $INODES -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null mount /dev/vn0c /mnt The dd command creates the fd.PICOBSD file, the vnconfig with the appropriate options will use it as a device, and then the disklabel command will simply label it. Note that since this is NOT a bootable device, no boot blocks need to be installed. Finally, we do a newfs to create the file system structure and then we mount it. Floppy Image file Creation (stage3 script) umount /dev/vn0 2> /dev/null || true umount /mnt 2> /dev/null || true vnconfig -u /dev/rvn0 2> /dev/null || true dd of=picobsd.bin if=/dev/zero count=1440 bs=1k 2> /dev/null vnconfig -c /dev/rvn0 picobsd.bin 2>/dev/null disklabel -Brw /dev/rvn0 fd1440 2>&1 >/dev/null newfs -i 4096 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null mount /dev/vn0c /mnt This is almost identical to the previous step, with the modified disklabel command. The -Brw option will cause boot blocks to be put onto the image, and the fd1440 disktab entry sets the geometry. The news command will create a disk with 4096 inodes - this has been reduce to 1024 in testing with no problems. Note that the number of inodes can be pretty small on the root system if you create an MFS system for general use. 4. Detailed Description of Boot Sequence The following is a detailed description of how the system boots from the boot floppy, and how this sequence relates to the commands in the stage3 file used to generate the boot disk. In the stage3 build script, we create and mount the floppy image on /mnt using the dd, vnconfig, newfs, and mount commands described above. The kernel has been created and compressed using gzip. We copy the kernel to the floppy image: cp kernel.gz /mnt/kernel.gz At this point, if we use dd to copy the floppy image to a floppy disk, we would discover that the boot loader could not handle a compressed kernel. In the past, this was handled by the kzip utility, which would compress the kernel and then prefix and append some code that would uncompress and then execute the kernel. We will use a different and rather more elaborate method for booting. Here is the boot sequence: (boot0 on floppy sector 0/0/1) loaded into memory and executed This is done by the PC BIOS. Boot1 uses the PC BIOS facilities, and is limited to reading a boot record by the various limitations of the PC BIOS facilities. boot1 finds UNIX partition, brings in boot2, starts execution of boot2 Boot1 looks at the partition table information and finds the 'active' partition and loads 'boot2' from a fixed location on the partition. Boot2 has quite a bit of the UNIX ufs file system, and can understand UFS file systems. boot2 will open /boot.config, read THE SINGLE LINE IN THE FILE, and interpret it as the name of a kernel and some options to pass to the kernel. You can interatively specify these values by pressing a key during the boot process and entering them at the prompt. The PICOBSD setup initializes boot.config with the line: /boot/loader which tells boot2 to use the /boot/loader code as a kernel. What is this all about? The answer is simple: we want to be able to configure the devices and we need a loader that is smart enough to uncompress our kernel. The boot3 loader (just called loader now) is a little big, so we use the kzip (kernel zip) facility to compress it and attach a bit of code to decompress and then run the compressed code. As I were saying, the boot2 loader copies the file /boot/loader into memory now executes it. The /boot/loader will now uncompress itself and will then read the (this is documented in the source code) file /boot/loader.rc This file contains a list of commands that the loader understands. (Aside: /boot/loader.rc used to be /boot/boot.conf in earlier FreeBSD releases, and this name is is pretty close to boot.config (see above). I wonder how many people this has confused?). If there are no commands then the /boot/loader will try to load kernel and then kernel.old by default. Note that kernel.gz and kernel.old.gz will also be tried. The /boot/loader.rc file on the floppy disk contains the following lines: load /kernel load -t userconfig_script /kernel.config boot -P If you are interested in this stuff, see /usr/src/boot/common/help.common for a complete list of commands understood by the loader. The load /kernel causes the loader to look for /kernel and /kernel.gz, which it will unzip and loader into memory. The load -t userconfig_script /kernel.config will cause the loader to pass to the kernel's a 'userconfig_script' option with the value "/kernel.config". The 'userconfig' module in the kernel (see /usr/src/sys/i386/i386/userconfig.c for the nasty details) will open and read this file, getting commands to set device configuration and other things. These commands can be: example di disable dev di de0 dr drq dev # dr 4 ei # EISA slots ei 4 en enable dev en ep0 ex exit (quit) ex f flags dev mask f de0 0xff h help intro intro screen iom iomem dev addr iom ed0 0xdf0000 ios iosize dev size iosize ed0 0x1000 ir irq dev # irq ed0 5 l ls, list l pn pnp (scan) pnp po port dev addr port ed0 0x300 res reset CPU res q quit q v visual mode v These commands are useful if you have a stock kernel and need to use it on systems with a differnt set of hardware. The need for port (io) address and interrupt modification is used only with ISA and not with PCI bus cards. The boot -P command line will boot it with the -P (use serial console if no keyboard) option. (see man boot for details of the flags). Finally, after all this work, the kernel is uncompressed and loaded into memory, and kernel execution is started. The kernel does its initialization, and then the userconfig kernel module is initialized. The 'userconfig_script' setting will cause it to it reads the /kernel.config file, and then, since we have generated our kernel with the INTRO_USERCONFIG option, the kernel will go into VISUAL userconfig operation. To stop the loader from going into /kernel.config user interactive mode automatically, you need to modify the PICOBSD configuration file. Comment out the following line: options INTRO_USERCONFIG #imply -c and parse and regenerate the kernel. Here are the commands used to set up all of this: # we make a compressed loader mkdir /mnt/boot cp /boot/loader . kzip -v loader mv loader.kz /mnt/boot/loader rm -f loader loader.o # set up the /boot.config file to cause boot2 to load /boot/loader echo "/boot/loader" >/mnt/boot.config # set up the /boot/loader.rc to cause the /boot/loader to # load in the kernel and set options cat >/mnt/boot/loader.rc <<EOF load /kernel load -t userconfig_script /kernel.config boot -P EOF # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # README # build # build_kernel # clean # install # modify # populate # stage1 # stage2 # stage3 # echo x - README sed 's/^X//' >README << 'END-of-README' X Revised picobsd Build Procedures and Scripts X For Compliance with FreeBSD 3.1-RELEASE X Patrick Powell <papowell@astart.com> X Wed Apr 28 20:26:09 PDT 1999 X X1. Modifications X X The modifications to the picobsd build procedures was done X as a result of working only with the FreeBSD 3.1-RELEASE X and reflects the current use of the various utilities. X X These include X a. VNODE support X b. disklabel utility X c. newfs utility X X In addition, the scripts have been modified to allow a user X specified configuration similar to the net, isp, router, dialer X and custom provided by the original Build procedures. X X Finally, an effort was made to extend the scripts to handle more X (and less) number of files in the various crunch, mfs.tree, X and floppy.tree systems. X X X2. Missing kzip /usr/lib/aout files on FreeBSD 3.1-RELEASE X X The necessary library files for the kzip utility are missing on the X FreeBSD 3.1-RELEASE. Do the following steps to create and install them: X X cd /usr/src/sys/i386/boot/kzipboot X make all install X X Note: kzip is present, but for completeness, you create and install X using: X cd /usr/src/usr.bin/kzip X make all install X X3. Build Script Modifications X X build -> build + build_script X X The build script was modified and the 'build_kernel' X function was extracted and made a separate file. This allows X the set -e to be used and greated control of error detection X and reporting during the build_kernel phase. X X The set -e option was used in all scripts to terminate at the X first error. Checks for file existence were added to prevent X the copying of a non-existent file to terminate operation. X X4. MFS and Floppy Image Generation X X The following modificiations were made in order to be compliant X with the current VNODE support commands vnconfig, disklabel, X and newfs. X X MFS Creation (stage1 script) X X umount /dev/vn0 2> /dev/null || true X umount /mnt 2> /dev/null || true X vnconfig -u /dev/rvn0 2> /dev/null || true X dd of=fs.PICOBSD if=/dev/zero count=${SIZE} bs=1k 2> /dev/null X vnconfig -s labels -c /dev/rvn0 fs.PICOBSD 2>/dev/null X disklabel -rw vn0 auto X INODES=4096 X newfs -i $INODES -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null X mount /dev/vn0c /mnt X X The dd command creates the fd.PICOBSD file, the X vnconfig with the appropriate options will use it as a X device, and then the disklabel command will simply label it. X Note that since this is NOT a bootable device, no boot blocks X need to be installed. Finally, we do a newfs to create the X file system structure and then we mount it. X X Floppy Image file Creation (stage3 script) X X umount /dev/vn0 2> /dev/null || true X umount /mnt 2> /dev/null || true X vnconfig -u /dev/rvn0 2> /dev/null || true X dd of=picobsd.bin if=/dev/zero count=1440 bs=1k 2> /dev/null X vnconfig -c /dev/rvn0 picobsd.bin 2>/dev/null X disklabel -Brw /dev/rvn0 fd1440 2>&1 >/dev/null X newfs -i 4096 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null X mount /dev/vn0c /mnt X X This is almost identical to the previous step, with the X modified disklabel command. The -Brw option will cause X boot blocks to be put onto the image, and the fd1440 X disktab entry sets the geometry. The news command will X create a disk with 4096 inodes - this has been reduce to X 1024 in testing with no problems. Note that the number of X inodes can be pretty small on the root system if you create X an MFS system for general use. X X4. Detailed Description of Boot Sequence X XThe following is a detailed description of how the system boots Xfrom the boot floppy, and how this sequence relates to the commands Xin the stage3 file used to generate the boot disk. X XIn the stage3 build script, we create and mount the floppy image Xon /mnt using the dd, vnconfig, newfs, and mount commands described Xabove. X XThe kernel has been created and compressed using gzip. We copy Xthe kernel to the floppy image: X X cp kernel.gz /mnt/kernel.gz X X XAt this point, if we use dd to copy the floppy image to a floppy Xdisk, we would discover that the boot loader could not handle a Xcompressed kernel. In the past, this was handled by the kzip Xutility, which would compress the kernel and then prefix and append Xsome code that would uncompress and then execute the kernel. We Xwill use a different and rather more elaborate method for booting. X X XHere is the boot sequence: X X (boot0 on floppy sector 0/0/1) loaded into memory and executed X XThis is done by the PC BIOS. Boot1 uses the PC BIOS facilities, Xand is limited to reading a boot record by the various limitations Xof the PC BIOS facilities. X X boot1 finds UNIX partition, brings in boot2, starts execution of boot2 X XBoot1 looks at the partition table information and finds the 'active' Xpartition and loads 'boot2' from a fixed location on the partition. X X XBoot2 has quite a bit of the UNIX ufs file system, and can understand XUFS file systems. boot2 will open /boot.config, read THE SINGLE XLINE IN THE FILE, and interpret it as the name of a kernel and some Xoptions to pass to the kernel. You can interatively specify these Xvalues by pressing a key during the boot process and entering them Xat the prompt. X XThe PICOBSD setup initializes boot.config with the line: X X /boot/loader X Xwhich tells boot2 to use the /boot/loader code as a kernel. X XWhat is this all about? The answer is simple: we want to be able to Xconfigure the devices and we need a loader that is smart enough Xto uncompress our kernel. The boot3 loader (just called loader now) Xis a little big, so we use the kzip (kernel zip) facility Xto compress it and attach a bit of code to decompress and then run Xthe compressed code. X X XAs I were saying, the boot2 loader copies the file /boot/loader Xinto memory now executes it. The /boot/loader will now uncompress Xitself and will then read the (this is documented in the source Xcode) file X X /boot/loader.rc X XThis file contains a list of commands that the loader understands. X(Aside: /boot/loader.rc used to be /boot/boot.conf in earlier FreeBSD Xreleases, and this name is is pretty close to boot.config (see above). XI wonder how many people this has confused?). If there are no commands Xthen the /boot/loader will try to load kernel and then kernel.old Xby default. Note that kernel.gz and kernel.old.gz will also be tried. X XThe /boot/loader.rc file on the floppy disk contains the following lines: X X load /kernel X X load -t userconfig_script /kernel.config X X boot -P X XIf you are interested in this stuff, see /usr/src/boot/common/help.common Xfor a complete list of commands understood by the loader. X XThe load /kernel causes the loader to look for /kernel and /kernel.gz, Xwhich it will unzip and loader into memory. X XThe load -t userconfig_script /kernel.config will cause the loader Xto pass to the kernel's a 'userconfig_script' option with the value X"/kernel.config". The 'userconfig' module in the kernel (see X/usr/src/sys/i386/i386/userconfig.c for the nasty details) will Xopen and read this file, getting commands to set device configuration Xand other things. These commands can be: X X example X di disable dev di de0 X dr drq dev # dr 4 X ei # EISA slots ei 4 X en enable dev en ep0 X ex exit (quit) ex X f flags dev mask f de0 0xff X h help X intro intro screen X iom iomem dev addr iom ed0 0xdf0000 X ios iosize dev size iosize ed0 0x1000 X ir irq dev # irq ed0 5 X l ls, list l X pn pnp (scan) pnp X po port dev addr port ed0 0x300 X res reset CPU res X q quit q X v visual mode v X XThese commands are useful if you have a stock kernel and need to Xuse it on systems with a differnt set of hardware. The need for Xport (io) address and interrupt modification is used only with ISA Xand not with PCI bus cards. X XThe boot -P command line will boot it with the -P (use serial Xconsole if no keyboard) option. (see man boot for details of the Xflags). X XFinally, after all this work, the kernel is uncompressed and Xloaded into memory, and kernel execution is started. The kernel Xdoes its initialization, and then the userconfig kernel module is Xinitialized. The 'userconfig_script' setting will cause it to it Xreads the /kernel.config file, and then, since we have generated Xour kernel with the INTRO_USERCONFIG option, the kernel will go Xinto VISUAL userconfig operation. X XTo stop the loader from going into /kernel.config Xuser interactive mode automatically, you need to modify the XPICOBSD configuration file. Comment out the following line: X X options INTRO_USERCONFIG #imply -c and parse X Xand regenerate the kernel. X XHere are the commands used to set up all of this: X X # we make a compressed loader mkdir /mnt/boot cp /boot/loader . X kzip -v loader mv loader.kz /mnt/boot/loader rm -f loader loader.o X X # set up the /boot.config file to cause boot2 to load /boot/loader X echo "/boot/loader" >/mnt/boot.config X X # set up the /boot/loader.rc to cause the /boot/loader to X # load in the kernel and set options X X cat >/mnt/boot/loader.rc <<EOF X load /kernel X load -t userconfig_script /kernel.config X boot -P X EOF X X END-of-README echo x - build sed 's/^X//' >build << 'END-of-build' X#!/bin/sh - X X# usage: build [what] X# what can be 'dial', 'net', 'isp', 'router', user X# X X# X# $Id: build,v 1.12 1999/01/19 23:02:05 abial Exp $ X# X Xwhile [ -n "$1" ] ; do X case "$1" in X -v ) verbose=-x; X set -x X ;; X * ) break;; X esac Xdone X X# You can set the SRC variable which points to your source tree. It's X# /usr/src by default (most people shouldn't change it). XSRC=/usr/src X X# Default MFS sizes for different types of the floppy. Again, most people X# shouldn't change them unless they know what they are doing. X XDIAL_DFLT_SIZE=1600 XROUTER_DFLT_SIZE=820 XNET_DFLT_SIZE=1700 XISP_DFLT_SIZE=1700 XDFLT_SIZE=1700 X X# DEVFS is currently broken. Always set this. X# XNO_DEVFS=yes X X# Path to srcdirs of special program for init(8) (standard if empty) XINIT= X X# --------- YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW ----------- X# The "build" script will ask you for parameters. Just run it... :-) X# --------- YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW ----------- X X X# Build kernel with previously set parameters. X X X# Main build procedure. It calls other scripts (stage1-3 and populate) Xmain() { X Xsuffix="-$TYPE" Xexport suffix Xif [ ! -d ../${TYPE} ] ; then X echo "You need `pwd`/../${TYPE} directory "; false; fi; Xif [ ! -f ../${TYPE}/conf/PICOBSD ] ; then X echo "You need `pwd`/../${TYPE}/conf/PICOBSD file"; false; fi; X Xclear Xecho "-> Building with following parameters:" Xecho -n " Type: ${TYPE}" Xif [ "X${INIT}" != "X" ] Xthen X echo " (using ${INIT} as init(8))" Xelse X echo "" Xfi Xecho " MFS size: ${SIZE} kB" Xecho " Language: ${LANGUAGE}" Xecho "" Xecho "-> We'll use the sources living in ${SRC}" Xecho "" Xecho "-> I hope you have checked the ../${TYPE}/conf/PICOBSD config file..." Xecho "" Xecho "" X# sleep 2 X X Xexport SIZE LANGUAGE TYPE SRC NO_DEVFS INIT X Xfor i in build_kernel stage1 populate stage2 stage3 Xdo X echo "====================== ${i} started =====================" X sh $verbose ./${i} X if [ "X$?" != "X0" ] X then X echo "" X echo "-> ERROR in \"${i}\" script. Aborting the build process." X echo -n "-> Cleaning temporary files... " X umount -f /mnt X vnconfig -u /dev/rvn0 X ./clean ${TYPE} X echo "Done." X exit 10 X else X echo "==================== ${i} completed =====================" X fi Xdone X} X X# Ask for, and set the custom config directory X Xset_custom() { X clear X echo " Custom directory setup" X echo "" X echo "Please enter the full path to the directory containing your" X echo "custom setup." X echo "This directory tree must be laid out exactly like the standard" X echo "ones. (E.g. you can type in /home/abial/work/custom, which" X echo "should contain conf/, crunch1/, floppy.tree/, lang/, mfs.tree/)." X echo "" X read -p "Enter the custom directory: " CUST_DIR X if [ "X${CUST_DIR}" = "X" ] X then X echo "-> Error. Custom directory cannot be null!" X exit 1 X fi X} X X# Set the LANGUAGE variable X Xset_lang() { X clear X echo " Language setup" X echo "" X echo "Language can be either 'en' (English - default) or 'pl' (Polish)" X echo "" X read -p "Enter the LANGUAGE (en, pl): " LANGUAGE X if [ "X${LANGUAGE}" = "X" ] X then X LANGUAGE=en X fi X} X X# Set the INIT variable X Xset_init() { X clear X echo " Choose your init(8) program" X echo "" X echo "You can choose either standard init(8) (which requires getty), or" X echo "you can choose 'oinit' from TinyWare collection." X echo "" X read -p "Enter the INIT (init, oinit): " INIT X if [ "X${INIT}" = "Xinit" ] X then X unset INIT X fi X} X X# Set the default MFS size depending on the type of setup Xset_dflt_size() { X if [ -z "$SIZE" ] ; then X case $TYPE in X dial ) SIZE=$DIAL_DFLT_SIZE;; X net ) SIZE=$NET_DFLT_SIZE;; X router ) SIZE=$ROUTER_DFLT_SIZE;; X isp ) SIZE=$ISP_DFLT_SIZE;; X * ) SIZE=$DFLT_SIZE;; X esac X fi; X echo "default MFS size for \"${TYPE}\" type floppy is ${SIZE} K" X} X X# Set the default INIT size depending on the type of setup X Xset_dflt_init() { X if [ -z "$INIT" ] ; then X case $TYPE in X router ) INIT=oinit;; X esac X fi; X echo "default INIT for \"${TYPE}\" is '${INIT}'" X} X X# Set MFS size interactively X Xset_size() { X clear X echo " Memory Filesystem (MFS) Size setup" X echo "" X echo " Size can be anything decent (usually 1700 or 2500) in kB." X echo " NOTE1: you can also use other numbers (e.g. 1500, 1456, 1789 ...)" X echo " even much bigger (like 4567), but keep in mind that this memory is" X echo " totally lost to other programs. Usually you want to keep this as small as" X echo " possible." X echo "" X echo " NOTE2: for pre-canned setups there are specific requirements:" X echo " dial - requires at least SIZE=$DIAL_DFLT_SIZE" X echo " router - requires at least SIZE=$ROUTER_DFLT_SIZE (500kB less without SNMP)" X echo " net - requires at least SIZE=$NET_DFLT_SIZE (500kB less without SNMP)" X echo " isp - requires at least SIZE=$ISP_DFLT_SIZE (500kB less without SNMP)" X echo "" X echo " The last two configurations are not likely to run reliably on machines" X echo " with less than 10MB of RAM, while the 'dial' is tested and proved to run" X echo " as many as ~30 processes on 10 consoles with only 8MB RAM. YMMV." X echo "" X read -p "Enter the SIZE in kB: " SIZE X if [ "X${SIZE}" = "X" ] X then X set_dflt_size X fi X} X X# Set type of floppy interactively X Xset_type() { X clear X echo " Setup the type of configuration" X echo "" X X echo " Type can be either 'dial', 'router', 'net' or 'isp'. There are four" X echo " sets of configuration files in subdirs ../dial, ../router, ../net" X echo " and ../isp respectively - the contents of the floppy is constructed" X echo " basing on the Makefiles and scripts in them." X echo "" X echo " You can also type in 'custom', and you'll be asked to enter the" X echo " full path to directory tree, where you stored your custom" X echo " configuration, laid out exactly like the standard ones. (E.g." X echo " you can type in /home/abial/work/custom, which should contain" X echo " conf/, crunch1/, floppy.tree/, lang/, mfs.tree/)." X echo "" X echo " If you define TYPE=dial, you'll end up having a floppy which is" X echo " suitable for dialup access and not much else. If you define TYPE=net," X echo " you'll have a small router-fixit-like floppy, which lacks most" X echo " interactive tools. TYPE=isp gives you a dialin server floppy." X echo "" X read -p "Enter the TYPE of the floppy (dial, net, router, isp): " TYPE X if [ "X${TYPE}" = "X" ] X then X TYPE=dial X fi X case $TYPE in X custom ) X set_custom X (ln -sf ${CUST_DIR} ../custom) X ;; X esac X set_dflt_size X set_dflt_init X} X Xput_title() { X clear X echo " Building the PicoBSD v. 0.4 floppy" X echo "============================================================================" X echo "" X} X X X#------------------------------------------------------------------- X# Main entry of the script X X# If $1="package", it creates a neat set of floppies X Xif [ X"$1" = X"package" ] Xthen X touch build.status X echo "##############################################" >>build.status X echo "## `date` ">>build.status X echo "##############################################" >>build.status X ./clean dial X for y in en pl X do X for z in dial router net isp X do X TYPE=${z} X LANGUAGE=${y} X INIT= X SIZE= X set_dflt_size X set_dflt_init X echo "---------------------------------------------">>build.status X echo "Building TYPE=${z}, LANGUAGE=${y}, INIT=${INIT}, SIZE=${SIZE}" >>build.status X export TYPE SIZE LANGUAGE SRC NO_DEVFS INIT X main X if [ "X$?" != "X0" ] X then X echo " ** FAILED! **">>build.status X else X echo " (ok)">>build.status X fi X mv picobsd.bin pb_${y}${suffix}.bin X echo "Calling ./clean for ${TYPE}, ${LANGUAGE}, ${SIZE}">>build.status X ./clean ${TYPE} X done X done X exit 0 Xfi X X# Set build parameters interactively X XTYPE=$1 Xif [ -z "$TYPE" ] ; then X TYPE=dial Xfi; XLANGUAGE=en Xset_dflt_size Xset_dflt_init Xif [ "$1X" = "X" ] ; then Xwhile [ "X${ans}" != "Xn" ] Xdo X put_title X echo "Current build parameters are as follows:" X echo "" X echo " 1. Type: ${TYPE}" X if [ "X${INIT}" != "X" ] X then X echo " a. (using ${INIT} as init(8))" X else X echo " a. (using stock init as init(8))" X fi X echo "" X echo " 2. MFS size: ${SIZE} kB" X echo " 3. Language: ${LANGUAGE}" X echo "" X echo "Which parameter would you like to change?" X read -p "(1, a, 2, 3; n -no change, build it ; q -quit): " ans X case ${ans} in X 1) set_type X clear X ;; X a) set_init X clear X ;; X 2) set_size X clear X ;; X 3) set_lang X clear X ;; X q) echo "" X echo "Hey! Don't give up so quickly. Quitting for now..." X echo "" X exit 0 X ;; X n) ;; X *) echo "Unknown option \"${ans}\". Try again." X sleep 2 X clear X ;; X esac Xdone Xfi X# Export the parameters Xexport LANGUAGE SIZE TYPE SRC NO_DEVFS INIT X# Call the build procedure Xmain X# Install if it's ok. Xecho "" Xif [ "X$?" = "X0" ] Xthen X echo "The build process was completed successfuly." X echo "" X echo "Now we are going to install the image on the floppy." X ./install Xfi Xexit 0 END-of-build echo x - build_kernel sed 's/^X//' >build_kernel << 'END-of-build_kernel' X#!/bin/sh - X# build a kernel X Xset -e Xecho "" Xecho "-> Checking if we have to build the PICOBSD kernel..." X(cd ../${TYPE}/conf; make) Xecho "" END-of-build_kernel echo x - clean sed 's/^X//' >clean << 'END-of-clean' X#! /bin/sh - X X# X# $Id: clean,v 1.7.2.1 1999/02/05 12:15:00 abial Exp $ X# Xset -e X Xif [ $# -lt 1 ] Xthen X echo "What to clean? Possible targets are 'dial', 'net', 'isp', 'router' or 'all'" X exit 1 Xfi X Xif [ "$1" = "all" ] Xthen X list="dial net isp router" X if [ -f picobsd.bin ] X then X mv -f picobsd.bin picobsd.bin.old X fi Xelse X list=$1 X if [ -f picobsd.bin ] X then X mv -f picobsd.bin picobsd.bin.$1 X fi Xfi X Xrm -f kernel kernel.kz fs.PICOBSD *.o *core *.db Xcd .. Xrm -rf help/tmp_hlp Xecho "===================== $0 tools started ====================" Xfor i in `ls -d tinyware/[a-z]*` tools/write_mfs_in_kernel Xdo X (cd ${i}; \ X if [ -f Makefile ]; \ X then \ X make clean && make cleandepend;\ X fi) Xdone Xfor j in $list Xdo X echo "===================== $0 $j started ======================" X (cd ${j}/crunch1; \ X if [ -f Makefile ]; \ X then \ X make clean ; \ X fi) X echo "=============== $0 $j completed successfuly ==============" Xdone END-of-clean echo x - install sed 's/^X//' >install << 'END-of-install' X#!/bin/sh X X# X# $Id: install,v 1.2 1998/09/29 11:58:54 abial Exp $ X# XFILENAME=picobsd.bin X Xset -e X Xecho "Please insert a blank floppy in /dev/fd0." Xecho "WARNING: the contents of the floppy will be permanently erased!" Xecho "Your options:" Xecho " * ^C to abort," Xecho " * Enter to install \"${FILENAME}\"," Xecho " * name of other file to install." Xecho "" Xread -p "Your choice: " junk Xif [ "X${junk}" != "X" ] Xthen X FILENAME=${junk} Xfi Xecho "Writing ${FILENAME}..." Xdd if=${FILENAME} of=/dev/rfd0 Xecho "Done." END-of-install echo x - modify sed 's/^X//' >modify << 'END-of-modify' X#!/bin/sh X X# Mount the picobsd.bin image on /mnt X# so you can modify the files X# X Xumount /mnt 2> /dev/null || true Xumount /dev/vn0 2> /dev/null || true Xvnconfig -u /dev/rvn0 2> /dev/null || true Xvnconfig -c /dev/rvn0 picobsd.bin 2>/dev/null Xmount /dev/vn0c /mnt END-of-modify echo x - populate sed 's/^X//' >populate << 'END-of-populate' X#!/bin/sh -x X# X# $Id: populate,v 1.8.2.2 1999/02/15 00:29:51 abial Exp $ X# X Xset -e X. ../Version X Xpwd=`pwd` X Xecho "-> Populating MFS tree..." Xcd ../${TYPE}/mfs.tree Xmake Xif [ X"${NO_DEVFS}" != X"" ] Xthen X make devnodes Xfi X X# we put in the /etc/rc script X# if there is a ../lang.mfs.rc.${LANGUAGE} -> /etc/rc X# if there is a ../lang.mfs.oinit.rc.${LANGUAGE} -> /etc/oinit.rc X Xif [ -f ../lang/mfs.rc.${LANGUAGE} ] ; then X cat ../lang/mfs.rc.${LANGUAGE}| \ X sed -e "s/@VER@/${VER}/g" > \ X /mnt/etc/rc Xfi X Xif [ -f ../lang/mfs.oinit.rc.${LANGUAGE} ] ; then X cat ../lang/mfs.oinit.rc.${LANGUAGE}| \ X sed -e "s/@VER@/${VER}/g" > \ X /mnt/etc/oinit.rc Xfi X Xif [ ! -f /mnt/etc/oinit.rc -a -f /mnt/etc/rc ] ; then X ln -s rc /mnt/etc/oinit.rc Xfi X Xif [ -f login.conf ] ; then X cp login.conf /mnt/etc/login.conf Xfi; X Xif [ ../lang/README.${LANGUAGE} ] ; then X cat ../lang/README.${LANGUAGE} | \ X sed -e "s/@VER@/${VER}/g" > \ X /mnt/README Xfi; Xif [ -f ../lang/update.${LANGUAGE} ] ; then X cp ../lang/update.${LANGUAGE} /mnt/stand/update Xfi Xif [ "${TYPE}" = "dial" ] Xthen X cp ../lang/reboot.${LANGUAGE} /mnt/stand/reboot X ln -f /mnt/stand/reboot /mnt/stand/shutdown X cp ../lang/login.${LANGUAGE} /mnt/stand/login X cp ../lang/dialup.${LANGUAGE} /mnt/stand/dialup X (cd ../../help;\ X rm -rf tmp_hlp;\ X mkdir tmp_hlp;\ X for i in `ls *.hlp.${LANGUAGE}`;\ X do \ X cp $i tmp_hlp/`basename $i .hlp.${LANGUAGE}`;\ X done;\ X cd tmp_hlp;\ X ar -cru help.a *;\ X cp help.a /mnt/help.a) Xfi X Xecho "-> Making and installing crunch1..." Xcd ../crunch1 Xmake "SRC=${SRC}" && make install 2>&1 >/dev/null Xif [ "X$?" != "X0" ] Xthen X echo "-> ERROR while building ../${TYPE}/crunch1..." X echo "-> Aborting $0" X exit 10 Xfi X Xcd ${pwd} X X(echo "-> Fixing permissions"; cd /mnt; chown -R root *) END-of-populate echo x - stage1 sed 's/^X//' >stage1 << 'END-of-stage1' X#!/bin/sh -x X X# X# $Id: stage1,v 1.7 1999/01/19 23:02:05 abial Exp $ X# X Xset -e Xecho ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel X Xif [ ! -f ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel ]; then X echo "-> ERROR: you must build PICOBSD${suffix}.${SIZE} first" X exit 1 Xfi X Xecho "-> Preparing kernel..." Xcp -p ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel kernel X#if [ "${TYPE}" != "dial" ] X#then X# echo "-> Preparing kvm database..." X# mv /var/db/kvm_kernel.db /var/db/old.db X# kvm_mkdb kernel X# cp /var/db/kvm_kernel.db kvm_kernel.db X# mv /var/db/old.db /var/db/kvm_kernel.db X#fi X Xecho "-> Preparing MFS filesystem..." Xumount /dev/vn0 2> /dev/null || true Xumount /mnt 2> /dev/null || true Xvnconfig -u /dev/rvn0 2> /dev/null || true X Xdd of=fs.PICOBSD if=/dev/zero count=${SIZE} bs=1k 2> /dev/null X X### --- removed papowell@astart.com X### This is not needed with 3.1 disklabel utility X#awk 'BEGIN {printf "%c%c", 85, 170}' | \ X# dd of=fs.PICOBSD obs=1 seek=510 conv=notrunc 2> /dev/null X X#vnconfig -c /dev/rvn0 fs.PICOBSD 2>/dev/null Xvnconfig -s labels -c /dev/rvn0 fs.PICOBSD 2>/dev/null X Xif [ "X$?" != "X0" ] Xthen X echo "-> Error while doing vnconfig of fs.PICOBSD on /dev/rvn0..." X echo " Most probably your running kernel doesn't have the vn(4) device." X echo "-> Aborting $0" X exit 10 Xfi X X### --- removed papowell@astart.com X### This is not needed with 3.1 disklabel utility X#dd if=/usr/mdec/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null X### *** dd writes boot record? X#dd if=/boot/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null X X### --- removed papowell@astart.com X### from --- to --- and replaced by 'disklabel vn0 auto' Xdisklabel -rw vn0 auto X X##--- This command does weird things on 2.2.x systems. In such case use normal X## disktype here instead X#if [ "${TYPE}" != "router" ] X#then X# disklabel -rw vn0 auto X#else X# if [ ${SIZE} -lt 1024 ] X# then X# disklabel -rw /dev/rvn0 fd${SIZE} X# else X# disklabel -rw vn0 auto X# fi X#fi X### --- X Xif [ "X$?" != "X0" ] Xthen X echo "-> Error while labeling fs.PICOBSD (vn0)..." X echo "-> Aborting $0" X exit 10 Xfi X X# Default setting for other (custom) setups. XINODES=4096 X# You can save some space on MFS if you don't want so many inodes... Xif [ -z "$INODES" ] ; then X case $TYPE in X * ) INODES=4096;; X router ) INODES=3072;; X esac Xfi X Xnewfs -i $INODES -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null Xmount /dev/vn0c /mnt Xif [ "X$?" != "X0" ] Xthen X echo "-> Error while mounting fs.PICOBSD (/dev/vn0c) on /mnt..." X echo "-> Aborting $0" X exit 10 Xfi END-of-stage1 echo x - stage2 sed 's/^X//' >stage2 << 'END-of-stage2' X#!/bin/sh -x X X# X# $Id: stage2,v 1.3 1999/01/14 23:14:46 abial Exp $ X# Xset -e X Xif [ ! -f kernel ]; then X echo "-> ERROR: you must build PICOBSD${suffix}.${SIZE} kernel first" X exit 1 Xfi X Xecho "-> Preparing kernel with MFS filesystem inside..." X X### display how much you have used Xdf -ik /mnt Xumount /mnt 2>&1 >/dev/null Xfsck -p /dev/rvn0c Xvnconfig -u /dev/rvn0 2>&1 >/dev/null X X# generate the write_mfs_in_kernel tool Xif [ ! -f ../tools/write_mfs_in_kernel/wmik ]; then X (cd ../tools/write_mfs_in_kernel; make) Xfi X X../tools/write_mfs_in_kernel/wmik kernel fs.PICOBSD Xstrip kernel Xstrip --remove-section=.note --remove-section=.comment kernel X X### compress the kernel Xgzip -9 -n -f kernel Xrm fs.PICOBSD END-of-stage2 echo x - stage3 sed 's/^X//' >stage3 << 'END-of-stage3' X#!/bin/sh -x X X# X# $Id: stage3,v 1.4 1999/01/14 23:14:46 abial Exp $ X# Xset -e X X. ../Version X Xif [ ! -f kernel.gz ]; then X echo "-> ERROR: you must build kernel.gz first" X exit 1 Xfi X Xecho "-> Preparing 1.44 floppy filesystem..." X### comments added papowell@astart.com Wed Apr 28 16:12:04 PDT 1999 X X### we make sure that the rvn0 system is available Xumount /dev/vn0 2> /dev/null || true Xumount /mnt 2> /dev/null || true Xvnconfig -u /dev/rvn0 2> /dev/null || true X X### now we make the file for the vnode file system Xdd of=picobsd.bin if=/dev/zero count=1440 bs=1k 2> /dev/null X X### --- removed papowell@astart.com X### this does not seem to be needed when using 3.1 disklabel utility X#awk 'BEGIN {printf "%c%c", 85, 170}' | \ X# dd of=picobsd.bin obs=1 seek=510 conv=notrunc 2> /dev/null X# vnconfig -s labels -c /dev/rvn0 picobsd.bin 2>/dev/null X X# we now configure the picobsd.bin file for use as the vnode file system Xvnconfig -c /dev/rvn0 picobsd.bin 2>/dev/null X X### -- removed papowell@astart.com X### the disklabel 'fd1440' should take care of this X### Note 1: FreeBSD 3.1-RELEASE does not use mdec X#dd if=/usr/mdec/boot1 of=picobsd.bin conv=notrunc 2> /dev/null X### the disklabel 'fd1440' should take care of this X#dd if=/boot/boot1 of=picobsd.bin conv=notrunc 2> /dev/null X X### -- updated papowell X### the disklabel with fd1440 will take care of the boot sectors X### and boot information X#disklabel -Brw -b /usr/mdec/fdboot -s /usr/mdec/bootfd /dev/rvn0 fd1440 2>&1 >/dev/null X X# we label the vnode file system as a floppy disk and install boot X# blocks Xdisklabel -Brw /dev/rvn0 fd1440 2>&1 >/dev/null X X### -- updated papowell@astart.co X### you may find that 32768 inodes is a little much, especially if you X### need every little bit of space X### newfs -i 32768 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null X X# now we do a newfs and mount the file as /mnt Xnewfs -i 4096 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null Xmount /dev/vn0c /mnt X X### sigh... this is ugly, but it works... Xpwd=`pwd` X X### --- added comments papowell@astart.com X### Note 1: these files are generated from the X### language dependent part of the tree. If the file X### is not there, then you get a nasty error and die X### We put a check for the file. Note that this allows X### us to put the rc.conf and rc.network files into a list X### Note 2: really, we ought to simply do: X### for i in ../lang/*.${LANGUAGE} X### and not worry about the language specific files X### Xcd ../${TYPE}/floppy.tree Xecho "-> Copying language dependent files..." Xfor i in hosts motd rc resolv.conf rc.conf Xdo X if [ -f ../lang/${i}.${LANGUAGE} ] ; then X cat ../lang/${i}.${LANGUAGE} | \ X sed -e "s/@VER@/${VER}/g" > \ X etc/${i} X fi; Xdone X X### --- removed, see above comments about tests X#if [ "${TYPE}" != "router" ] X#then X# cat ../lang/rc.conf.${LANGUAGE} | \ X# sed -e "s/@VER@/${VER}/g" > \ X# etc/rc.conf X# cat ../lang/rc.network.${LANGUAGE}| \ X# sed -e "s/@VER@/${VER}/g" > \ X# etc/rc.network X#fi X Xecho "-> Populating floppy filesystem..." X### -- this is tricky - you want to put in the boot.help file Xcat ../lang/boot.help.${LANGUAGE} | \ X sed -e "s/@VER@/${VER}/g" > \ X /mnt/boot.help X X### now you copy all the files in ${TYPE}/floppy.tree to /mnt Xcp -pr . /mnt Xrm -rf /mnt/CVS /mnt/etc/CVS /mnt/etc/ppp/CVS X X### this provides a prebuilt password file - but it takes space Xif [ "${TYPE}" = "dial" ] Xthen X pwd_mkdb -d etc/ etc/master.passwd X mv etc/spwd.db /mnt/etc/ X rm etc/pwd.db Xfi X X### we return to our original directory, and copy the kernel to the floppy image X### kernel Xcd ${pwd} Xcp kernel.gz /mnt/kernel.gz Xrm kernel.gz X X### now we add the boot loader - boot1 and boot2 were done by disklabel X### X### Here is the boot sequence: X### (boot0 on floppy sector 0/0/1) loaded into memory and executed X### boot1 finds UNIX partition, brings in boot2, starts execution of boot2 X### Boot1 usually does things using BIOS facilities X### Boot2 has quite a bit of the UNIX ufs file system, and can understand UFS X### file systems. X### boot2 will open /boot.config, read THE SINGLE LINE IN THE FILE, X### and interpret it as the name of a kernel and some options to pass X### to the kernel. X### The PICOBSD setup initializes boot.config with X### /boot/loader X### which tells boot2 to use the /boot/loader code as a kernel. X### X### What is this all about? The answer is simple: we want to be able to X### configure the devices by using the 3rd Stage Loader. But this X### loader is a little big, so we use the kzip (kernel zip) facility X### to compress it and attach a bit of code to decompress and then run X### the compressed code. X### X### The /boot/loader will now uncompress itself and will then read the X### (documented in the source code) file X### /boot/loader.rc X### This contains a list of commands that the loader understands. X### (Aside: /boot/loader.rc used to be /boot/boot.conf in earlier FreeBSD X### releases, and this name is is pretty close to boot.config (see above). X### I wonder how many people this has confused?) X### X### The /boot/loader.rc file contains the following commands: X### load /kernel X### load -t userconfig_script /kernel.config X### boot -P X### (see /usr/src/boot/common/help.common for list of commands) X### X### load /kernel loads /kernel into memory, and the boot -P X### line will boot it with the -P (use serial console if no keyboard) option. X### (see man boot for details of the flags) X### X### The load -t userconfig_script /kernel.config X### sets the kernel's 'userconfig_script' option value to X### "/kernel.config". The 'userconfig' module in the kernel X### (see /usr/src/sys/i386/i386/userconfig.c for the nasty details) X### will open and read this file, getting commands to set device X### configuration and other things. X### These commands can be: X### example X### di disable dev di de0 X### dr drq dev # dr 4 X### ei # EISA slots ei 4 X### en enable dev en ep0 X### ex exit (quit) ex X### f flags dev mask f de0 0xff X### h help X### intro intro screen X### iom iomem dev addr iom ed0 0xdf0000 X### ios iosize dev size iosize ed0 0x1000 X### ir irq dev # irq ed0 5 X### l ls, list l X### pn pnp ... pnp X### po port dev addr port ed0 0x300 X### res reset CPU res X### q quit q X### v visual mode v X### X### I strongly suspect that this has been included strictly as a Tour de Force X### example of how to make the loading as flexible as possible, etc, without X### needing to compile a special version of the boot code. X### X### Finally, after all this work, the kernel is loaded into memory, X### and kernel execution is started. Of course we have compressed the X### kernel, so it will promptly uncompress itself and start execution. X### X### The userconfig module is started, it reads the /kernel.config file, X### and then, since we have generated our kernel with the INTRO_USERCONFIG X### option, the kernel will go into VISUAL userconfig X### operation. X### X### To stop the loader from going into /kernel.config X### user interactive mode automatically, you need to modify the X### PICOBSD configuration file. Remove the X### options INTRO_USERCONFIG #imply -c and parse info area X### And regenerate the kernel. X### X### Suggested Alternatives X### X### Skipping the /boot/loader X### To do this, set /boot.config to contain only '-P' X### By default, you will get the kernel loaded. You should also X### compile the kernel without the INTRO_USERCONFIG option. X### X X# we make a compressed loader Xmkdir /mnt/boot Xcp /boot/loader . Xkzip -v loader Xmv loader.kz /mnt/boot/loader Xrm -f loader loader.o X X# set up the /boot.config file to cause boot2 to load /boot/loader Xecho "/boot/loader" >/mnt/boot.config X X# set up the /boot/loader.rc to cause the /boot/loader to X# load in the kernel and set options Xcat >/mnt/boot/loader.rc <<EOF Xload /kernel Xload -t userconfig_script /kernel.config Xboot -P XEOF X X( echo "-> Fixing permissions"; cd /mnt; chown -R root * ) X X### little bit of information for users Xdf -ik /mnt Xls -Rl /mnt X Xumount /mnt X# and we are finished Xvnconfig -u /dev/rvn0 END-of-stage3 exit To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-small" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904290528.WAA08070>