There are only four steps that you need to perform in preparation for any disaster that may occur.
First, print the disklabel from each of your disks
(e.g. disklabel sd0 | lpr
), your filesystem table
(/etc/fstab
) and all boot messages, two copies of each.
Second, determine that the boot and fixit floppies (boot.flp and fixit.flp) have all your devices. The easiest way to check is to reboot your machine with the boot floppy in the floppy drive and check the boot messages. If all your devices are listed and functional, skip on to step three.
Otherwise, you have to create two custom bootable
floppies which has a kernel that can mount your all of your disks
and access your tape drive. These floppies must contain:
fdisk(8)
, disklabel(8)
, newfs(8)
,
mount(8)
, and whichever backup program you use. These
programs must be statically linked. If you use dump(8)
,
the floppy must contain restore(8)
.
Third, create backup tapes regularly. Any changes that you make after your last backup may be irretrievably lost. Write-protect the backup tapes.
Fourth, test the floppies (either boot.flp and
fixit.flp or the two custom bootable floppies you made in step
two.) and backup tapes. Make notes of the procedure. Store
these notes with the bootable floppy, the printouts and the
backup tapes. You will be so distraught when restoring that the
notes may prevent you from destroying your backup tapes (How? In
place of tar xvf /dev/rst0
, you might accidently type
tar cvf /dev/rst0
and over-write your backup tape).
For an added measure of security, make bootable floppies and two backup tapes each time. Store one of each at a remote location. A remote location is NOT the basement of the same office building. A number of firms in the World Trade Center learned this lesson the hard way. A remote location should be physically separated from your computers and disk drives by a significant distance.
An example script for creating a bootable floppy:
#!/bin/sh
#
# create a restore floppy
#
# format the floppy
#
PATH=/bin:/sbin:/usr/sbin:/usr/bin
fdformat -q fd0
if [ $? -ne 0 ]
then
echo "Bad floppy, please use a new one"
exit 1
fi
# place boot blocks on the floppy
#
disklabel -w -B -b /usr/mdec/fdboot -s /usr/mdec/bootfd /dev/rfd0c fd1440
#
# newfs the one and only partition
#
newfs -t 2 -u 18 -l 1 -c 40 -i 5120 -m 5 -o space /dev/rfd0a
#
# mount the new floppy
#
mount /dev/fd0a /mnt
#
# create required directories
#
mkdir /mnt/dev
mkdir /mnt/bin
mkdir /mnt/sbin
mkdir /mnt/etc
mkdir /mnt/root
mkdir /mnt/mnt # for the root partition
mkdir /mnt/tmp
mkdir /mnt/var
#
# populate the directories
#
if [ ! -x /sys/compile/MINI/kernel ]
then
cat << EOM
The MINI kernel does not exist, please create one.
Here is an example config file:
#
# MINI -- A kernel to get FreeBSD on onto a disk.
#
machine "i386"
cpu "I486_CPU"
ident MINI
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=2 #1 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
controller ncr0
controller scbus0
device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr
device npx0 at isa? port "IO_NPX" irq 13 vector npxintr
device sd0
device sd1
device sd2
device st0
pseudo-device loop # required by INET
pseudo-device gzip # Exec gzipped a.out's
EOM
exit 1
fi
cp -f /sys/compile/MINI/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
gzip -c -best /bin/sync > /mnt/bin/sync
cp /root/.profile /mnt/root
cp -f /dev/MAKEDEV /mnt/dev
chmod 755 /mnt/dev/MAKEDEV
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
#
# create the devices nodes
#
cd /mnt/dev
./MAKEDEV std
./MAKEDEV sd0
./MAKEDEV sd1
./MAKEDEV sd2
./MAKEDEV st0
./MAKEDEV pty0
cd /
#
# create minimum filesystem table
#
cat > /mnt/etc/fstab <<EOM
/dev/fd0a / ufs rw 1 1
EOM
#
# create minimum passwd file
#
cat > /mnt/etc/passwd <<EOM
root:*:0:0:Charlie &:/root:/bin/sh
EOM
cat > /mnt/etc/master.passwd <<EOM
root::0:0::0:0:Charlie &:/root:/bin/sh
EOM
chmod 600 /mnt/etc/master.passwd
chmod 644 /mnt/etc/passwd
/usr/sbin/pwd_mkdb -d/mnt/etc /mnt/etc/master.passwd
#
# umount the floppy and inform the user
#
/sbin/umount /mnt
The key question is: did your hardware survive? You have been doing regular backups so there is no need to worry about the software.
If the hardware has been damaged. First, replace those parts that have been damaged.
If your hardware is okay, check your floppies. If you are using a custom boot floppy, boot single-user (type "-s" at the "boot:" prompt). Skip the following paragraph.
If you are using the boot.flp and fixit.flp floppies,
keep reading. Insert the boot.flp floppy in the first floppy drive
and boot the computer. The original install menu will be displayed
on the screen. Select the "Fixit--Repair mode with CDROM or floppy."
option. Insert the fixit.flp when prompted. restore
and
the other programs that you need are located in /mnt2/stand
.
Recover each filesystem separately.
Try to mount(8) (e.g. mount /dev/sd0a /mnt)
the root partition of your first disk. If the disklabel was
damaged, use disklabel(8)
to re-partition and label the
disk to match the label that your printed and saved. Use
newfs(8)
to re-create the filesystems. Re-mount the
root partition of the floppy read-write ("mount -u -o rw
/mnt
"). Use your backup program and backup tapes to recover
the data for this filesystem (e.g. restore vrf
/dev/st0
). Unmount the filesystem (e.g. umount
/mnt
) Repeat for each filesystem that was damaged.
Once your system is running, backup your data onto new tapes. Whatever caused the crash or data loss may strike again. An another hour spent now, may save you from further distress later.