1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # setup 4.1 - install a Minix distribution Author: Kees J. Bot
|
---|
4 | # 20 Dec 1994
|
---|
5 |
|
---|
6 | PATH=/bin:/usr/bin
|
---|
7 | export PATH
|
---|
8 |
|
---|
9 | usage()
|
---|
10 | {
|
---|
11 | cat >&2 <<'EOF'
|
---|
12 | Usage: 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.
|
---|
21 | EOF
|
---|
22 | exit 1
|
---|
23 | }
|
---|
24 |
|
---|
25 | # No options.
|
---|
26 | while getopts '' opt; do usage; done
|
---|
27 | shift `expr $OPTIND - 1`
|
---|
28 |
|
---|
29 | # Installing a floppy set?
|
---|
30 | case $# in
|
---|
31 | 0) # No, we're installing a skeleton system on the hard disk.
|
---|
32 | ;;
|
---|
33 | 1)
|
---|
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 "\
|
---|
45 | What 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
|
---|
81 | esac
|
---|
82 |
|
---|
83 | # Installing Minix on the hard disk.
|
---|
84 | # Must be in / or we can't mount or umount.
|
---|
85 | if [ ! -f /CD ]
|
---|
86 | then
|
---|
87 | case "`pwd`" in
|
---|
88 | /?*)
|
---|
89 | echo "Please type 'cd /' first, you are locking up `pwd`" >&2
|
---|
90 | exit 1
|
---|
91 | esac
|
---|
92 | fi
|
---|
93 |
|
---|
94 | case "$0" in
|
---|
95 | /tmp/*)
|
---|
96 | rm -f "$0"
|
---|
97 | ;;
|
---|
98 | *) cp -p "$0" /tmp/setup
|
---|
99 | exec /tmp/setup
|
---|
100 | esac
|
---|
101 |
|
---|
102 | # Find out what we are running from.
|
---|
103 | exec 9<&0 </etc/mtab # Mounted file table.
|
---|
104 | read thisroot rest # Current root (/dev/ram or /dev/fd?)
|
---|
105 | read fdusr rest # USR (/dev/fd? or /dev/fd?p2)
|
---|
106 | exec 0<&9 9<&-
|
---|
107 |
|
---|
108 | # What do we know about ROOT?
|
---|
109 | case $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 "\
|
---|
124 | It looks like Minix has been installed on disk already. Are you sure you
|
---|
125 | know what you are doing? [n] "
|
---|
126 | read yn
|
---|
127 | case "$yn" in
|
---|
128 | [yY]*|sure) ;;
|
---|
129 | *) exit
|
---|
130 | esac
|
---|
131 | fi
|
---|
132 | esac
|
---|
133 |
|
---|
134 | echo -n "\
|
---|
135 | This is the Minix installation script.
|
---|
136 |
|
---|
137 | Note 1: If the screen blanks suddenly then hit CTRL+F3 to select \"software
|
---|
138 | scrolling\".
|
---|
139 |
|
---|
140 | Note 2: If things go wrong then hit DEL and start over.
|
---|
141 |
|
---|
142 | Note 3: The installation procedure is described in the manual page
|
---|
143 | usage(8). It will be hard without it.
|
---|
144 |
|
---|
145 | Note 4: Some questions have default answers, like this: [y]
|
---|
146 | Simply hit RETURN (or ENTER) if you want to choose that answer.
|
---|
147 |
|
---|
148 | Note 5: If you see a colon (:) then you should hit RETURN to continue.
|
---|
149 | :"
|
---|
150 | read ret
|
---|
151 |
|
---|
152 | echo "
|
---|
153 | What type of keyboard do you have? You can choose one of:
|
---|
154 | "
|
---|
155 | ls -C /usr/lib/keymaps | sed -e 's/\.map//g' -e 's/^/ /'
|
---|
156 | echo -n "
|
---|
157 | Keyboard type? [us-std] "; read keymap
|
---|
158 | test -n "$keymap" && loadkeys "/usr/lib/keymaps/$keymap.map"
|
---|
159 |
|
---|
160 | echo -n "
|
---|
161 | Minix needs one primary partition of at about 210 MB for a full install
|
---|
162 | with sources. (The full install also fits in about 180 MB, but it
|
---|
163 | needs 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 |
|
---|
168 | If there is no free space on your disk then you have to back up one of the
|
---|
169 | other partitions, shrink, and reinstall. See the appropriate manuals of the
|
---|
170 | the operating systems currently installed. Restart your Minix installation
|
---|
171 | after you have made space.
|
---|
172 |
|
---|
173 | To make this partition you will be put in the editor \"part\". Follow the
|
---|
174 | advice under the '!' key to make a new partition of type MINIX. Do not
|
---|
175 | touch an existing partition unless you know precisely what you are doing!
|
---|
176 | Please note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you
|
---|
177 | make. (See the devices section in usage(8) on Minix device names.)
|
---|
178 | :"
|
---|
179 | read ret
|
---|
180 |
|
---|
181 | primary=
|
---|
182 | while [ -z "$primary" ]
|
---|
183 | do
|
---|
184 | part || exit
|
---|
185 |
|
---|
186 | echo -n "
|
---|
187 | Please finish the name of the primary partition you have created:
|
---|
188 | (Just type RETURN if you want to rerun \"part\") /dev/"
|
---|
189 | read primary
|
---|
190 | done
|
---|
191 |
|
---|
192 | root=${primary}s0
|
---|
193 | swap=${primary}s1
|
---|
194 | usr=${primary}s2
|
---|
195 |
|
---|
196 | hex2int()
|
---|
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
|
---|
214 | echo ""
|
---|
215 | echo "Minix currently supports the Intel Pro/100 and RealTek 8139 "
|
---|
216 | echo "Ethernet cards. Please choose: "
|
---|
217 | echo ""
|
---|
218 | echo "0. No Ethernet card (no networking)"
|
---|
219 | echo "1. An Intel Pro/100 Ethernet card is installed"
|
---|
220 | echo "2. A Realtek 8139 Ethernet card is installed"
|
---|
221 | echo "3. A different Ethernet card is installed (no networking)"
|
---|
222 | echo ""
|
---|
223 | echo "You can always change your mind after the install."
|
---|
224 | echo ""
|
---|
225 | echo "Choice? "
|
---|
226 | read eth
|
---|
227 | driver=""
|
---|
228 | inetparams=""
|
---|
229 | case "$eth" in
|
---|
230 | 1) driver=FXP; inetparams="servers=inet;" ;;
|
---|
231 | 2) driver=RTL8139; inetparams="servers=inet;" ;;
|
---|
232 | esac
|
---|
233 |
|
---|
234 | # Compute the amount of memory available to Minix.
|
---|
235 | memsize=0
|
---|
236 | ifs="$IFS"
|
---|
237 | IFS=','
|
---|
238 | set -- $(sysenv memory)
|
---|
239 | IFS="$ifs"
|
---|
240 |
|
---|
241 | for mem
|
---|
242 | do
|
---|
243 | mem=$(expr $mem : '.*:\(.*\)')
|
---|
244 | memsize=$(expr $memsize + $(hex2int $mem) / 1024)
|
---|
245 | done
|
---|
246 |
|
---|
247 | # Compute an advised swap size.
|
---|
248 | swapadv=0
|
---|
249 | case `arch` in
|
---|
250 | i86)
|
---|
251 | test $memsize -lt 4096 && swapadv=$(expr 4096 - $memsize)
|
---|
252 | ;;
|
---|
253 | *) test $memsize -lt 6144 && swapadv=$(expr 6144 - $memsize)
|
---|
254 | esac
|
---|
255 |
|
---|
256 | echo -n "
|
---|
257 | How much swap space would you like? Swapspace is only needed if this
|
---|
258 | system is memory starved, like a 16-bit system with less then 2M, or a
|
---|
259 | 32-bit system with less then 4M. Minix swapping isn't very good yet, so
|
---|
260 | there is no need for it otherwise.
|
---|
261 | Size in kilobytes? [$swapadv] "
|
---|
262 | swapsize=
|
---|
263 | read swapsize
|
---|
264 | test -z "$swapsize" && swapsize=$swapadv
|
---|
265 |
|
---|
266 | echo -n "
|
---|
267 | You have created a partition named: /dev/$primary
|
---|
268 | The 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 |
|
---|
274 | Hit return if everything looks fine, or hit DEL to bail out if you want to
|
---|
275 | think it over. The next step will destroy /dev/$primary.
|
---|
276 | :"
|
---|
277 | read ret
|
---|
278 | # Secondary master bootstrap.
|
---|
279 | installboot -m /dev/$primary /usr/mdec/masterboot >/dev/null || exit
|
---|
280 |
|
---|
281 | # Partition the primary.
|
---|
282 | p3=0:0
|
---|
283 | test "$swapsize" -gt 0 && p3=81:`expr $swapsize \* 2`
|
---|
284 | partition /dev/$primary 1 81:32768* $p3 81:0+ || exit
|
---|
285 |
|
---|
286 | if [ "$swapsize" -gt 0 ]
|
---|
287 | then
|
---|
288 | # We must have that swap, now!
|
---|
289 | mkswap -f /dev/$swap || exit
|
---|
290 | mount -s /dev/$swap || exit
|
---|
291 | else
|
---|
292 | # Forget about swap.
|
---|
293 | swap=
|
---|
294 | fi
|
---|
295 |
|
---|
296 | echo "
|
---|
297 | Migrating to disk...
|
---|
298 | "
|
---|
299 |
|
---|
300 | mkfs /dev/$usr
|
---|
301 | echo "\
|
---|
302 | Scanning /dev/$usr for bad blocks. (Hit DEL to stop the scan if you are
|
---|
303 | absolutely sure that there can not be any bad blocks. Otherwise just wait.)"
|
---|
304 | trap ': nothing' 2
|
---|
305 | readall -b /dev/$usr | sh
|
---|
306 | sleep 2
|
---|
307 | trap 2
|
---|
308 |
|
---|
309 | mount /dev/$usr /mnt || exit # Mount the intended /usr.
|
---|
310 |
|
---|
311 | cpdir -v /usr /mnt || exit # Copy the usr floppy.
|
---|
312 |
|
---|
313 | umount /dev/$usr || exit # Unmount the intended /usr.
|
---|
314 |
|
---|
315 | umount $fdusr # Unmount the /usr floppy.
|
---|
316 |
|
---|
317 | mount /dev/$usr /usr || exit # A new /usr
|
---|
318 |
|
---|
319 | if [ $fdroot = unknown ]
|
---|
320 | then
|
---|
321 | echo "
|
---|
322 | By 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
|
---|
340 | fi
|
---|
341 |
|
---|
342 | echo "
|
---|
343 | Copying $fdroot to /dev/$root
|
---|
344 | "
|
---|
345 |
|
---|
346 | mkfs /dev/$root || exit
|
---|
347 | mount /dev/$root /mnt || exit
|
---|
348 | if [ -d /boot ]
|
---|
349 | then
|
---|
350 | # Running from the floppy itself (or installation CD).
|
---|
351 | cpdir -vx / /mnt || exit
|
---|
352 | chmod 555 /mnt/usr
|
---|
353 | else
|
---|
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
|
---|
359 | fi
|
---|
360 |
|
---|
361 | # CD remnants that aren't for the installed system
|
---|
362 | rm /mnt/etc/issue /mnt/CD 2>/dev/null
|
---|
363 | # Change /etc/fstab.
|
---|
364 | echo >/mnt/etc/fstab "\
|
---|
365 | # Poor man's File System Table.
|
---|
366 |
|
---|
367 | root=/dev/$root
|
---|
368 | ${swap:+swap=/dev/$swap}
|
---|
369 | usr=/dev/$usr"
|
---|
370 |
|
---|
371 | # National keyboard map.
|
---|
372 | test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt/etc/keymap
|
---|
373 |
|
---|
374 | # Set inet.conf to correct driver
|
---|
375 | if [ -n "$driver" ]
|
---|
376 | then echo "eth0 $driver 0 { default; };" >/mnt/etc/inet.conf
|
---|
377 | fi
|
---|
378 |
|
---|
379 | umount /dev/$root || exit # Unmount the new root.
|
---|
380 |
|
---|
381 | # Compute size of the second level file block cache.
|
---|
382 | case `arch` in
|
---|
383 | i86)
|
---|
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
|
---|
392 | esac
|
---|
393 | echo "Second level file system block cache set to $cache kb."
|
---|
394 | if [ $cache -eq 0 ]; then cache=; else cache="ramsize=$cache"; fi
|
---|
395 |
|
---|
396 | # Make bootable.
|
---|
397 | installboot -d /dev/$root /usr/mdec/bootblock /boot/boot >/dev/null || exit
|
---|
398 | edparams /dev/$root "rootdev=$root; ramimagedev=$root; $cache; $inetparams; save" || exit
|
---|
399 | pfile="/usr/src/tools/fdbootparams"
|
---|
400 | echo "Remembering boot parameters in ${pfile}."
|
---|
401 | echo "rootdev=$root; ramimagedev=$root; $cache; save" >$pfile || exit
|
---|
402 | sync
|
---|
403 |
|
---|
404 | echo "
|
---|
405 | Please type 'halt' to exit Minix.
|
---|
406 | You can type 'boot $primary' to try the newly installed Minix system. See
|
---|
407 | \"TESTING\" in the usage manual."
|
---|
408 |
|
---|