source: trunk/minix/commands/scripts/floppysetup.sh@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 9.8 KB
Line 
1#!/bin/sh
2#
3# setup 4.1 - install a Minix distribution Author: Kees J. Bot
4# 20 Dec 1994
5
6PATH=/bin:/usr/bin
7export PATH
8
9usage()
10{
11 cat >&2 <<'EOF'
12Usage: setup # Install a skeleton system on the hard disk.
13 setup /usr # Install the rest of the system (binaries or sources).
14
15 # To install from other things then floppies:
16
17 urlget http://... | setup /usr # Read from a web site.
18 urlget ftp://... | setup /usr # Read from an FTP site.
19 mtools copy c0d0p0:... - | setup /usr # Read from the C: drive.
20 dosread c0d0p0 ... | setup /usr # Likewise if no mtools.
21EOF
22 exit 1
23}
24
25# No options.
26while getopts '' opt; do usage; done
27shift `expr $OPTIND - 1`
28
29# Installing a floppy set?
30case $# in
310) # No, we're installing a skeleton system on the hard disk.
32 ;;
331)
34 cd "$1" || exit
35
36 # Annoying message still there?
37 grep "'setup /usr'" /etc/issue >/dev/null 2>&1 && rm -f /etc/issue
38
39 if [ -t 0 ]
40 then
41 size=bad
42 while [ "$size" = bad ]
43 do
44 echo -n "\
45What is the size of the images on the diskettes? [all] "; read size
46
47 case $size in
48 ''|360|720|1200|1440)
49 ;;
50 *) echo "Sorry, I don't believe \"$size\", try again." >&2
51 size=bad
52 esac
53 done
54
55 drive=
56 while [ -z "$drive" ]
57 do
58 echo -n "What floppy drive to use? [0] "; read drive
59
60 case $drive in
61 '') drive=0
62 ;;
63 [01])
64 ;;
65 *) echo "It must be 0 or 1, not \"$drive\"."
66 drive=
67 esac
68 done
69
70 vol -r $size /dev/fd$drive | uncompress | tar xvfp -
71 else
72 # Standard input is where we can get our files from.
73 uncompress | tar xvfp -
74 fi
75
76 echo Done.
77 exit
78 ;;
79*)
80 usage
81esac
82
83# Installing Minix on the hard disk.
84# Must be in / or we can't mount or umount.
85if [ ! -f /CD ]
86then
87 case "`pwd`" in
88 /?*)
89 echo "Please type 'cd /' first, you are locking up `pwd`" >&2
90 exit 1
91 esac
92fi
93
94case "$0" in
95/tmp/*)
96 rm -f "$0"
97 ;;
98*) cp -p "$0" /tmp/setup
99 exec /tmp/setup
100esac
101
102# Find out what we are running from.
103exec 9<&0 </etc/mtab # Mounted file table.
104read thisroot rest # Current root (/dev/ram or /dev/fd?)
105read fdusr rest # USR (/dev/fd? or /dev/fd?p2)
106exec 0<&9 9<&-
107
108# What do we know about ROOT?
109case $thisroot:$fdusr in
110/dev/ram:/dev/fd0p2) fdroot=/dev/fd0 # Combined ROOT+USR in drive 0
111 ;;
112/dev/ram:/dev/fd1p2) fdroot=/dev/fd1 # Combined ROOT+USR in drive 1
113 ;;
114/dev/ram:/dev/fd*) fdroot=unknown # ROOT is some other floppy
115 ;;
116/dev/fd*:/dev/fd*) fdroot=$thisroot # ROOT is mounted directly
117 ;;
118*) fdroot=$thisroot # ?
119 if [ -f /CD ]
120 then
121 :
122 else
123 echo -n "\
124It looks like Minix has been installed on disk already. Are you sure you
125know what you are doing? [n] "
126 read yn
127 case "$yn" in
128 [yY]*|sure) ;;
129 *) exit
130 esac
131 fi
132esac
133
134echo -n "\
135This is the Minix installation script.
136
137Note 1: If the screen blanks suddenly then hit CTRL+F3 to select \"software
138 scrolling\".
139
140Note 2: If things go wrong then hit DEL and start over.
141
142Note 3: The installation procedure is described in the manual page
143 usage(8). It will be hard without it.
144
145Note 4: Some questions have default answers, like this: [y]
146 Simply hit RETURN (or ENTER) if you want to choose that answer.
147
148Note 5: If you see a colon (:) then you should hit RETURN to continue.
149:"
150read ret
151
152echo "
153What type of keyboard do you have? You can choose one of:
154"
155ls -C /usr/lib/keymaps | sed -e 's/\.map//g' -e 's/^/ /'
156echo -n "
157Keyboard type? [us-std] "; read keymap
158test -n "$keymap" && loadkeys "/usr/lib/keymaps/$keymap.map"
159
160echo -n "
161Minix needs one primary partition of at about 210 MB for a full install
162with sources. (The full install also fits in about 180 MB, but it
163needs more if fully recompiled. Add more space to taste.)
164
165 * Minix currently only understands filesystems up to 4GB, so don't make
166 it bigger.
167
168If there is no free space on your disk then you have to back up one of the
169other partitions, shrink, and reinstall. See the appropriate manuals of the
170the operating systems currently installed. Restart your Minix installation
171after you have made space.
172
173To make this partition you will be put in the editor \"part\". Follow the
174advice under the '!' key to make a new partition of type MINIX. Do not
175touch an existing partition unless you know precisely what you are doing!
176Please note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you
177make. (See the devices section in usage(8) on Minix device names.)
178:"
179read ret
180
181primary=
182while [ -z "$primary" ]
183do
184 part || exit
185
186 echo -n "
187Please finish the name of the primary partition you have created:
188(Just type RETURN if you want to rerun \"part\") /dev/"
189 read primary
190done
191
192root=${primary}s0
193swap=${primary}s1
194usr=${primary}s2
195
196hex2int()
197{
198 # Translate hexadecimal to integer.
199 local h d i
200
201 h=$1
202 i=0
203 while [ -n "$h" ]
204 do
205 d=$(expr $h : '\(.\)')
206 h=$(expr $h : '.\(.*\)')
207 d=$(expr \( 0123456789ABCDEF : ".*$d" \) - 1)
208 i=$(expr $i \* 16 + $d)
209 done
210 echo $i
211}
212
213# Ask user about networking
214echo ""
215echo "Minix currently supports the Intel Pro/100 and RealTek 8139 "
216echo "Ethernet cards. Please choose: "
217echo ""
218echo "0. No Ethernet card (no networking)"
219echo "1. An Intel Pro/100 Ethernet card is installed"
220echo "2. A Realtek 8139 Ethernet card is installed"
221echo "3. A different Ethernet card is installed (no networking)"
222echo ""
223echo "You can always change your mind after the install."
224echo ""
225echo "Choice? "
226read eth
227driver=""
228inetparams=""
229case "$eth" in
230 1) driver=FXP; inetparams="servers=inet;" ;;
231 2) driver=RTL8139; inetparams="servers=inet;" ;;
232esac
233
234# Compute the amount of memory available to Minix.
235memsize=0
236ifs="$IFS"
237IFS=','
238set -- $(sysenv memory)
239IFS="$ifs"
240
241for mem
242do
243 mem=$(expr $mem : '.*:\(.*\)')
244 memsize=$(expr $memsize + $(hex2int $mem) / 1024)
245done
246
247# Compute an advised swap size.
248swapadv=0
249case `arch` in
250i86)
251 test $memsize -lt 4096 && swapadv=$(expr 4096 - $memsize)
252 ;;
253*) test $memsize -lt 6144 && swapadv=$(expr 6144 - $memsize)
254esac
255
256echo -n "
257How much swap space would you like? Swapspace is only needed if this
258system is memory starved, like a 16-bit system with less then 2M, or a
25932-bit system with less then 4M. Minix swapping isn't very good yet, so
260there is no need for it otherwise.
261 Size in kilobytes? [$swapadv] "
262swapsize=
263read swapsize
264test -z "$swapsize" && swapsize=$swapadv
265
266echo -n "
267You have created a partition named: /dev/$primary
268The following subpartitions are about to be created on /dev/$primary:
269
270 Root subpartition: /dev/$root 16 MB
271 Swap subpartition: /dev/$swap $swapsize kb
272 /usr subpartition: /dev/$usr rest of $primary
273
274Hit return if everything looks fine, or hit DEL to bail out if you want to
275think it over. The next step will destroy /dev/$primary.
276:"
277read ret
278 # Secondary master bootstrap.
279installboot -m /dev/$primary /usr/mdec/masterboot >/dev/null || exit
280
281 # Partition the primary.
282p3=0:0
283test "$swapsize" -gt 0 && p3=81:`expr $swapsize \* 2`
284partition /dev/$primary 1 81:32768* $p3 81:0+ || exit
285
286if [ "$swapsize" -gt 0 ]
287then
288 # We must have that swap, now!
289 mkswap -f /dev/$swap || exit
290 mount -s /dev/$swap || exit
291else
292 # Forget about swap.
293 swap=
294fi
295
296echo "
297Migrating to disk...
298"
299
300mkfs /dev/$usr
301echo "\
302Scanning /dev/$usr for bad blocks. (Hit DEL to stop the scan if you are
303absolutely sure that there can not be any bad blocks. Otherwise just wait.)"
304trap ': nothing' 2
305readall -b /dev/$usr | sh
306sleep 2
307trap 2
308
309mount /dev/$usr /mnt || exit # Mount the intended /usr.
310
311cpdir -v /usr /mnt || exit # Copy the usr floppy.
312
313umount /dev/$usr || exit # Unmount the intended /usr.
314
315umount $fdusr # Unmount the /usr floppy.
316
317mount /dev/$usr /usr || exit # A new /usr
318
319if [ $fdroot = unknown ]
320then
321 echo "
322By now the floppy USR has been copied to /dev/$usr, and it is now in use as
323/usr. Please insert the installation ROOT floppy in a floppy drive."
324
325 drive=
326 while [ -z "$drive" ]
327 do
328 echo -n "What floppy drive is it in? [0] "; read drive
329
330 case $drive in
331 '') drive=0
332 ;;
333 [01])
334 ;;
335 *) echo "It must be 0 or 1, not \"$drive\"."
336 drive=
337 esac
338 done
339 fdroot=/dev/fd$drive
340fi
341
342echo "
343Copying $fdroot to /dev/$root
344"
345
346mkfs /dev/$root || exit
347mount /dev/$root /mnt || exit
348if [ -d /boot ]
349then
350 # Running from the floppy itself (or installation CD).
351 cpdir -vx / /mnt || exit
352 chmod 555 /mnt/usr
353else
354 # Running from the RAM disk, root image is on a floppy.
355 mount $fdroot /root || exit
356 cpdir -v /root /mnt || exit
357 umount $fdroot || exit
358 cpdir -f /dev /mnt/dev # Copy any extra MAKEDEV'd devices
359fi
360
361# CD remnants that aren't for the installed system
362rm /mnt/etc/issue /mnt/CD 2>/dev/null
363 # Change /etc/fstab.
364echo >/mnt/etc/fstab "\
365# Poor man's File System Table.
366
367root=/dev/$root
368${swap:+swap=/dev/$swap}
369usr=/dev/$usr"
370
371 # National keyboard map.
372test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt/etc/keymap
373
374# Set inet.conf to correct driver
375if [ -n "$driver" ]
376then echo "eth0 $driver 0 { default; };" >/mnt/etc/inet.conf
377fi
378
379umount /dev/$root || exit # Unmount the new root.
380
381# Compute size of the second level file block cache.
382case `arch` in
383i86)
384 cache=`expr "0$memsize" - 1024`
385 test $cache -lt 32 && cache=0
386 test $cache -gt 512 && cache=512
387 ;;
388*)
389 cache=`expr "0$memsize" - 2560`
390 test $cache -lt 64 && cache=0
391 test $cache -gt 1024 && cache=1024
392esac
393echo "Second level file system block cache set to $cache kb."
394if [ $cache -eq 0 ]; then cache=; else cache="ramsize=$cache"; fi
395
396 # Make bootable.
397installboot -d /dev/$root /usr/mdec/bootblock /boot/boot >/dev/null || exit
398edparams /dev/$root "rootdev=$root; ramimagedev=$root; $cache; $inetparams; save" || exit
399pfile="/usr/src/tools/fdbootparams"
400echo "Remembering boot parameters in ${pfile}."
401echo "rootdev=$root; ramimagedev=$root; $cache; save" >$pfile || exit
402sync
403
404echo "
405Please type 'halt' to exit Minix.
406You can type 'boot $primary' to try the newly installed Minix system. See
407\"TESTING\" in the usage manual."
408
Note: See TracBrowser for help on using the repository browser.