2005-07-13 15:04:56 +02:00
#!/bin/sh
#
2005-08-12 13:08:23 +02:00
# setup 4.1 - install a MINIX distribution
#
# Changes:
# Aug 2005 robustness checks and beautifications (Jorrit N. Herder)
# Jul 2005 extended with autopart and networking (Ben J. Gras)
# Dec 20, 1994 created (Kees J. Bot)
#
2005-07-13 15:04:56 +02:00
2005-08-05 18:49:38 +02:00
LOCALRC = /usr/etc/rc.local
2005-07-13 15:04:56 +02:00
PATH = /bin:/usr/bin
export PATH
2005-08-12 13:08:23 +02:00
2005-07-13 15:04:56 +02:00
usage( )
{
cat >& 2 <<'EOF'
Usage: setup # Install a skeleton system on the hard disk.
setup /usr # Install the rest of the system (binaries or sources).
# To install from other things then floppies:
urlget http://... | setup /usr # Read from a web site.
urlget ftp://... | setup /usr # Read from an FTP site.
mtools copy c0d0p0:... - | setup /usr # Read from the C: drive.
dosread c0d0p0 ... | setup /usr # Likewise if no mtools.
EOF
exit 1
}
2005-08-12 13:08:23 +02:00
warn( )
{
echo -e " \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ! $1 "
}
2005-07-13 15:04:56 +02:00
# No options.
while getopts '' opt; do usage; done
shift ` expr $OPTIND - 1`
2005-07-13 16:59:43 +02:00
if [ " $USER " != root ]
2005-07-26 15:14:59 +02:00
then echo "Please run setup as root."
2005-07-13 16:59:43 +02:00
exit 1
fi
2005-07-13 15:04:56 +02:00
2005-08-08 16:28:32 +02:00
# Installing MINIX on the hard disk.
2005-07-13 15:04:56 +02:00
case " $0 " in
/tmp/*)
rm -f " $0 "
; ;
*) cp -p " $0 " /tmp/setup
exec /tmp/setup
esac
# Find out what we are running from.
exec 9<& 0 </etc/mtab # Mounted file table.
read thisroot rest # Current root (/dev/ram or /dev/fd?)
read fdusr rest # USR (/dev/fd? or /dev/fd?p2)
exec 0<& 9 9<& -
# What do we know about ROOT?
case $thisroot :$fdusr in
/dev/ram:/dev/fd0p2) fdroot = /dev/fd0 # Combined ROOT+USR in drive 0
; ;
/dev/ram:/dev/fd1p2) fdroot = /dev/fd1 # Combined ROOT+USR in drive 1
; ;
/dev/ram:/dev/fd*) fdroot = unknown # ROOT is some other floppy
; ;
/dev/fd*:/dev/fd*) fdroot = $thisroot # ROOT is mounted directly
; ;
*) fdroot = $thisroot # ?
esac
2005-08-11 15:12:55 +02:00
echo -n "
2005-08-12 13:08:23 +02:00
Welcome to the MINIX setup script. This script will guide you in setting up
MINIX on your machine. Please consult the manual for detailed instructions.
2005-07-13 15:04:56 +02:00
2005-08-09 13:16:15 +02:00
Note 1: If the screen blanks, hit CTRL+F3 to select \" software scrolling\" .
2005-08-12 13:08:23 +02:00
Note 2: If things go wrong then hit CTRL+C to abort and start over.
2005-08-11 15:12:55 +02:00
Note 3: Default answers, like [ y] , can simply be chosen by hitting ENTER.
2005-08-08 16:28:32 +02:00
Note 4: If you see a colon ( :) then you should hit ENTER to continue .
2005-07-13 15:04:56 +02:00
:"
read ret
2005-08-12 13:08:23 +02:00
# begin Step 1
2005-08-11 15:12:55 +02:00
echo ""
echo " --- Step 1: Select keyboard type --------------------------------------"
echo ""
2005-07-13 15:04:56 +02:00
2005-08-12 13:08:23 +02:00
echo "What type of keyboard do you have? You can choose one of:"
echo ""
ls -C /usr/lib/keymaps | sed -e 's/\.map//g' -e 's/^/ /'
echo ""
step1 = ""
while [ " $step1 " != ok ]
do
echo -n "Keyboard type? [us-std] " ; read keymap
test -n " $keymap " || keymap = us-std
if loadkeys " /usr/lib/keymaps/ $keymap .map " 2>/dev/null
then step1 = ok
else warn "invalid keyboard"
fi
done
# end Step 1
# begin Step 2
step2 = ""
while [ " $step2 " != ok ]
2005-08-02 10:57:26 +02:00
do
2005-08-11 15:12:55 +02:00
echo ""
echo " --- Step 2: Create a partition for MINIX 3 ----------------------------"
echo ""
2005-08-12 13:08:23 +02:00
echo "Now you need to create a MINIX 3 partition on your hard disk."
echo "Unless you are an expert, you are advised to use the automated"
echo "step-by-step help in setting up."
echo ""
ok = ""
while [ " $ok " = "" ]
do
echo -n "Press ENTER for automatic mode or type 'expert': "
read mode
if [ -z " $mode " ] ; then auto = "1" ; ok = "yes" ; fi
if [ " $mode " = expert ] ; then auto = "" ; ok = "yes" ; fi
if [ " $ok " != yes ] ; then warn "try again" ; fi
done
2005-07-13 16:59:43 +02:00
primary =
if [ -z " $auto " ]
then
# Expert mode
2005-07-13 15:04:56 +02:00
echo -n "
2005-08-09 13:16:15 +02:00
MINIX needs one primary partition of about 250 MB for a full install.
2005-08-09 18:46:46 +02:00
The maximum fill system currently supported is 4 GB.
2005-07-13 15:04:56 +02:00
2005-08-09 13:16:15 +02:00
If there is no free space on your disk then you have to choose an option:
( 1) Delete one or more partitions
( 2) Allocate an existing partition to MINIX 3
( 3) Exit setup and shrink a partition using a different OS
2005-07-13 15:04:56 +02:00
To make this partition you will be put in the editor \" part\" . Follow the
advice under the '!' key to make a new partition of type MINIX. Do not
touch an existing partition unless you know precisely what you are doing!
Please note the name of the partition ( e.g. c0d0p1, c0d1p3, c1d1p0) you
2005-08-08 16:28:32 +02:00
make. ( See the devices section in usage( 8) on MINIX device names.)
2005-07-13 15:04:56 +02:00
:"
2005-07-13 16:59:43 +02:00
read ret
2005-07-13 15:04:56 +02:00
2005-07-13 16:59:43 +02:00
while [ -z " $primary " ]
do
part || exit
2005-07-13 15:04:56 +02:00
2005-07-13 16:59:43 +02:00
echo -n "
2005-07-13 15:04:56 +02:00
Please finish the name of the primary partition you have created:
2005-08-08 16:28:32 +02:00
( Just type ENTER if you want to rerun \" part\" ) /dev/"
2005-07-13 16:59:43 +02:00
read primary
2005-08-12 13:08:23 +02:00
done
2005-08-11 15:12:55 +02:00
echo ""
echo "This is the point of no return. You have selected to install MINIX"
echo " on partition /dev/ $primary . Please confirm that you want to use this "
echo "selection to install MINIX."
echo ""
2005-08-12 13:08:23 +02:00
confirmation = ""
while [ -z " $confirmation " -o " $confirmation " != yes -a " $confirmation " != no ]
do
echo -n "Are you sure you want to continue? Please enter 'yes' or 'no': "
read confirmation
if [ " $confirmation " = yes ] ; then step2 = ok; fi
2005-08-11 15:12:55 +02:00
done
2005-08-12 13:08:23 +02:00
2005-07-13 16:59:43 +02:00
else
# Automatic mode
2005-08-12 13:08:23 +02:00
# while [ -z "$primary" ]
# do
2005-07-13 16:59:43 +02:00
PF = "/tmp/pf"
if autopart -f$PF
then if [ -s " $PF " ]
then
bd = " `cat $PF ` "
2005-07-24 03:16:37 +02:00
if [ -b " /dev/ $bd " ]
2005-07-13 16:59:43 +02:00
then primary = " $bd "
else echo " Funny device $bd from autopart. "
fi
else
echo "Didn't find output from autopart."
fi
else echo "Autopart tool failed. Trying again."
fi
2005-08-09 18:46:46 +02:00
# reset at retries and timeouts in case autopart left
# them messy
atnormalize
2005-08-12 13:08:23 +02:00
# done
if [ -n " $primary " ] ; then step2 = ok; fi
2005-07-13 16:59:43 +02:00
fi
2005-07-13 15:04:56 +02:00
2005-08-12 13:08:23 +02:00
done
# end Step 2
2005-07-13 15:04:56 +02:00
root = ${ primary } s0
swap = ${ primary } s1
usr = ${ primary } s2
hex2int( )
{
# Translate hexadecimal to integer.
local h d i
h = $1
i = 0
while [ -n " $h " ]
do
d = $( expr $h : '\(.\)' )
h = $( expr $h : '.\(.*\)' )
d = $( expr \( 0123456789ABCDEF : " .* $d " \) - 1)
i = $( expr $i \* 16 + $d )
done
echo $i
}
2005-08-12 13:08:23 +02:00
# begin Step 3
2005-07-13 15:04:56 +02:00
echo ""
2005-08-11 15:12:55 +02:00
echo " --- Step 3: Select your Ethernet chip ---------------------------------"
echo ""
# Ask user about networking
2005-08-08 16:28:32 +02:00
echo "MINIX currently supports the following Ethernet cards. Please choose: "
2005-08-12 13:08:23 +02:00
echo ""
echo "0. No Ethernet card (no networking)"
echo "1. Intel Pro/100"
echo "2. Realtek 8139 based card"
echo "3. Realtek 8029 based card (emulated by Qemu)"
echo "4. NE2000, 3com 503 or WD based card (emulated by Bochs)"
echo "5. 3Com 501 or 3Com 509 based card"
echo "6. Different Ethernet card (no networking)"
echo ""
echo "You can always change your mind after the setup."
echo ""
step3 = ""
while [ " $step3 " != ok ]
do
eth = ""
echo -n "Ethernet card? [0] " ; read eth
test -z $eth && eth = 0
driver = ""
driverargs = ""
case " $eth " in
0) step3 = "ok" ; ; ;
1) step3 = "ok" ; driver = fxp; ; ;
2) step3 = "ok" ; driver = rtl8139; ; ;
3) step3 = "ok" ; driver = dp8390; driverargs = "dp8390_arg='DPETH0=pci'" ; ; ;
4) step3 = "ok" ; driver = dp8390; driverargs = "dp8390_arg='DPETH0=240:9'" ;
echo ""
echo " Note: After installing, edit $LOCALRC to the right configuration. "
echo " chose option 4, the defaults for emulation by Bochs have been set."
2005-08-09 18:46:46 +02:00
; ;
2005-08-12 13:08:23 +02:00
5) step3 = "ok" ; driver = dpeth; driverargs = "#dpeth_arg='DPETH0=port:irq:memory'" ;
echo ""
echo " Note: After installing, edit $LOCALRC to the right configuration. "
2005-08-09 18:46:46 +02:00
; ;
2005-08-12 13:08:23 +02:00
6) step3 = "ok" ; ; ;
*) warn "choose a number"
esac
done
# end Step 3
2005-07-13 15:04:56 +02:00
2005-08-08 16:28:32 +02:00
# Compute the amount of memory available to MINIX.
2005-07-13 15:04:56 +02:00
memsize = 0
ifs = " $IFS "
IFS = ','
set -- $( sysenv memory)
IFS = " $ifs "
for mem
do
mem = $( expr $mem : '.*:\(.*\)' )
memsize = $( expr $memsize + $( hex2int $mem ) / 1024)
done
# Compute an advised swap size.
2005-08-12 13:08:23 +02:00
# swapadv=0
# case `arch` in
# i86)
# test $memsize -lt 4096 && swapadv=$(expr 4096 - $memsize)
# ;;
# *) test $memsize -lt 6144 && swapadv=$(expr 6144 - $memsize)
# esac
2005-07-13 15:04:56 +02:00
2005-08-10 17:14:14 +02:00
blockdefault = 4
2005-08-09 13:16:15 +02:00
2005-08-11 15:12:55 +02:00
echo ""
echo " --- Step 4: Select a block size ---------------------------------------"
echo ""
echo " The maximum (and default) file system block size is $blockdefault KB. "
echo "For a small disk or small RAM you may want 1 or 2 KB blocks."
echo ""
2005-07-22 20:30:40 +02:00
while [ -z " $blocksize " ]
2005-08-12 13:08:23 +02:00
do
echo -n " Block size in kilobytes? [ $blockdefault ] " ; read blocksize
test -z " $blocksize " && blocksize = $blockdefault
2005-08-10 17:14:14 +02:00
if [ " $blocksize " -ne 1 -a " $blocksize " -ne 2 -a " $blocksize " -ne $blockdefault ]
2005-08-12 13:08:23 +02:00
then
warn "1, 2 or 4 please"
2005-07-22 20:30:40 +02:00
blocksize = ""
fi
done
2005-07-24 03:16:37 +02:00
blocksizebytes = " `expr $blocksize '*' 1024` "
2005-08-11 15:12:55 +02:00
2005-07-22 20:30:40 +02:00
2005-08-12 13:08:23 +02:00
# begin Step 5
# echo ""
# echo " --- Step 5: Allocate swap space ---------------------------------------"
# echo ""
2005-08-08 16:28:32 +02:00
2005-08-12 13:08:23 +02:00
# echo -n "How much swap space would you like? Swapspace is only needed if this
# system is memory starved. If you have 128 MB of memory or more, you
# probably don't need it. If you have less and want to run many programs
# at once, I suggest setting it to the memory size.
2005-07-13 15:04:56 +02:00
2005-08-12 13:08:23 +02:00
# Size in kilobytes? [$swapadv] "
# read swapsize
# test -z "$swapsize" && swapsize=$swapadv
#
2005-08-09 13:16:15 +02:00
2005-08-11 15:12:55 +02:00
echo "
You have selected to install MINIX in the partition /dev/$primary .
2005-08-12 13:42:57 +02:00
The following subpartitions are now being created on /dev/$primary :
2005-07-13 15:04:56 +02:00
2005-08-11 15:12:55 +02:00
Root subpartition: /dev/$root 16 MB
2005-07-13 15:04:56 +02:00
/usr subpartition: /dev/$usr rest of $primary
2005-08-11 15:12:55 +02:00
"
2005-07-13 15:04:56 +02:00
# Secondary master bootstrap.
installboot -m /dev/$primary /usr/mdec/masterboot >/dev/null || exit
# Partition the primary.
p3 = 0:0
2005-08-12 13:08:23 +02:00
# test "$swapsize" -gt 0 && p3=81:`expr $swapsize \* 2`
2005-08-11 15:12:55 +02:00
partition /dev/$primary 1 81:32768* $p3 81:0+ > /dev/null || exit
2005-08-12 13:42:57 +02:00
mkfs -B $blocksizebytes /dev/$root || exit
mkfs -B $blocksizebytes /dev/$usr || exit
2005-07-13 15:04:56 +02:00
2005-08-12 13:08:23 +02:00
# if [ "$swapsize" -gt 0 ]
# then
# # We must have that swap, now!
# mkswap -f /dev/$swap || exit
# mount -s /dev/$swap || exit
# else
# # Forget about swap.
# swap=
# fi
2005-08-08 11:24:02 +02:00
2005-08-12 13:42:57 +02:00
2005-08-11 15:12:55 +02:00
echo ""
2005-08-12 13:08:23 +02:00
echo " --- Step 5: Wait for bad block detection ------------------------------"
2005-08-11 15:12:55 +02:00
echo ""
2005-08-12 13:08:23 +02:00
echo "Scanning disk for bad blocks. Hit CTRL-C to stop the scan if you are"
echo "sure that there can not be any bad blocks. Otherwise just wait."
2005-07-13 15:04:56 +02:00
2005-08-12 13:08:23 +02:00
trap ': nothing;echo' 2
2005-08-11 15:12:55 +02:00
echo ""
2005-08-12 13:08:23 +02:00
echo " Scanning /dev/ $root for bad blocks: "
readall -b /dev/$root | sh
echo ""
echo " Scanning /dev/ $usr for bad blocks: "
2005-07-13 15:04:56 +02:00
readall -b /dev/$usr | sh
trap 2
2005-08-11 15:12:55 +02:00
echo ""
2005-08-12 13:08:23 +02:00
echo " --- Step 6: Wait for files to be copied -------------------------------"
2005-08-11 15:12:55 +02:00
echo ""
2005-08-12 13:42:57 +02:00
echo "This is the final step of the MINIX setup. All files will be now be"
echo "copied to your hard disk. This may take a while."
echo ""
2005-08-09 13:16:15 +02:00
2005-08-12 13:42:57 +02:00
mount /dev/$usr /mnt >/dev/null || exit # Mount the intended /usr.
2005-07-13 15:04:56 +02:00
2005-08-11 17:17:52 +02:00
files = "`find /usr | wc -l`"
cpdir -v /usr /mnt | progressbar " $files " || exit # Copy the usr floppy.
2005-07-13 15:04:56 +02:00
2005-08-12 13:42:57 +02:00
umount /dev/$usr >/dev/null || exit # Unmount the intended /usr.
umount $fdusr >/dev/null # Unmount the /usr floppy.
mount /dev/$usr /usr >/dev/null || exit # A new /usr
2005-07-13 15:04:56 +02:00
if [ $fdroot = unknown ]
then
echo "
By now the floppy USR has been copied to /dev/$usr , and it is now in use as
/usr. Please insert the installation ROOT floppy in a floppy drive."
drive =
while [ -z " $drive " ]
do
echo -n "What floppy drive is it in? [0] " ; read drive
case $drive in
'' ) drive = 0
; ;
[ 01] )
; ;
*) echo " It must be 0 or 1, not \" $drive \". "
drive =
esac
done
fdroot = /dev/fd$drive
fi
2005-08-12 13:42:57 +02:00
mount /dev/$root /mnt >/dev/null || exit
2005-07-13 16:59:43 +02:00
# Running from the installation CD.
2005-08-12 11:52:29 +02:00
files = "`find / -xdev | wc -l`"
cpdir -vx / /mnt || progressbar " $files " || exit
2005-07-13 16:59:43 +02:00
chmod 555 /mnt/usr
2005-07-13 15:04:56 +02:00
# CD remnants that aren't for the installed system
rm /mnt/etc/issue /mnt/CD 2>/dev/null
2005-08-12 13:08:23 +02:00
# Change /etc/fstab. (No swap.)
# ${swap:+swap=/dev/$swap}
2005-07-13 15:04:56 +02:00
echo >/mnt/etc/fstab " \
# Poor man's File System Table.
root = /dev/$root
usr = /dev/$usr "
# National keyboard map.
test -n " $keymap " && cp -p " /usr/lib/keymaps/ $keymap .map " /mnt/etc/keymap
2005-08-12 13:42:57 +02:00
# Set inet.conf to correct driver
2005-07-13 15:04:56 +02:00
if [ -n " $driver " ]
then echo " eth0 $driver 0 { default; }; " >/mnt/etc/inet.conf
2005-08-05 18:49:38 +02:00
echo " $driverargs " >$LOCALRC
2005-08-08 11:24:02 +02:00
disable = ""
2005-08-08 19:37:39 +02:00
else disable = "disable=inet;"
2005-07-13 15:04:56 +02:00
fi
2005-08-12 13:42:57 +02:00
umount /dev/$root >/dev/null || exit # Unmount the new root.
2005-07-13 15:04:56 +02:00
# Compute size of the second level file block cache.
case ` arch` in
i86)
cache = ` expr " 0 $memsize " - 1024`
test $cache -lt 32 && cache = 0
test $cache -gt 512 && cache = 512
; ;
*)
cache = ` expr " 0 $memsize " - 2560`
test $cache -lt 64 && cache = 0
test $cache -gt 1024 && cache = 1024
esac
2005-08-11 15:12:55 +02:00
# echo "Second level file system block cache set to $cache KB."
2005-07-13 15:04:56 +02:00
if [ $cache -eq 0 ] ; then cache = ; else cache = " ramsize= $cache " ; fi
2005-08-11 15:12:55 +02:00
# Make bootable.
2005-07-13 15:04:56 +02:00
installboot -d /dev/$root /usr/mdec/bootblock /boot/boot >/dev/null || exit
2005-08-11 15:12:55 +02:00
edparams /dev/$root " rootdev= $root ; ramimagedev= $root ; $disable $cache ; main() { echo By default, MINIX 3 will automatically load in 3 seconds.; echo Press ESC to enter the monitor for special configuration.; trap 3000 boot; menu; }; save " || exit
2005-07-13 15:04:56 +02:00
pfile = "/usr/src/tools/fdbootparams"
2005-08-11 15:12:55 +02:00
# echo "Remembering boot parameters in ${pfile}."
2005-07-13 15:04:56 +02:00
echo " rootdev= $root ; ramimagedev= $root ; $cache ; save " >$pfile || exit
sync
echo "
2005-08-12 13:08:23 +02:00
Please type 'shutdown' to exit MINIX 3 and enter the boot monitor. At the
boot monitor prompt, type 'boot $primary' to try your new MINIX system.
This ends the MINIX setup script. After booting your newly set up system,
you can run the test suites as indicated in the setup manual. You also
may want to take care of local configuration, such as securing your system
with a password. Please consult the usage manual for more information.
2005-08-11 15:12:55 +02:00
2005-08-08 16:28:32 +02:00
"
2005-07-13 15:04:56 +02:00