rtregn@immd3.informatik.uni-erlangen.de (Robert Regn) (12/15/88)
I have installed minix on various machines and think the procedure for that
is much too difficult and can only be done by a minix 'guru'. A big danger
is to destroy existing DOS or Xenix Filesystems by specifying a wrong
device (=partition) for mkfs.
I have now a shell script to automatisize the hard disk installation ready.
This is only a first approach. It should be named /.profile. Then it will
be executed on the first root login and all things run well if no errors
occur. It also customizes /etc/rc and /etc/shutdown (earlier posted with
shut.c, now included) and copies things to the ram image medium.
Creating a ram image on the disk is also supported.
It uses further the improved fdisk.c posted on 6. Dec (It isn't
tolerable to must recompile if the disk has more than 4 heads !)
The user must know:
number of heads
size of the extended memory (for an AT)
number of the partitions for minix
For the handling of bad sectors i have fixed dd (the original dies even with
the conv=noerror option) and badblocks (doesn't return 0 if all OK), cdiffs are included.
It would be nice if many people test this script on the next opportunity and
report problems or fix them.
---------------------------------------- cut here ---------------------------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: install shutdown dd.c.cdif badblocks.c.cdif
# Wrapped by rtregn@faui32 on Wed Dec 14 17:59:12 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'install' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'install'\"
else
echo shar: Extracting \"'install'\" \(9535 characters\)
sed "s/^X//" >'install' <<'END_OF_FILE'
X#
X# Minix installation script
X# Version 1.0 Author: Robert Regn
X# rtregn@faui32.uucp
X# rtregn@immd3.informatik.uni-erlangen.de
X# Fri Dec 16 MET 1988
X#
X# Copyright 1988,89 by Robert Regn, Germany. All rights reserved.
X# This code may be used for personal purposes.
X# It may be freely distributed providing this notice is kept intact.
X# No charge may be made other than resonable charges for reproduction.
X# It may not be sold for profit.
X# The author is not responsible for the consequences of use this software,
X# even if they arise from flaws in it.
X#
X#
X# Needs 10 KB stack in /bin/sh !!!!!
X# should named /.profile
X# ROOTIM is the partition from which the kernel loads the root filesystem
X# (depends on boot floppy )
X# PROTORAM is a prototype file for the root filesystem
X# PROFILE is the name of the original root profile
X# Work still to do: support of a second floppy drive, a second hard disk,
X# badblock handling (problem: dd dies even with noerror),
X# a program which recognizes the size of extended memory and the number
X# of heads, handling of various errors
X
XROOTIM=2
XPROTORAM=/usr/ast/proto.ram
XPROFILE=/.prof
XPATH=$PATH:/usr/ast/bin:/etc
Xtrap "echo installation aborted;exit" 2 3
Xif test -f /usr/tmp/config #after reboot
X then set `cat /usr/tmp/config`
X rm /usr/tmp/config
X n=$1
X root=$2
X else
X echo ' *********************************************************'
X echo ' * Minix hard disk installation procedure *'
X echo ' *********************************************************'
X# general check
X#
X echo
X echo -n checking disk ' '
X dd if=/dev/hd0 of=/dev/null bs=7k count=100 2>/tmp/dd.out
X if grep 'read error' /tmp/dd.out
X then
X echo read error on disk
X echo your disk is not compatible or you have wrong driver in kernel
X exit
X else echo OK
X fi
X echo Please enter number of heads of disk or 0 if partitions already exists
X read heads
X if test "$heads" = ""
X then heads=0
X fi
X if test $heads -ne 0
X then echo 'Please generate partition for minix (/usr) and'
X echo "optionally for root filesystem (position $ROOTIM preferred)"
X fdisk -$heads /dev/hd0
X fi
X echo which partition is created for minix - counted from the lowest cylinder
X echo warning - the number shown by fdisk is NOT necessaryly the partition number
X echo see doc/READ_ME
X echo Caution - wrong numbers will destroy data in other partitions
X read n
X echo is there a partition for the root image \?
X echo enter number or 0
X read root
X
X if test $root -eq $n
X then echo you cannot have the same partition for usr and root
X exit
X fi
X
X if test $heads -ne 0
X then
X# prepare reboot
X
X if test ! -d /usr/tmp
X then mkdir /usr/tmp
X fi
X echo $n $root $heads >/usr/tmp/config
X sync
X cp /usr/bin/login /bin
X umount /dev/fd0 2>/dev/null
X echo OK, now please reboot
X exit
X fi
Xfi
X
X#
X#safety checking - we don't want to destroy other filesystems on the disk
X#cooperation with the user necessary
Xfor i in $n $root
X do dd if=/dev/hd$i of=/tmp/f bs=512 count=1 2>/dev/null
X# check for dos
X od -x /tmp/f |head -1 >/tmp/fx
X if grep 'e[9b] ' /tmp/fx
X then echo CAUTION partition $i is probably DOS
X echo -n the OEM name would be: ' '
X dd if=/tmp/f bs=1 skip=3 count=8 2>/dev/null
X echo
X echo will you continue \?
X read ans
X if test $ans = n || test $ans = N
X then exit
X fi
X fi
X# problem: because of the alignment of the partitions to 1k blocks
X# is hd$i probably 512B to late ->
X# another check for dos : search boot files in the root directory
X# translate the attribute code for dir into newline
X# fgrep don't work otherwise
X if dd if=/dev/hd$i bs=1k count=65 2>/dev/null | tr '\21' '\12' | fgrep 'IBMDOS COM'
X then echo CAUTION partition $i is probably DOS
X echo will you continue \?
X read ans
X if test $ans = n || test $ans = N
X then exit
X fi
X fi
X
X# check for Xenix - grep can't this
X if fgrep 'boot0: error' /tmp/f
X then echo CAUTION partition $i is probably Xenix
X echo will you continue \?
X read ans
X if test $ans = n || test $ans = N
X then exit
X fi
X fi
X
Xdone
X
X# badblock handling
X
Xecho checking partition $n - may take several minutes
Xdd if=/dev/hd$n of=/dev/null bs=1k 2>/tmp/dd.out
Xif grep 'read error' /tmp/dd.out
X then echo partition $n has bad blocks
X echo want you nevertheless use this partition \?
X read ans
X if test "$ans" = n
X then exit
X fi
X# recheck partition and list errors
X echo checking partition $n again - may take several minutes
X dd if=/dev/hd$n of=/dev/null bs=1k conv=noerror 2>/tmp/dd.err
X# last two lines are size
X tail -2 /tmp/dd.err >/tmp/dd.out
X grep 'records' /tmp/dd.err |sed 's/+.*//' |uniq >/tmp/errors
X set `wc -l /tmp/errors`
X err=`expr $1 - 1` # now remove size line and join lines
X head -$err /tmp/errors | tr '\12' ' ' >/tmp/err.line
X mv /tmp/err.line /tmp/errors
X echo there are $err bad blocks
X echo '' >>/tmp/errors #add \n
X rm /tmp/dd.err
X
X else echo ready
Xfi
X
Xsize=`head -1 /tmp/dd.out | sed 's/+.*//'`
Xecho partition is $size KB big
Xif test $size -le 1200
X then echo this is too small
X exit
Xfi
X
Xecho generate filesystem on partition $n
Xsleep 3 #if you want stop
X
Xif mkfs /dev/hd$n $size
X then echo generated
X else echo error - ask minix guru
X exit
Xfi
X
Xif test -f /tmp/errors
X then if badblocks /dev/hd$n </tmp/errors
X then :
X else echo could not mark bad blocks
X# no return 0 from badblocks yet
X# exit
X fi
X rm /tmp/errors
Xfi
X
X# set mount points
Xif test ! -d /mnt
X then mkdir /mnt
Xfi
X
Xif test ! -d /user
X then mkdir /user
Xfi
X
X# mount the hard disk
Xif mount /dev/hd$n /mnt
X then :
X else echo error in mounting hard disk - ask minix guru
X exit
Xfi
X# mkfs sets root of a filesystem to 777 !
Xchmod 755 /mnt
X
Xecho will you copy the files of the /usr floppy onto the disk \?
Xecho please do it except you have a complete backup to restore
X# At this stage of this script you must do it to avoid missing many cmds later
Xread ans
Xif test $ans = y
X then echo copy files - please wait
X cpdir -sm /usr /mnt
X sync
X# in else we must copy all necessary commands
X# e.g. ed mkfs test tar vol cpdir cpio proto.ram
X# (too much for /dev/ram )
X else
X for i in test echo getlf vol cpdir tar
X do if test ! -f /bin/$i
X then cp /usr/bin/$i /bin
X fi
X done
Xfi
X
X# change to hard disk
X
Xcp $PROTORAM /tmp/proto.ram
Xumount /dev/fd0
Xumount /dev/hd$n 2>/dev/null
Xmount /dev/hd$n /usr 2>/dev/null
Xecho remove /usr floppy
X
X# restore any files or backups
X
Xecho
Xecho now you should restore all files or backups
Xans=99
Xwhile test "$ans" != 0
X do echo you can use:
X# putting the next statement later gives a syntax error
X# echo ' disks with cpio format - type c'
X echo ' disks in tar format - type t'
X echo ' disks with minix filesystems - type m'
X echo if done, type 0
X read ans
X case $ans in
X [tc]*) echo enter the size of the volumes in KB
X read size;;
X esac
X case $ans in
X t*) vol -u $size /dev/at0 |tar x -;;
X m*) umount /dev/fd0 2>/dev/null
X echo what is the target directory for copying \?
X read dir
X if test "$dir" = ""
X then dir=/usr
X fi
X getlf "insert disk and hit return"
X mount /dev/fd0 /mnt
X cpdir -sm /mnt $dir
X umount /dev/fd0;;
X# later :
X c*) vol -u $size /dev/at0 |cpio -iBvdm;;
X esac
Xdone
X
X
X# install the root image
X
Xif test $root -ne 0
X then echo
X echo how big should be the root filesystem \?
X echo Caution - if you have root filesystem greater 255 KB,
X echo you must have an AT or 386 with extended memory with a size
X echo at least of the root filesystem
X echo -n size of the root partition is: "(wait) "
X dd if=/dev/hd$root of=/dev/null bs=1k 2>&1 |head -1 |sed 's/+.*//' >/tmp/dd.out
X cat /tmp/dd.out
X# the size of the rootfsys can be greater than the root partition !
X echo -n size of the root filesystem in KB "? "
X read size
X if test "$size" = ""
X then size=`cat /tmp/dd.out`
X echo take $size KB
X fi
X if test $size -gt 512
X then inodes=256
X elif test $size -gt 255
X then inodes=128
X else inodes=96
X fi
X
X
X
X# edit /tmp/proto.ram - insert size and inodes
X# <<- not supported
X ed - /tmp/proto.ram <<EOF
X 2s/.*/$size $inodes/
X w
X q
XEOF
X mkfs /dev/hd$root /tmp/proto.ram
X# copy root filesystem
X
X if mount /dev/hd$root /user
X then
X umount /dev/fd0 2>/dev/null
X getlf "insert root disk and hit return"
X mount /dev/fd0 /mnt -r 2>/dev/null
X echo copy root filesystem
X# errors about special files to null
X cpdir -sm /mnt /user 2>/dev/null
X umount /dev/fd0 2>/dev/null
X umount /dev/hd$root
X echo remove root disk
X
X if test $root -ne $ROOTIM
X then echo you must rebuild the filesystem process with RAM_IMAGE = 0x30$root
X echo this definition is in filesystem/main.c
X fi
X else echo error - no root image created
X fi
X else
X echo you need 2 disks for booting minix
Xfi
X
X# password
X#
Xecho
Xecho
Xecho please set a root password
Xpasswd root
X
X# mount root image medium to make changes permanent
Xif test $root -eq 0
X then umount /dev/fd0 2>/dev/null
X getlf "insert root disk and hit return"
X mount /dev/fd0 /mnt
X else mount /dev/hd$root /mnt 2>/dev/null
Xfi
Xcp /etc/passwd /mnt/etc/passwd
X
X# customize /etc/rc and shutdown
Xecho now i customize /etc/rc and shutdown
Xed - /mnt/etc/rc <<EOF
X /mount/s/[fh]d./hd$n
X w
X q
XEOF
Xed - /mnt/etc/shutdown <<EOF
X /USR/s,=.*,=/dev/hd$n
X /ROOT/s,=.*,=/dev/hd$root
X w
X q
XEOF
Xcp /mnt/etc/shutdown /etc # for first shut
Xmv /mnt/.profile /mnt/.install
Xmv /.profile /.install
X
X# install the original profiles
Xcp /$PROFILE /.profile
Xcp /$PROFILE /mnt/.profile
X
Xif test $root -eq 0
X then umount /dev/fd0
X echo remove root floppy
X else umount /dev/hd$root 2>/dev/null
Xfi
X
X# cleanup
Xrm -f /tmp/f /tmp/fx /tmp/dd.out
Xecho
Xecho ' ' INSTALLATION READY
Xecho
Xexit
X
END_OF_FILE
if test 9535 -ne `wc -c <'install'`; then
echo shar: \"'install'\" unpacked with wrong size!
fi
# end of 'install'
fi
if test -f 'shutdown' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'shutdown'\"
else
echo shar: Extracting \"'shutdown'\" \(382 characters\)
sed "s/^X//" >'shutdown' <<'END_OF_FILE'
XUSR=/dev/hd4
XROOT=/dev/hd2
Xsync
Xsync
X/etc/umount /dev/fd0 2>/dev/null
X/etc/umount /dev/fd1 2>/dev/null
X/etc/umount $ROOT 2>/dev/null
Xcp /usr/bin/echo /tmp
Xcp /usr/bin/true /tmp
Xcp /usr/bin/login /bin
Xif /etc/umount $USR
X then /tmp/echo ' ' NORMAL SYSTEM SHUTDOWN
X while /tmp/true
X do :
X done
X else /tmp/echo cannot umount hard disk -- please kill processes
X /tmp/echo type F9
Xfi
END_OF_FILE
if test 382 -ne `wc -c <'shutdown'`; then
echo shar: \"'shutdown'\" unpacked with wrong size!
fi
# end of 'shutdown'
fi
if test -f 'dd.c.cdif' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dd.c.cdif'\"
else
echo shar: Extracting \"'dd.c.cdif'\" \(440 characters\)
sed "s/^X//" >'dd.c.cdif' <<'END_OF_FILE'
X*** minix/1.3/a.fertig/commands/dd.c Tue Oct 4 12:43:04 1988
X--- /tmp/rr/dd.c Tue Dec 13 15:22:09 1988
X***************
X*** 264,270 ****
X ibc = 0;
X for (i = 0; i < ibs; i++)
X if (ibuf[i] != 0)
X! ibs = i;
X statistics();
X }
X if ((ibc == 0) && (--files <= 0)) {
X--- 264,270 ----
X ibc = 0;
X for (i = 0; i < ibs; i++)
X if (ibuf[i] != 0)
X! ibc = i;
X statistics();
X }
X if ((ibc == 0) && (--files <= 0)) {
END_OF_FILE
if test 440 -ne `wc -c <'dd.c.cdif'`; then
echo shar: \"'dd.c.cdif'\" unpacked with wrong size!
fi
# end of 'dd.c.cdif'
fi
if test -f 'badblocks.c.cdif' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'badblocks.c.cdif'\"
else
echo shar: Extracting \"'badblocks.c.cdif'\" \(774 characters\)
sed "s/^X//" >'badblocks.c.cdif' <<'END_OF_FILE'
X*** 1.3/a.fertig/commands/badblocks.c Tue Oct 4 12:58:48 1988
X--- badblocks.c Tue Dec 13 17:06:13 1988
X***************
X*** 364,370 ****
X
X modify(cnt);
X close(fd); /* free device */
X! done(FILE_EXISTS);
X }
X
X modify(nr_blocks)
X--- 364,370 ----
X
X modify(cnt);
X close(fd); /* free device */
X! done(SUCCESS);
X }
X
X modify(nr_blocks)
X***************
X*** 591,598 ****
X int nr;
X {
X switch(nr) {
X- case FILE_EXISTS: unlink(file_name);
X case SUCCESS:
X case DEV_MOUNTED: umount(dev_name);
X case DIR_CREATED: unlink(dir_name);
X case HARMLESS: ;
X--- 591,598 ----
X int nr;
X {
X switch(nr) {
X case SUCCESS:
X+ case FILE_EXISTS: unlink(file_name);
X case DEV_MOUNTED: umount(dev_name);
X case DIR_CREATED: unlink(dir_name);
X case HARMLESS: ;
END_OF_FILE
if test 774 -ne `wc -c <'badblocks.c.cdif'`; then
echo shar: \"'badblocks.c.cdif'\" unpacked with wrong size!
fi
# end of 'badblocks.c.cdif'
fi
echo shar: End of shell archive.
exit 0
Robert Regn Germany
rtregn@faui32.uucp Tel: 09131 857913
rtregn@immd3.informatik.uni-erlangen.de