Subject: Crunch: a package to help build featureful install/fixit disks
To: None <tech-install@sun-lamp.cs.berkeley.edu>
From: James da Silva <jds@cs.UMD.EDU>
List: tech-install
Date: 01/28/1994 18:24:11
Here's the README for a little something I just hacked up for use here. I
hope it can be of some use to others.
We'll be working further here on install/release issues over the next
months, and I'm interested in making available anything that is of general
applicability to *BSD. Likewise, of course, I'm interested in hearing
about what others are doing in this area.
--------
CRUNCH 0.1 README 1/27/94
Crunch is available via anonymous ftp to ftp.cs.umd.edu in
pub/bsd/crunch-0.1.tar.gz
INTRODUCTION
Crunch is a little package (the tar.gz is 10 KB) that helps create
"crunched" binaries for use on boot, install, and fixit floppies. A
crunched binary in this case is one where many programs have been linked
together into one a.out file. The different programs are run depending on
the value of argv[0], so hard links to the crunched binary suffice to
simulate a perfectly normal system.
As an extreme example, I have created an 868K crunched "kitchen-sink"
binary containing the following programs in their entirety:
cat chmod cp date dd df echo ed expr hostname kill ln ls mkdir mt
mv pwd rcp rm rmdir sh sleep stty sync test [ badsect chown
clri disklabel dump dmesg fdisk fsck halt ifconfig init mknod mount
newfs ping reboot restore swapon umount rdump rrestore ftp rsh
telnet rlogin elvis vi cpio gzip sed tar gunzip gzcat
Note carefully: vi, cpio, tar, gzip, ed, sed, dump/restore, some networking
utilities, and the disk management utilities, all in a binary small enough
to fit on a 1.2 MB root filesystem floppy (albeit with the kernel on its
own boot floppy). A more reasonable subset can be made to fit easily with
a kernel for a decent one-disk fixit filesystem.
The linking together of different programs by hand is an old space-saving
technique. Crunch automates the process by taking advantage of two tricks.
First, it includes a little program that doctors the symbol tables of the
component .o files to allow them to link without "symbol multiply defined"
conflicts. Second, it takes good advantage of the nice uniform BSD makefile
scheme to automatically know what files to compile with what options for
each program, by .including the progam's original makefile.
While Crunch seems to be working fairly well for my initial tests, it
hasn't been stress-tested in the field (or by anyone other than me, in
fact), so this is definitely an Alpha release. I use it under a circa 1/94
NetBSD-current, but know of no reason why it won't work just as well under
FreeBSD or older NetBSDs (but see below for info on a linker bug).
Please let me know of any problems or of enhancements you make to this
package. I'm particularly interested in the details of what you found was
good to put on your fixit or install disks. Thanks!
I whipped up crunch for the Maruti Hard Real-Time Operating System project
at the University of Maryland, to help make for better install and recovery
procedures for our NetBSD-based development environment.
Crunch is Copyright by the University of Maryland under a UCB-style
freely-redistributable notice. See the file COPYRIGHT for details.
Share and Enjoy,
Jaime
............................................................................
: Stand on my shoulders, : jds@cs.umd.edu : James da Silva
: not on my toes. : uunet!mimsy!jds : Systems Design & Analysis Group
BUILDING CRUNCHED BINARIES
1. Run "make" in the crunch src directory to build the hidesyms
program.
2. Edit a crunch .conf file that describes the programs you want to include
in your crunched binary. Here is a simple .conf example (see
kitchen-sink.conf for a bigger example):
srcdirs /usr/src/bin /usr/src/sbin # where the sources are
progs test cp echo sh fsck halt init mount umount
ln test [ # hard links
ln sh -sh # (init calls sh this way)
libs -lutil -lcrypt # what to link with
3. Run gencrunch on your conffile:
$ ./gencrunch kitchen-sink.conf
4. Make the crunched binary in its subdirectory:
$ cd kitchen-sink
$ make
This should generate the binary "kitchen-sink", which can then be copied
onto a floppy. The programs within the crunched binary can be invoked
via hard links to the binary, or by invoking the crunched binary by its
own name, with the program to run as its arguments. For example:
$ ln kitchen-sink df
$ ./df -k .
[... normal df output ...]
$ ./kitchen-sink df -k .
[... the same df output ...]
A GNU LD BUG
Alas, crunch occasionally tickles a bug in the GNU linker's handling of
'-dc -r' for a very few programs. Paul Kranenburg <pk@cs.few.eur.nl>
supplied the following fix, which will be incorporated into his latest
linker (I believe), so should be in both netbsd-current and freebsd-current
by early February. Special thanks to Paul for his quick fix!
diff -c -r1.1 /usr/src/gnu/usr.bin/ld/ld.c
*** 1.1 1994/01/27 16:14:33
--- /usr/src/gnu/usr.bin/ld/ld.c 1994/01/27 16:26:32
***************
*** 2826,2832 ****
symtype = sp->defined & N_TYPE;
! if (!pic_code_seen && (force_common_definition ||
symtype == N_DATA ||
symtype == N_TEXT ||
symtype == N_ABS)) {
--- 2826,2832 ----
symtype = sp->defined & N_TYPE;
! if (!pic_code_seen && ( symtype == N_BSS ||
symtype == N_DATA ||
symtype == N_TEXT ||
symtype == N_ABS)) {
------------------------------------------------------------------------------