Commit | Line | Data |
---|---|---|
f078e99d | 1 | #!/bin/sh |
362925ff | 2 | # install1.fs disk 'install' |
f078e99d | 3 | # |
362925ff AM |
4 | # Currently, no method for checking to see if the designated disk type is |
5 | # already in /etc/disktab. You can edit it out of the file after installation. | |
f078e99d | 6 | # |
c5bc0e81 | 7 | OPSYSTEM=FreeBSD |
362925ff AM |
8 | OPSYSID=165 |
9 | ROOTMIN=7 | |
10 | SWAPMIN=8 | |
11 | DISKMIN=`expr $ROOTMIN + $SWAPMIN + 1` | |
0d255f16 | 12 | DEFBLOCKING=2 |
8231ed99 RG |
13 | DEFSECT=17 |
14 | DEFHEAD=12 | |
15 | DEFCYLN=1024 | |
362925ff | 16 | RUN_FDISK="" |
f078e99d | 17 | |
362925ff AM |
18 | set_arbitrary_defaults() { |
19 | cyls_per_disk=$DEFCYLN | |
20 | tracks_per_cyl=$DEFHEAD | |
21 | sects_per_track=$DEFSECT | |
22 | unused_last_part=3 | |
23 | part_cnt=4 | |
24 | } | |
25 | ||
26 | ||
27 | get_fdisk_data() { | |
28 | cyls_per_disk= | |
29 | part_id= | |
30 | got_sysid= | |
31 | part_cnt=0 | |
32 | sysid_cnt=0 | |
33 | have_opsys_part= | |
34 | unused_last_part= | |
35 | extent_max=0 | |
36 | extent_max_part= | |
37 | ||
38 | fdisk /dev/r${drivename}d >fdisk.out 2>fdisk.err | |
39 | if [ $? -gt 0 ]; then | |
40 | echo "Can't open /dev/r${drivename}d for reading!" | |
41 | set_arbitrary_defaults | |
42 | >fdisk.out | |
43 | >fdisk.err | |
44 | return 2 | |
45 | elif [ -s fdisk.err ]; then | |
46 | echo "Disk doesn't appear to be initialized..." | |
47 | no_part_table=1 | |
21a421ff | 48 | fi |
362925ff AM |
49 | while read data; do |
50 | if [ ! "$cyls_per_disk" ]; then | |
51 | cyls_per_disk=`expr "$data" : '[^=]*=\([0-9]*\)'` | |
52 | tracks_per_cyl=`expr "$data" : '[^=]*=[^=]*=\([0-9]*\)'` | |
53 | sects_per_track=`expr "$data" : '[^=]*=[^=]*=[^=]*=\([0-9]*\)'` | |
54 | continue | |
55 | fi | |
56 | if [ "$got_sysid" ]; then | |
57 | start_part=`expr "$data" : '[^0-9]*\([0-9]*\)'` | |
58 | size_part=`expr "$data" : '[^0-9]*[0-9]*[^0-9]*\([0-9]*\)'` | |
59 | extent_part=`expr $start_part + $size_part` | |
60 | if [ $extent_part -gt $extent_max ]; then | |
61 | extent_max=$extent_part | |
62 | extent_max_part=$part_id | |
63 | fi | |
64 | eval start${part_id}=$start_part | |
65 | eval size${part_id}=$size_part | |
66 | sysid_cnt=`expr $sysid_cnt + 1` | |
67 | got_sysid= | |
68 | part_id= | |
69 | elif [ "$part_id" ]; then | |
70 | sysid=`expr "$data" : 'sysid \([0-9]*\)'` | |
71 | if [ "$no_part_table" -o "$sysid" = "0" -o \ | |
72 | "$(expr "$data" : '\(<UNUSED>\)')" = "<UNUSED>" ]; then | |
73 | unused_last_part=$part_id | |
74 | part_id= | |
75 | continue | |
76 | fi | |
77 | [ "$sysid" = "$OPSYSID" ] && have_opsys_part=$part_id | |
78 | eval sysid${part_id}=$sysid | |
79 | got_sysid=1 | |
80 | else | |
81 | part_id=`expr "$data" : 'The data[^0-9]*\([0-9]*\)'` | |
82 | beg_cyl=`expr "$data" : '[ ]*beg[^0-9]*\([0-9]*\)'` | |
83 | end_cyl=`expr "$data" : '[ ]*end[^0-9]*\([0-9]*\)'` | |
84 | if [ "$part_id" ]; then | |
85 | part_cnt=`expr $part_cnt + 1` | |
86 | elif [ "$beg_cyl" ]; then | |
87 | if [ $beg_cyl -gt $cyls_per_disk ]; then | |
88 | no_part_table=1 | |
89 | sysid_cnt=0 | |
90 | have_opsys_part=0 | |
91 | unused_last_part=`expr $part_cnt - 1` | |
92 | fi | |
93 | elif [ "$end_cyl" ]; then | |
94 | if [ $end_cyl -gt $cyls_per_disk ]; then | |
95 | no_part_table=1 | |
96 | sysid_cnt=0 | |
97 | have_opsys_part=0 | |
98 | unused_last_part=`expr $part_cnt - 1` | |
99 | fi | |
100 | fi | |
101 | fi | |
102 | done <fdisk.out | |
103 | if [ ! "$cyls_per_disk" ]; then | |
104 | set_arbitrary_defaults | |
105 | return 2 | |
106 | fi | |
107 | >fdisk.out | |
108 | >fdisk.err | |
109 | return 0 | |
110 | } | |
111 | ||
112 | analyze_fdisk_data() { | |
113 | # Case I: >1024 cylinders | |
114 | force_offset= | |
115 | if [ $cyls_per_disk -gt 1024 ]; then | |
116 | echo | |
117 | echo "WARNING: >1024 cylinders." | |
730f2c4e | 118 | echo -n "Overwriting existing partitions - okay? [y] " |
362925ff AM |
119 | read resp junk |
120 | [ ! "$resp" ] && resp=y | |
121 | case "$resp" in | |
f078e99d | 122 | y*|Y*) |
730f2c4e | 123 | RUN_FDISK="" |
362925ff | 124 | force_offset=1 |
730f2c4e AM |
125 | opsys_off=0 |
126 | cyls_per_opsys=${cyls_per_disk} | |
127 | opsys_part=${unused_last_part:-3} | |
128 | return 0 | |
362925ff AM |
129 | ;; |
130 | *) | |
21a421ff | 131 | echo |
730f2c4e | 132 | echo "If the number of disk cylinders does not exceed 1024, then ${OPSYSTEM}" |
362925ff | 133 | echo "can be installed alongside other operating systems on a single disk." |
730f2c4e AM |
134 | echo "Otherwise, it is system-dependent whether this will work or not." |
135 | echo "In the worst case, ${OPSYSTEM} MUST be installed at the beginning of" | |
136 | echo "the disk, and existing partitions will be lost." | |
137 | echo | |
138 | echo "For now, we will assume that >1024 cylinders creates no problems..." | |
139 | # FALL THROUGH | |
362925ff AM |
140 | ;; |
141 | esac | |
730f2c4e | 142 | fi |
362925ff | 143 | # Case II: no partitions used |
730f2c4e | 144 | if [ $sysid_cnt -eq 0 ]; then |
362925ff AM |
145 | echo |
146 | echo "WARNING: partition table is either missing or corrupt." | |
147 | echo "Existing partitions will be lost." | |
148 | part_cnt=${part_cnt:-4} | |
149 | RUN_FDISK="overwrite" | |
150 | opsys_off=1 | |
151 | cyls_per_opsys=`expr ${cyls_per_disk} - 1` | |
152 | opsys_part=${unused_last_part:-3} | |
153 | return 0 | |
154 | # Case IIIa: overwrite an existing 386BSD/NetBSD/FreeBSD partition | |
155 | elif [ "$have_opsys_part" ]; then | |
156 | echo | |
157 | echo "386/Net/FreeBSD partition already exists!" | |
158 | echo -n "Overwriting existing partition - okay? [y] " | |
159 | read resp junk | |
160 | [ ! "$resp" ] && resp=y | |
161 | case "$resp" in | |
162 | y*|Y*) | |
163 | # Set existing partiton values as default (after adjusting to | |
164 | # cylinder boundaries) | |
165 | eval opsys_size=\$size${have_opsys_part} | |
166 | eval opsys_start=\$start${have_opsys_part} | |
167 | [ $opsys_size -eq 50000 ] && opsys_size=$disksize | |
168 | opsys_off=`expr $opsys_start / $cylindersize` | |
169 | opsys_adjusted=`expr $opsys_off \* $cylindersize` | |
170 | if [ $opsys_adjusted -lt $opsys_start -o $opsys_off -eq 0 ]; then | |
171 | opsys_off=`expr $opsys_off + 1` | |
172 | opsys_adjusted=`expr $opsys_off \* $cylindersize` | |
173 | opsys_size=`expr $opsys_size - $opsys_adjusted + $opsys_start` | |
174 | fi | |
175 | cyls_per_opsys=`expr $opsys_size / $cylindersize` | |
176 | opsys_part=${have_opsys_part} | |
177 | RUN_FDISK="fdisk -u" | |
178 | return 0 | |
179 | ;; | |
180 | *) | |
181 | have_opsys_part= | |
182 | # FALL THROUGH | |
183 | ;; | |
184 | esac | |
185 | fi | |
186 | ||
187 | # Case IIIb: no partitions available | |
188 | if [ $sysid_cnt -eq $part_cnt -a ! "$have_opsys_part" ]; then | |
189 | echo | |
190 | echo "No unused partitions." | |
191 | echo "$OPSYSTEM cannot selectively overwrite existing partitions." | |
192 | echo -n "Install $OPSYSTEM and overwrite the entire disk? [n] " | |
193 | read resp junk | |
194 | case "$resp" in | |
195 | y*|Y*) | |
196 | # don't use first cylinder! | |
197 | opsys_off=1 | |
198 | cyls_per_opsys=`expr $cyls_per_disk - 1` | |
199 | opsys_part=${unused_last_part} | |
200 | RUN_FDISK="overwrite" | |
201 | return 0 | |
202 | ;; | |
203 | *) | |
204 | return 2 | |
205 | ;; | |
206 | esac | |
207 | fi | |
208 | ||
209 | ||
210 | # *** CAVEAT *** | |
211 | # $OPSYSTEM installs at the end of the disk. If the | |
212 | # beginning of the disk is free but not the end, install fails! | |
213 | ||
214 | # Assume `fdisk -u' to add $OPSYSTEM in last unused partition for remaining cases | |
215 | opsys_part=${unused_last_part} | |
216 | RUN_FDISK="fdisk -u" | |
217 | mb_sect=`expr 1024 \* 1024 / $bytes_per_sect` | |
218 | disk_minimum=`expr $DISKMIN \* $mb_sect` | |
219 | ||
220 | # Case IV: No room (at end of disk) for mininal install | |
221 | disk_remaining=`expr $disksize - $extent_max` | |
222 | if [ $disk_remaining -lt $disk_minimum ]; then | |
223 | echo | |
224 | echo "Not enough space ($DISKMIN Mb) at end of disk to install $OPSYSTEM." | |
225 | echo -n "Install FreeBSD and overwrite the entire disk? [n] " | |
226 | read resp junk | |
227 | case "$resp" in | |
228 | y*|Y*) | |
229 | # don't use first cylinder! | |
230 | opsys_off=1 | |
231 | cyls_per_opsys=`expr $cyls_per_disk - 1` | |
232 | opsys_part=${unused_last_part} | |
233 | RUN_FDISK="overwrite" | |
f078e99d RG |
234 | ;; |
235 | *) | |
362925ff AM |
236 | echo |
237 | echo "WARNING: To install ${OPSYSTEM}, you're on your own in figuring" | |
238 | echo "out where on the disk it will fit without overwriting another" | |
239 | echo "partition..." | |
240 | # Set defaults assuming there is only one partition at end of disk | |
241 | eval start=\$start${extent_max_part} | |
242 | # don't use first cylinder! | |
243 | opsys_off=1 | |
244 | cyls_per_opsys=`expr $start / $cylindersize - 1` | |
f078e99d | 245 | ;; |
362925ff AM |
246 | esac |
247 | return 0 | |
248 | fi | |
249 | ||
250 | # Case V: Room for $OPSYSTEM and partition data okay | |
251 | opsys_off=`expr $extent_max / $cylindersize` | |
252 | opsys_extent=`expr $opsys_off \* $cylindersize` | |
253 | [ $opsys_extent -lt $extent_max ] && opsys_off=`expr $opsys_off + 1` | |
254 | cyls_per_opsys=`expr $cyls_per_disk - $opsys_off` | |
255 | return 0 | |
256 | } | |
257 | ||
258 | put_fdisk_data() { | |
259 | start=$root_offset | |
260 | size=$partition | |
261 | ||
262 | if [ "$RUN_FDISK" = "overwrite" ]; then | |
263 | # How do you overwrite without explicitly editing each entry? | |
264 | ( | |
265 | echo y | |
266 | echo $cyls_per_disk | |
267 | echo $tracks_per_cyl | |
268 | echo $sects_per_track | |
269 | echo y | |
270 | ) >fdisk.script | |
271 | i=0 | |
272 | n=`expr ${part_cnt:-4} - 1` | |
273 | while [ $i -lt $n ]; do | |
274 | echo y | |
275 | echo 0 | |
276 | echo 0 | |
277 | echo 0 | |
278 | echo n | |
279 | echo y | |
280 | i=`expr $i + 1` | |
281 | done >>fdisk.script | |
282 | ( echo y | |
283 | echo ${OPSYSID} | |
284 | echo ${start} | |
285 | echo ${size} | |
286 | echo n | |
287 | echo y | |
288 | echo y | |
289 | echo ${n} | |
290 | echo y | |
291 | echo y | |
292 | ) >>fdisk.script | |
293 | fdisk -u <fdisk.script >/dev/null 2>&1 | |
294 | elif [ "$RUN_FDISK" ]; then | |
295 | $RUN_FDISK -${opsys_part:-${unused_last_part:-3}} <<-EOF >/dev/null 2>&1 | |
296 | y | |
297 | $cyls_per_disk | |
298 | $tracks_per_cyl | |
299 | $sects_per_track | |
300 | y | |
301 | y | |
302 | ${OPSYSID} | |
303 | ${start} | |
304 | ${size} | |
305 | n | |
306 | y | |
307 | y | |
308 | ${opsys_part:-${unused_last_part:-3}} | |
309 | y | |
310 | y | |
311 | EOF | |
312 | fi | |
313 | ||
314 | } | |
315 | ||
316 | echo "Welcome to ${OPSYSTEM}." | |
317 | echo | |
318 | echo "This program is designed to help put ${OPSYSTEM} on a hard disk with" | |
319 | echo "at least $DISKMIN Megabytes of free space." | |
320 | echo | |
321 | echo "If other operating systems are already on the disk, ${OPSYSTEM}" | |
322 | echo "should be able to install alongside them. Otherwise, if the disk" | |
323 | echo "is being installed for the first time, it would probably be useful" | |
324 | echo "to have the disk's hardware manual, the installation notes, and a" | |
325 | echo "calculator handy." | |
326 | echo | |
327 | echo "As with anything which modifies a hard drive's contents, this" | |
328 | echo "program can cause SIGNIFICANT data loss, and we strongly recommend" | |
329 | echo "making sure that the hard drive is backed up before going further with" | |
330 | echo "the installation process." | |
331 | echo | |
332 | echo -n "Proceed with installation? [y] " | |
333 | read resp junk | |
334 | resp=${resp:-y} | |
335 | case "$resp" in | |
336 | y*|Y*) | |
337 | echo | |
338 | echo "Cool! Let's get to it..." | |
339 | echo | |
340 | echo "If a mistake is made along the way, don't bail out." | |
341 | echo "At the end, you have the option to redo the configuration." | |
342 | echo "If you really must quit at some point, type <CTRL>+C and" | |
343 | echo "enter \`halt' at the command prompt, \`#'." | |
344 | ;; | |
345 | *) | |
346 | echo | |
347 | echo "OK, then. Enter \`halt' to halt the machine." | |
348 | echo "Once the machine has halted, remove the floppy," | |
349 | echo "and press any key to reboot." | |
350 | exit | |
351 | ;; | |
f078e99d | 352 | esac |
c5bc0e81 | 353 | |
362925ff AM |
354 | mount -u /dev/fd0a / |
355 | sync | |
ede9f473 | 356 | verified_install="" |
362925ff | 357 | while [ ! "$verified_install" ]; do # Begin of Big Loop |
ede9f473 | 358 | |
c5bc0e81 RG |
359 | rotdelay="" |
360 | drivename=wd0 | |
361 | drivetype=wd | |
362 | sect_fwd="" | |
362925ff AM |
363 | echo |
364 | echo "First, we need to know the drive type. This can be can be one of" | |
21a421ff | 365 | echo "ESDI, SCSI, ST506, or IDE." |
362925ff AM |
366 | echo -n "Drive type? [${type:-IDE}] " |
367 | read resp junk | |
368 | type=${resp:-${type:-IDE}} | |
f078e99d | 369 | case "$type" in |
362925ff AM |
370 | e*|E*|st*|ST*) |
371 | echo -n "Does it support AUTOMATIC sector remapping? [y] " | |
372 | read remap junk | |
373 | case "$remap" in | |
374 | n*|N*) | |
375 | sect_fwd="sf:" | |
f078e99d | 376 | ;; |
362925ff AM |
377 | esac |
378 | case "$type" in | |
379 | e*|E*) | |
380 | DEFSECT=36 | |
21a421ff | 381 | ;; |
362925ff AM |
382 | esac |
383 | ;; | |
384 | i*|I*) | |
385 | type=ST506 | |
386 | rotdelay="-d 0" | |
387 | ;; | |
388 | sc*|SC*) | |
389 | drivename=sd0 | |
390 | drivetype=sd | |
391 | type=SCSI | |
392 | rotdelay="-d 0" | |
393 | DEFSECT=32 | |
394 | DEFHEAD=64 | |
395 | ;; | |
396 | *) | |
397 | echo "Unknown type. Assuming ST506 with automatic sectoring..." | |
398 | type=ST506 | |
399 | ;; | |
f078e99d | 400 | esac |
362925ff AM |
401 | echo |
402 | echo "Disk is of device type $drivetype." | |
403 | echo | |
404 | echo -n "Number of bytes per disk sector? [${bytes_per_sect:-512}] " | |
405 | read resp junk | |
406 | bytes_per_sect=${resp:-${bytes_per_sect:-512}} | |
407 | if [ ! "$partition" ]; then | |
408 | echo | |
409 | echo "Please wait. Examining device /dev/r${drivename}d..." | |
410 | get_fdisk_data | |
411 | if [ $? -gt 1 ]; then | |
412 | echo "Hm - we can't seem to read that drive." | |
413 | echo | |
414 | echo -n "Are you sure that $type is the correct type? [n] " | |
415 | read resp | |
416 | case "$resp" in | |
417 | y*|Y*) | |
418 | echo "Well, since we can't even open it, there isn't much" | |
419 | echo "hope for writing a label on it. But you're free" | |
420 | echo "to give it a try. You need to specify the geometry." | |
421 | ;; | |
422 | *) | |
423 | echo "Okay. Let's start again from the top." | |
424 | continue | |
425 | ;; | |
426 | esac | |
427 | fi | |
428 | fi | |
429 | echo | |
21a421ff AM |
430 | echo "Now we want to build a data base entry in /etc/disktab describing" |
431 | echo "the geometry of the /dev/$drivename disk. The name of the entry" | |
432 | echo "should be descriptive of the disk's type and model. For example," | |
433 | echo "a Maxtor IDE, model 7080 disk might be named \`maxtor7080'." | |
362925ff AM |
434 | echo -n "Disk label name (one word, please)? [${name:-mfr_model}] " |
435 | read resp junk | |
436 | name=${resp:-${name:-mfr_model}} | |
437 | echo | |
438 | echo -n "Total number of disk cylinders? [${cyls_per_disk:-${DEFCYLN}}] " | |
439 | read resp junk | |
440 | cyls_per_disk=${resp:-${cyls_per_disk:-${DEFCYLN}}} | |
441 | echo | |
442 | echo -n "Number of disk heads (i.e., tracks/cylinder)? [${tracks_per_cyl:-${DEFHEAD}}] " | |
443 | read resp junk | |
444 | tracks_per_cyl=${resp:-${tracks_per_cyl:-${DEFHEAD}}} | |
445 | echo | |
446 | echo -n "Number of disk sectors (i.e., sectors/track)? [${sects_per_track:-${DEFSECT}}] " | |
447 | read resp junk | |
448 | sects_per_track=${resp:-${sects_per_track:-${DEFSECT}}} | |
f078e99d RG |
449 | cylindersize=`expr $sects_per_track \* $tracks_per_cyl` |
450 | disksize=`expr $cylindersize \* $cyls_per_disk` | |
21a421ff AM |
451 | mb_sect=`expr 1024 \* 1024 / $bytes_per_sect` |
452 | mb_per_disk=`expr $disksize / $mb_sect` | |
362925ff AM |
453 | opsys_cyls_min=`expr $DISKMIN \* $mb_sect / $cylindersize` |
454 | analyze_fdisk_data | |
455 | if [ $? -eq 0 ]; then | |
456 | partition=`expr $cyls_per_opsys \* $cylindersize` | |
457 | part_offset=`expr $opsys_off \* $cylindersize` | |
21a421ff | 458 | fi |
362925ff AM |
459 | echo |
460 | echo "Disk has a total of $mb_per_disk Mb." | |
461 | echo "The size of the ${OPSYSTEM} portion of the disk must be at least" | |
462 | echo "${opsys_cyls_min} cylinders, and should not exceed $(expr $cyls_per_disk - 1) cylinders." | |
463 | echo "The offset of ${OPSYSTEM} from the beginning of the disk should be at" | |
464 | echo "least 1 cylinder." | |
465 | echo | |
466 | echo "For efficiency, partitions begin and end on cylinder boundaries." | |
467 | echo "If you know the size NN in Megabytes (Mb) of a partition you want, then" | |
468 | echo "use the following formula to determine the number NC of cylinders to use:" | |
469 | echo " NC = integer { ( NN * $mb_sect ) / $cylindersize }" | |
470 | while :; do | |
471 | echo -n "Total size of the ${OPSYSTEM} portion of the disk (in cylinders)? [${cyls_per_opsys:-`expr ${cyls_per_disk} - 1`}] " | |
472 | read resp junk | |
473 | cyls_per_opsys=${resp:-${cyls_per_opsys:-`expr ${cyls_per_disk} - 1`}} | |
474 | partition=`expr $cyls_per_opsys \* $cylindersize` | |
475 | if [ $cyls_per_opsys -lt $cyls_per_disk -a ! "$force_offset" ]; then | |
476 | echo | |
477 | echo -n "Offset of ${OPSYSTEM} from beginning of disk (in cylinders)? [${opsys_off:-1}] " | |
478 | read resp junk | |
479 | opsys_off=${resp:-${opsys_off:-1}} | |
480 | else | |
481 | echo | |
482 | echo "WARNING: Installing at cylinder 0 overwrites DOS partition table." | |
483 | echo "Existing partitions will be lost, and subsequent installs may fail." | |
484 | RUN_FDISK="" | |
485 | cyls_per_opsys=$cyls_per_disk | |
486 | partition=$disksize | |
487 | opsys_off=0 | |
21a421ff | 488 | fi |
362925ff AM |
489 | part_offset=`expr $opsys_off \* $cylindersize` |
490 | opsys_extent=`expr $opsys_off + $cyls_per_opsys` | |
491 | if [ ${opsys_extent} -gt ${cyls_per_disk} ]; then | |
492 | echo | |
493 | echo "${OPSYSTEM} Size + Offset cannot exceed ${cyls_per_disk} cylinders." | |
494 | elif [ ${cyls_per_opsys} -lt ${opsys_cyls_min} ]; then | |
495 | echo | |
496 | echo "${OPSYSTEM} requires at least ${opsys_cyls_min} cylinders to install." | |
497 | else break | |
498 | fi | |
499 | done | |
f078e99d RG |
500 | badspacesec=0 |
501 | if [ "$sect_fwd" = "sf:" ]; then | |
502 | badspacecyl=`expr $sects_per_track + 126` | |
503 | badspacecyl=`expr $badspacecyl + $cylindersize - 1` | |
504 | badspacecyl=`expr $badspacecyl / $cylindersize` | |
505 | badspacesec=`expr $badspacecyl \* $cylindersize` | |
362925ff | 506 | echo |
f078e99d RG |
507 | echo -n "Using $badspacesec sectors ($badspacecyl cylinders) for the " |
508 | echo "bad144 bad block table" | |
509 | fi | |
510 | whats_left=`expr $partition - $badspacesec` | |
511 | cyl_left=`expr $whats_left / $cylindersize` | |
21a421ff | 512 | mb_left=`expr $whats_left / $mb_sect` |
362925ff AM |
513 | swap_cyls_min=`expr $SWAPMIN \* $mb_sect / $cylindersize` |
514 | root_cyls_max=`expr ${cyl_left} - ${swap_cyls_min}` | |
515 | root_cyls_min=`expr $ROOTMIN \* $mb_sect / $cylindersize` | |
516 | echo | |
517 | echo "There are $mb_left Mb ($cyl_left cylinders) to allocate." | |
518 | echo | |
519 | echo "The $OPSYSTEM portion of the disk must itself be divided into at least" | |
520 | echo "two partitions: one for the root filesystem and one for swap. It is a" | |
521 | echo "good idea to have at least a third (large) $OPSYSTEM partition for the /usr" | |
522 | echo "filesystem." | |
523 | echo | |
524 | echo "The root partition cannot exceed ${root_cyls_max} cylinders. It is usually" | |
525 | echo "no larger than about 15 Mb ($(expr 15 \* $mb_sect / $cylindersize) cylinders), and sometimes" | |
526 | echo "as small as $ROOTMIN Mb ($root_cyls_min cylinders)." | |
527 | if [ ! "$cyls_per_root" ]; then | |
528 | # set default root partition to 15MB | |
529 | cyls_per_root=`expr \( 15 \* $mb_sect \) / $cylindersize` | |
530 | [ $cyls_per_root -gt $root_cyls_max ] && cyls_per_root=$root_cyls_max | |
21a421ff | 531 | fi |
362925ff AM |
532 | while :; do |
533 | echo -n "Root partition size (in cylinders)? [${cyls_per_root}] " | |
534 | read resp junk | |
535 | cyls_per_root=${resp:-${cyls_per_root}} | |
536 | root=`expr $cyls_per_root \* $cylindersize` | |
537 | if [ ${cyls_per_root} -gt ${root_cyls_max} ]; then | |
538 | echo | |
539 | echo "The root partition size cannot exceed $root_cyls_max cylinders." | |
540 | elif [ ${cyls_per_root} -lt ${root_cyls_min} ]; then | |
541 | echo | |
542 | echo "The root partition size must be at least $root_cyls_min cylinders." | |
543 | else | |
544 | part_used=`expr $root + $badspacesec` | |
545 | break | |
21a421ff | 546 | fi |
f078e99d RG |
547 | done |
548 | root_offset=$part_offset | |
549 | whats_left=`expr $partition - $part_used` | |
21a421ff AM |
550 | cyl_left=`expr $whats_left / $cylindersize` |
551 | mb_left=`expr $whats_left / $mb_sect` | |
362925ff | 552 | echo |
0d255f16 RG |
553 | # DO NOT USE DIFFERENT BLOCKING FACTORS FOR EACH PARITION.. IT TRASHES THE |
554 | # VM SYSTEM! When that gets fixed this can go back the way it was... | |
555 | # | |
556 | echo "We can build the filesystems with block/fragment sizes of either" | |
21a421ff AM |
557 | echo " 1) 4k/512, to save disk space at the expense of speed, or" |
558 | echo " 2) 8k/1k for speed at the expense of disk space." | |
0d255f16 | 559 | echo -n "Which blocking factor should we use for the filesystems? " |
362925ff AM |
560 | echo -n "[${blocking_factor:-${DEFBLOCKING}}] " |
561 | read resp junk | |
562 | blocking_factor=${resp:-${blocking_factor:-${DEFBLOCKING}}} | |
21a421ff AM |
563 | fragsize=`expr $bytes_per_sect \* $blocking_factor` |
564 | blocksize=`expr $bytes_per_sect \* $blocking_factor \* 8` | |
362925ff AM |
565 | echo |
566 | echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk." | |
567 | echo | |
568 | echo "Minimum swap space is ${swap_cyls_min} cylinders." | |
569 | echo "For running X, if your RAM size is NR Mb, then the recomended swap" | |
570 | echo "size NS (in cylinders) is:" | |
571 | echo " NS = integer { ( NR x `expr 21 \* $mb_sect / 10` ) / ${cylindersize} }" | |
572 | if [ ! "$swap_cyl" ]; then | |
21a421ff AM |
573 | # guess memory size |
574 | mb_ram=16 | |
362925ff AM |
575 | swap_cyl=`expr \( 21 \* $mb_ram \* $mb_sect \) / 10` |
576 | swap_cyl=`expr $swap_cyl / ${cylindersize}` | |
21a421ff AM |
577 | |
578 | # but not swap size more than 10% of disk size... | |
579 | swap_quot=`expr $mb_left / $mb_ram` | |
580 | if [ $swap_quot -lt 10 ]; then | |
362925ff | 581 | swap_cyl=$swap_cyls_min |
21a421ff | 582 | fi |
362925ff AM |
583 | fi |
584 | while :; do | |
585 | echo -n "Swap partition size (in cylinders)? [${swap_cyl}] " | |
586 | read resp junk | |
587 | swap_cyl=${resp:-${swap_cyl}} | |
588 | swap=`expr $swap_cyl \* $cylindersize` | |
589 | if [ ${swap_cyl} -gt ${cyl_left} ]; then | |
590 | echo | |
591 | echo "Swap size cannot exceed $cyl_left cylinders." | |
592 | elif [ ${swap_cyl} -lt ${swap_cyls_min} ]; then | |
593 | echo | |
594 | echo "Swap size must be at least ${swap_cyls_min} cylinders." | |
595 | else | |
596 | break | |
21a421ff | 597 | fi |
f078e99d | 598 | done |
362925ff | 599 | echo |
f078e99d RG |
600 | swap_offset=`expr $root_offset + $root` |
601 | part_used=`expr $part_used + $swap` | |
362925ff AM |
602 | echo "" >/etc/disktab |
603 | echo "$name|${OPSYSTEM} installation generated:\\" >>/etc/disktab | |
604 | echo " :dt=${type}:ty=winchester:\\" >>/etc/disktab | |
f078e99d | 605 | echo -n " :nc#${cyls_per_disk}:ns#${sects_per_track}" >>/etc/disktab |
362925ff AM |
606 | echo ":nt#${tracks_per_cyl}:\\" >>/etc/disktab |
607 | echo " :se#${bytes_per_sect}:${sect_fwd}\\" >>/etc/disktab | |
f078e99d | 608 | echo -n " :pa#${root}:oa#${root_offset}" >>/etc/disktab |
362925ff AM |
609 | echo ":ta=4.2BSD:ba#${blocksize}:fa#${fragsize}:\\" >>/etc/disktab |
610 | echo " :pb#${swap}:ob#${swap_offset}:tb=swap:\\" >>/etc/disktab | |
611 | echo " :pc#${partition}:oc#${part_offset}:\\" >>/etc/disktab | |
f078e99d | 612 | ename="";fname="";gname="";hname="" |
362925ff AM |
613 | if [ $part_used -lt $partition ]; then |
614 | echo | |
615 | echo "Now we enter information about any other partitions and filesystems" | |
616 | echo "to be created in the ${OPSYSTEM} portion of the disk. This process" | |
617 | echo "is complete when we've filled up all remaining space in the ${OPSYSTEM}" | |
618 | echo "portion of the disk." | |
619 | fi | |
f078e99d RG |
620 | while [ $part_used -lt $partition ]; do |
621 | part_size=0 | |
622 | whats_left=`expr $partition - $part_used` | |
21a421ff AM |
623 | cyl_left=`expr $whats_left / $cylindersize` |
624 | mb_left=`expr $whats_left / $mb_sect` | |
362925ff AM |
625 | echo |
626 | echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk." | |
627 | echo | |
628 | while :; do | |
21a421ff | 629 | echo -n "Next partition size (in cylinders)? [${cyl_left}] " |
362925ff AM |
630 | read resp junk |
631 | part_size=${resp:-${cyl_left}} | |
632 | part_size=`expr $part_size \* $cylindersize` | |
633 | total=`expr $part_used + $part_size` | |
634 | if [ $total -gt $partition ]; then | |
635 | echo | |
636 | echo "Partition size cannot exceed ${cyl_left} cylinders." | |
637 | else | |
638 | part_used=$total | |
639 | part_name="" | |
640 | while [ "$part_name" = "" ]; do | |
641 | echo | |
642 | echo -n "On which directory should this filesystem be mounted? [usr] " | |
643 | read resp junk | |
644 | part_name=${resp:-usr} | |
645 | part_name=`expr "$part_name" : '/*\(.*\)'` | |
646 | done | |
647 | break | |
21a421ff | 648 | fi |
f078e99d | 649 | done |
362925ff AM |
650 | echo |
651 | if [ ! "$ename" ]; then | |
f078e99d RG |
652 | ename=$part_name |
653 | offset=`expr $part_offset + $root + $swap` | |
654 | echo -n " :pe#${part_size}:oe#${offset}" >>/etc/disktab | |
655 | echo ":te=4.2BSD:be#${blocksize}:fe#${fragsize}:\\" >>/etc/disktab | |
656 | offset=`expr $offset + $part_size` | |
362925ff | 657 | elif [ ! "$fname" ]; then |
f078e99d RG |
658 | fname=$part_name |
659 | echo -n " :pf#${part_size}:of#${offset}" >>/etc/disktab | |
660 | echo ":tf=4.2BSD:bf#${blocksize}:ff#${fragsize}:\\" >>/etc/disktab | |
661 | offset=`expr $offset + $part_size` | |
362925ff | 662 | elif [ ! "$gname" ]; then |
f078e99d RG |
663 | gname=$part_name |
664 | echo -n " :pg#${part_size}:og#${offset}" >>/etc/disktab | |
665 | echo ":tg=4.2BSD:bg#${blocksize}:fg#${fragsize}:\\" >>/etc/disktab | |
666 | offset=`expr $offset + $part_size` | |
362925ff | 667 | elif [ ! "$hname" ]; then |
f078e99d RG |
668 | hname=$part_name |
669 | echo -n " :ph#${part_size}:oh#${offset}" >>/etc/disktab | |
670 | echo ":th=4.2BSD:bh#${blocksize}:fh#${fragsize}:\\" >>/etc/disktab | |
671 | part_used=partition | |
672 | fi | |
673 | done | |
674 | ||
362925ff | 675 | echo " :pd#${disksize}:od#0:" >>/etc/disktab |
f078e99d RG |
676 | sync |
677 | ||
362925ff AM |
678 | # cat /etc/disktab |
679 | OIFS=$IFS | |
680 | IFS=' | |
681 | ' | |
682 | while read data; do | |
683 | echo $data | |
684 | done < /etc/disktab | |
685 | IFS=$OIFS | |
686 | ||
687 | echo | |
8231ed99 RG |
688 | echo -n "Verbose installation? [n] " |
689 | read resp | |
690 | ||
691 | case $resp in | |
362925ff AM |
692 | y*) |
693 | cpioverbose=v | |
694 | ;; | |
695 | *) | |
696 | cpioverbose= | |
697 | ;; | |
8231ed99 RG |
698 | esac |
699 | ||
362925ff AM |
700 | |
701 | echo | |
702 | echo "OK! THIS IS THE LAST CHANCE!!! Data on the hard disk wil be lost." | |
21a421ff | 703 | echo -n "Are you sure you want to install on the hard drive? (yes/no) " |
362925ff AM |
704 | resp="" |
705 | while [ ! "$resp" ]; do | |
706 | read resp junk | |
707 | case "$resp" in | |
708 | Yes|yes|YES) | |
709 | verified_install=1 | |
710 | echo | |
711 | echo "OK! Here we go..." | |
712 | ;; | |
713 | No|no|NO) | |
714 | echo | |
715 | echo -n "Would you like to change the configuration? [y] " | |
716 | read resp junk | |
717 | resp=${resp:-y} | |
718 | case "$resp" in | |
719 | y*|Y*) | |
f078e99d RG |
720 | ;; |
721 | *) | |
362925ff AM |
722 | echo |
723 | echo "OK, then. Enter 'halt' to halt the machine." | |
724 | echo "Once the machine has halted, remove the floppy," | |
725 | echo "and press any key to reboot." | |
726 | exit | |
f078e99d | 727 | ;; |
362925ff AM |
728 | esac |
729 | ;; | |
730 | *) | |
731 | echo "Please spell out either of \`yes' or \`no'..." | |
732 | echo -n "Install on the hard disk? (yes/no) " | |
733 | resp= | |
734 | ;; | |
f078e99d RG |
735 | esac |
736 | done | |
ede9f473 AM |
737 | done # End of Big Loop |
738 | ||
362925ff AM |
739 | put_fdisk_data |
740 | ||
741 | echo | |
f078e99d | 742 | echo -n "Labelling disk..." |
362925ff AM |
743 | echo y | |
744 | /sbin/disklabel -w -r ${drivename} $name /usr/mdec/${drivetype}boot /usr/mdec/boot${drivetype} >/dev/null 2>&1 | |
745 | echo " done." | |
f078e99d RG |
746 | |
747 | if [ "$sect_fwd" = "sf:" ]; then | |
748 | echo -n "Initializing bad144 badblock table..." | |
749 | bad144 $drivename 0 | |
750 | echo " done." | |
362925ff AM |
751 | echo "Updating badblock table..." |
752 | # `2>&1 >/dev/null' filters stdout and leaves only stderr... | |
753 | bad144 -s $drivename 2>&1 >/dev/null | | |
754 | while read data; do | |
755 | bad_seek=`expr $data : '[^(]*(seek)[^0-9]*\([0-9]*\)'` | |
756 | bad_read=`expr $data : '[^(]*(read)[^0-9]*\([0-9]*\)'` | |
757 | [ "$bad_seek" -o "$bad_read" ] && echo -n "$bad_seek $bad_read " | |
758 | done >bad144.out | |
759 | if [ -s bad144.out ]; then | |
760 | read badlist <bad144.out | |
761 | bad144 -a -c $drivename "$badlist" | |
762 | >bad144.out | |
763 | fi | |
764 | echo " done." | |
f078e99d RG |
765 | fi |
766 | ||
362925ff | 767 | echo "Initializing root filesystem, and mounting..." |
c5bc0e81 | 768 | newfs ${rotdelay} /dev/r${drivename}a $name |
f078e99d RG |
769 | mount -v /dev/${drivename}a /mnt |
770 | if [ "$ename" != "" ]; then | |
362925ff AM |
771 | echo |
772 | echo "Initializing $ename filesystem, and mounting..." | |
c5bc0e81 | 773 | newfs ${rotdelay} /dev/r${drivename}e $name |
f078e99d RG |
774 | mkdir -p /mnt/$ename |
775 | mount -v /dev/${drivename}e /mnt/$ename | |
776 | fi | |
777 | if [ "$fname" != "" ]; then | |
362925ff AM |
778 | echo |
779 | echo "Initializing $fname filesystem, and mounting..." | |
c5bc0e81 | 780 | newfs ${rotdelay} /dev/r${drivename}f $name |
f078e99d RG |
781 | mkdir -p /mnt/$fname |
782 | mount -v /dev/${drivename}f /mnt/$fname | |
783 | fi | |
784 | if [ "$gname" != "" ]; then | |
362925ff AM |
785 | echo |
786 | echo "Initializing $gname filesystem, and mounting..." | |
c5bc0e81 | 787 | newfs ${rotdelay} /dev/r${drivename}g $name |
f078e99d RG |
788 | mkdir -p /mnt/$gname |
789 | mount -v /dev/${drivename}g /mnt/$gname | |
790 | fi | |
791 | if [ "$hname" != "" ]; then | |
362925ff AM |
792 | echo |
793 | echo "Initializing $hname filesystem, and mounting..." | |
c5bc0e81 | 794 | newfs ${rotdelay} /dev/r${drivename}h $name |
f078e99d RG |
795 | mkdir -p /mnt/$hname |
796 | mount -v /dev/${drivename}h /mnt/$hname | |
797 | fi | |
798 | ||
8231ed99 | 799 | echo |
362925ff | 800 | echo "Please wait. Copying to disk..." |
f078e99d | 801 | cd / |
362925ff AM |
802 | # cat filelist | cpio -pdamu${cpioverbose} /mnt |
803 | OIFS=$IFS | |
804 | IFS=' | |
805 | ' | |
806 | while read data; do | |
807 | echo $data | |
808 | done <filelist | cpio -pdamu${cpioverbose} /mnt | |
809 | IFS=$OIFS | |
0d255f16 | 810 | sync |
f078e99d RG |
811 | |
812 | cd /mnt | |
c5bc0e81 | 813 | echo "/dev/${drivename}a / ufs rw 1 1" >etc/fstab |
f078e99d | 814 | if [ "$ename" != "" ]; then |
c5bc0e81 | 815 | echo "/dev/${drivename}e /$ename ufs rw 1 2" >>etc/fstab |
f078e99d RG |
816 | fi |
817 | if [ "$fname" != "" ]; then | |
c5bc0e81 | 818 | echo "/dev/${drivename}f /$fname ufs rw 1 3" >>etc/fstab |
f078e99d RG |
819 | fi |
820 | if [ "$gname" != "" ]; then | |
c5bc0e81 | 821 | echo "/dev/${drivename}g /$gname ufs rw 1 4" >>etc/fstab |
f078e99d RG |
822 | fi |
823 | if [ "$hname" != "" ]; then | |
c5bc0e81 | 824 | echo "/dev/${drivename}h /$hname ufs rw 1 5" >>etc/fstab |
f078e99d RG |
825 | fi |
826 | ||
362925ff AM |
827 | # cat /etc/disktab >etc/disktab.install |
828 | OIFS=$IFS | |
829 | IFS=' | |
830 | ' | |
831 | while read data; do | |
832 | echo $data | |
833 | done </etc/disktab >etc/disktab.install | |
834 | IFS=$OIFS | |
0d255f16 | 835 | |
362925ff AM |
836 | # cat << EOF >.profile |
837 | ( | |
919841f8 | 838 | echo "PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:/usr/distbin:.:" |
362925ff AM |
839 | echo "export PATH" |
840 | echo "HOME=/root" | |
841 | echo "export HOME" | |
842 | echo "TERM=pc3" | |
843 | echo "export TERM" | |
844 | echo "mount -at ufs" | |
845 | echo "echo" | |
846 | echo "echo \"Insert second installation floppy in drive and\"" | |
847 | echo "echo -n \"enter that drive's number (e.g. 0 or 1): [0] \"" | |
848 | echo "read resp junk" | |
849 | echo "driveno=\${resp:-0}" | |
850 | echo "mount -o ro /dev/fd\${driveno}a /mnt" | |
851 | echo "cd /mnt" | |
852 | echo "install" | |
730f2c4e AM |
853 | echo "cd /" |
854 | echo "umount /mnt >/dev/null 2>&1" | |
855 | echo "echo" | |
856 | echo "echo \"Now insert third installation floppy in drive and\"" | |
857 | echo "echo -n \"enter that drive's number (e.g. 0 or 1): [0] \"" | |
858 | echo "read resp junk" | |
859 | echo "driveno=\${resp:-0}" | |
860 | echo "mount -t pcfs -o ro /dev/fd\${driveno}a /mnt" | |
861 | echo "mkdir -p /usr/distbin" | |
862 | echo "cp /mnt/* /usr/distbin/" | |
919841f8 | 863 | echo "sync" |
730f2c4e AM |
864 | echo "umount /mnt >/dev/null 2>&1" |
865 | echo "echo" | |
866 | echo "echo \"OK. All of the base files are installed.\"" | |
867 | echo "echo" | |
868 | echo "echo \"The next step: reboot from the hard disk, and follow\"" | |
869 | echo "echo \"more instrutctions.\"" | |
870 | echo "echo" | |
871 | echo "echo \"To do this, enter 'halt' at the prompt to halt the machine.\"" | |
872 | echo "echo \"Once the machine has halted, remove the floppy from the disk\"" | |
873 | echo "echo \"drive, and hit any key to reboot from the hard disk.\"" | |
362925ff | 874 | ) >.profile |
f078e99d RG |
875 | |
876 | sync | |
877 | ||
362925ff AM |
878 | echo |
879 | echo "The next step: reboot from the kernel-copy disk, copy a kernel" | |
880 | echo "to the hard disk, and finally reboot from the hard disk." | |
881 | echo | |
882 | echo "To do this, enter 'halt' now to halt the machine. After it" | |
21a421ff AM |
883 | echo "announces that it has halted, remove the floppy from the drive" |
884 | echo "and insert the kernel-copy disk that was booted before." | |
730f2c4e AM |
885 | echo "Press any key to reboot. When prompted to insert the filesystem" |
886 | echo "floppy this time, just hit RETURN without changing floppies." | |
362925ff AM |
887 | echo |
888 | echo "If all goes well, you can enter the command \`copy' at the prompt to" | |
889 | echo "copy the kernel to the hard disk. When asked for which partition to" | |
890 | echo "copy to, enter to \`${drivename}a' (without the quotes)." | |
891 | echo | |
21a421ff | 892 | echo "Okay, that's all for now. I'm waiting for you to enter \`halt'..." |