Date: Sun, 5 Oct 1997 20:05:44 +0200 (CEST) From: Martin Kammerhofer <dada@sbox.tu-graz.ac.at> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: docs/4698: Handbook's script for making repair floppy doesn't work Message-ID: <199710051805.UAA01774@lend.tu-graz.ac.at> Resent-Message-ID: <199710051900.MAA04455@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 4698 >Category: docs >Synopsis: Handbook's script for making repair floppy doesn't work >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Sun Oct 5 12:00:01 PDT 1997 >Last-Modified: >Originator: Martin Kammerhofer >Organization: Graz University of Technology >Release: FreeBSD 2.2.2-RELEASE i386 >Environment: >Description: In handbook/hw.sgml "10.5.9.5. Emergency Restore Procedure" is a shell-script given, which demonstrates how to create a repair floppy if the standard boot/fixit floppys cannot be used. (Due to a non-GENERIC harddisk configuration). I tried this script with 2.2.2 and it fails, because the floppy is full before everything gets copied to it. >How-To-Repeat: Copy the script from /usr/src/share/doc/handbook/hw.sgml and run it. (You have to build a MINI kernel in order to do that). >Fix: I modified it a bit, compressing the kernel now with kzip(1) to have enough space on the floppy an clearing up a few other things. It is tested (w/o actually restoring data) and works quite well under 2.2.2. Re-check and replace/modify that script in hw.sgml. Try booting the floppy it creates. ===== CUT HERE ===== CUT HERE ===== CUT HERE ===== CUT HERE ===== #! /bin/sh # # create a restore floppy # # formats the floppy without asking questions # PATH=/bin:/sbin:/usr/sbin:/usr/bin KERNEL=${1:-"MINI"} FLP=${2:-"fd0"} # # exit on errors # set -e [ -d /sys ] || ln -s /usr/src/sys / # # check for kernel # if [ ! -x /sys/compile/${KERNEL}/kernel ] then cat << EOM The ${KERNEL} kernel does not exist, please create one. Here is an example config file: #++++++++++++++++++ cut here please ++++++++++++++++++++++++++ # # ${KERNEL} -- A minimum kernel to get FreeBSD onto a floppy. # # This is for three SCSI disks (NCR contr.) and two IDE disks (on 1st contr.). # machine "i386" cpu "I486_CPU" ident ${KERNEL} maxusers 5 options INET # needed for _tcp _icmpstat _ipstat # _udpstat _tcpstat _udb options FFS #Berkeley Fast File System options FAT_CURSOR #block cursor in syscons or pccons options SCSI_DELAY=15 #Be pessimistic about Joe SCSI device options NCONS=4 #4 virtual consoles options USERCONFIG #Allow user configuration with -c XXX config kernel root on sd0 swap on sd0 and sd1 dumps on sd0 controller isa0 controller pci0 controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr disk fd0 at fdc0 drive 0 device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr device npx0 at isa? port "IO_NPX" irq 13 vector npxintr # SCSI section controller ncr0 controller scbus0 device sd0 device sd1 device sd2 device st0 # IDE section controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr device wd0 device wd1 # end of IDE section pseudo-device loop # required by INET pseudo-device gzip # Exec gzipped a.out's #++++++++++++++++++ cut here please ++++++++++++++++++++++++++ EOM exit 1 fi umount -v /dev/${FLP}a 2>/dev/null && \ echo >&2 "error: ${FLP} is mounted" && exit 2 || true echo -n "Formatting floppy..................................." fdformat -q ${FLP} && echo "done." && \ fdformat -v ${FLP} || { echo "Bad floppy, please use a new one!" exit 1 } # place boot blocks on the floppy # echo "Writing bootblocks." disklabel -w -B -b /usr/mdec/fdboot -s /usr/mdec/bootfd /dev/r${FLP}c fd1440 # # newfs the one and only partition # echo "Making filesystem." newfs -t 2 -u 18 -l 1 -c 40 -i 5120 -m 0 -o space /dev/r${FLP}a # # mount the new floppy # echo "Mounting floppy." mount -v /dev/${FLP}a /mnt trap "df -ki /mnt; echo Unmounting floppy.; umount -v /mnt" 0 2 # on exit/intr. # # create required directories # mtree -e -f /etc/mtree/BSD.root.dist -p /mnt -U >/dev/null # # populate the directories # echo "Compressing kernel." kzip /sys/compile/${KERNEL}/kernel # compress kernel echo "Populating filesystem." cp /sys/compile/${KERNEL}/kernel.kz /mnt/kernel [ -r /sys/i386/conf/${KERNEL} ] && cp /sys/i386/conf/${KERNEL} /mnt gzip -c -best /sbin/init > /mnt/sbin/init gzip -c -best /sbin/fsck > /mnt/sbin/fsck gzip -c -best /sbin/mount > /mnt/sbin/mount gzip -c -best /sbin/halt > /mnt/sbin/halt gzip -c -best /sbin/restore > /mnt/sbin/restore gzip -c -best /bin/sh > /mnt/bin/sh ln /mnt/bin/sh /mnt/bin/-sh gzip -c -best /bin/sync > /mnt/bin/sync cp /root/.profile /mnt/root # MAKEDEV would require "sh test expr mknod chown rm..." to work! # so it's of no use on floppy ln -sf /dev/MAKEDEV /mnt/dev (cd /mnt/dev && /dev/MAKEDEV fd0 vty4 std st0 sd0 sd1 sd2 wd0 wd1) rm -f /mnt/dev/MAKEDEV /mnt/dev/fd/?? # save some inodes chmod 500 /mnt/sbin/init chmod 555 /mnt/sbin/fsck /mnt/sbin/mount /mnt/sbin/halt chmod 555 /mnt/bin/sh /mnt/bin/sync chmod 6555 /mnt/sbin/restore tr '@' '\0' >/mnt/bin/tcat <<'EOM' #! /bin/sh # tcat - a simple cat for textfiles only, simulated with sh(1) # won't echo incomplete lines (with missing newline) for f in $*; do IFS='@'; # there's an ascii NUL here between the apostrophes! exec < $f && while read line; do echo $line done done EOM chmod 555 /mnt/bin/tcat # # create minimum filesystem table # cat > /mnt/etc/fstab <<EOM /dev/fd0a / ufs rw 1 1 EOM # # create minimum profile # cat > /mnt/etc/profile <<EOM set -E PATH=/bin:/usr/bin:/sbin:/usr/sbin:/mnt/bin:/mnt/sbin:/mnt/usr/bin:/mnt/usr/sbin export PATH EOM exit 0 ===== CUT HERE ===== CUT HERE ===== CUT HERE ===== CUT HERE ===== Some additional notes: /etc/[master.]passwd and [s]pwd.db are not really required, single user booting (as stated in hw.sgml) is also not required. Since this floppy has a very limited command set (until something else is mounted into your path) I have added a 'tcat' command, to look at textfiles. With this and 'echo *' as a 'ls' replacement one doesn't feel completely blind in such an extremely stripped down environment. BTW, I'm aware that this kind of bootfloppy creation is suboptimal. I have made bootfloppies with crunched binaries and a MFS root-fs (like install floppy, only better) but - of course - that's too complex for the handbook and rarely needed. (Dynamic linking would be another option, only libc is rather big). >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710051805.UAA01774>