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 | # |
d39e7451 | 7 | PATH=/sbin:/bin:/usr/bin:/usr/sbin:. |
56164db9 | 8 | export PATH |
d39e7451 | 9 | |
c5bc0e81 | 10 | OPSYSTEM=FreeBSD |
362925ff AM |
11 | OPSYSID=165 |
12 | ROOTMIN=7 | |
13 | SWAPMIN=8 | |
14 | DISKMIN=`expr $ROOTMIN + $SWAPMIN + 1` | |
0d255f16 | 15 | DEFBLOCKING=2 |
8231ed99 RG |
16 | DEFSECT=17 |
17 | DEFHEAD=12 | |
18 | DEFCYLN=1024 | |
362925ff | 19 | RUN_FDISK="" |
f078e99d | 20 | |
362925ff AM |
21 | set_arbitrary_defaults() { |
22 | cyls_per_disk=$DEFCYLN | |
23 | tracks_per_cyl=$DEFHEAD | |
24 | sects_per_track=$DEFSECT | |
25 | unused_last_part=3 | |
26 | part_cnt=4 | |
27 | } | |
28 | ||
29 | ||
30 | get_fdisk_data() { | |
31 | cyls_per_disk= | |
32 | part_id= | |
33 | got_sysid= | |
34 | part_cnt=0 | |
35 | sysid_cnt=0 | |
36 | have_opsys_part= | |
37 | unused_last_part= | |
38 | extent_max=0 | |
39 | extent_max_part= | |
40 | ||
41 | fdisk /dev/r${drivename}d >fdisk.out 2>fdisk.err | |
42 | if [ $? -gt 0 ]; then | |
43 | echo "Can't open /dev/r${drivename}d for reading!" | |
44 | set_arbitrary_defaults | |
45 | >fdisk.out | |
46 | >fdisk.err | |
47 | return 2 | |
48 | elif [ -s fdisk.err ]; then | |
49 | echo "Disk doesn't appear to be initialized..." | |
50 | no_part_table=1 | |
21a421ff | 51 | fi |
362925ff AM |
52 | while read data; do |
53 | if [ ! "$cyls_per_disk" ]; then | |
54 | cyls_per_disk=`expr "$data" : '[^=]*=\([0-9]*\)'` | |
55 | tracks_per_cyl=`expr "$data" : '[^=]*=[^=]*=\([0-9]*\)'` | |
56 | sects_per_track=`expr "$data" : '[^=]*=[^=]*=[^=]*=\([0-9]*\)'` | |
57 | continue | |
58 | fi | |
59 | if [ "$got_sysid" ]; then | |
60 | start_part=`expr "$data" : '[^0-9]*\([0-9]*\)'` | |
61 | size_part=`expr "$data" : '[^0-9]*[0-9]*[^0-9]*\([0-9]*\)'` | |
62 | extent_part=`expr $start_part + $size_part` | |
63 | if [ $extent_part -gt $extent_max ]; then | |
64 | extent_max=$extent_part | |
65 | extent_max_part=$part_id | |
66 | fi | |
67 | eval start${part_id}=$start_part | |
68 | eval size${part_id}=$size_part | |
69 | sysid_cnt=`expr $sysid_cnt + 1` | |
70 | got_sysid= | |
71 | part_id= | |
72 | elif [ "$part_id" ]; then | |
73 | sysid=`expr "$data" : 'sysid \([0-9]*\)'` | |
74 | if [ "$no_part_table" -o "$sysid" = "0" -o \ | |
75 | "$(expr "$data" : '\(<UNUSED>\)')" = "<UNUSED>" ]; then | |
76 | unused_last_part=$part_id | |
77 | part_id= | |
78 | continue | |
79 | fi | |
80 | [ "$sysid" = "$OPSYSID" ] && have_opsys_part=$part_id | |
81 | eval sysid${part_id}=$sysid | |
82 | got_sysid=1 | |
83 | else | |
84 | part_id=`expr "$data" : 'The data[^0-9]*\([0-9]*\)'` | |
85 | beg_cyl=`expr "$data" : '[ ]*beg[^0-9]*\([0-9]*\)'` | |
86 | end_cyl=`expr "$data" : '[ ]*end[^0-9]*\([0-9]*\)'` | |
87 | if [ "$part_id" ]; then | |
88 | part_cnt=`expr $part_cnt + 1` | |
d39e7451 AM |
89 | elif [ "${beg_cyl}" -gt "${cyls_per_disk}" -o \ |
90 | "${end_cyl}" -gt "${cyls_per_disk}" ]; then | |
91 | no_part_table=1 | |
92 | sysid_cnt=0 | |
93 | have_opsys_part=0 | |
94 | unused_last_part=`expr $part_cnt - 1` | |
362925ff AM |
95 | fi |
96 | fi | |
97 | done <fdisk.out | |
98 | if [ ! "$cyls_per_disk" ]; then | |
99 | set_arbitrary_defaults | |
100 | return 2 | |
101 | fi | |
102 | >fdisk.out | |
103 | >fdisk.err | |
104 | return 0 | |
105 | } | |
106 | ||
107 | analyze_fdisk_data() { | |
108 | # Case I: >1024 cylinders | |
109 | force_offset= | |
110 | if [ $cyls_per_disk -gt 1024 ]; then | |
111 | echo | |
1f49206c AM |
112 | echo " WARNING: >1024 cylinders. On some hardware, this prevents" |
113 | echo " ${OPSYSTEM} from sharing the disk with other operating systems." | |
730f2c4e | 114 | echo -n "Overwriting existing partitions - okay? [y] " |
362925ff AM |
115 | read resp junk |
116 | [ ! "$resp" ] && resp=y | |
117 | case "$resp" in | |
f078e99d | 118 | y*|Y*) |
730f2c4e | 119 | RUN_FDISK="" |
362925ff | 120 | force_offset=1 |
730f2c4e AM |
121 | opsys_off=0 |
122 | cyls_per_opsys=${cyls_per_disk} | |
123 | opsys_part=${unused_last_part:-3} | |
124 | return 0 | |
362925ff AM |
125 | ;; |
126 | *) | |
21a421ff | 127 | echo |
730f2c4e | 128 | echo "If the number of disk cylinders does not exceed 1024, then ${OPSYSTEM}" |
362925ff | 129 | echo "can be installed alongside other operating systems on a single disk." |
730f2c4e AM |
130 | echo "Otherwise, it is system-dependent whether this will work or not." |
131 | echo "In the worst case, ${OPSYSTEM} MUST be installed at the beginning of" | |
132 | echo "the disk, and existing partitions will be lost." | |
133 | echo | |
134 | echo "For now, we will assume that >1024 cylinders creates no problems..." | |
135 | # FALL THROUGH | |
362925ff AM |
136 | ;; |
137 | esac | |
730f2c4e | 138 | fi |
362925ff | 139 | # Case II: no partitions used |
730f2c4e | 140 | if [ $sysid_cnt -eq 0 ]; then |
362925ff | 141 | echo |
1f49206c AM |
142 | echo " WARNING: partition table is either missing or corrupt." |
143 | echo " Existing partitions will be lost." | |
362925ff AM |
144 | part_cnt=${part_cnt:-4} |
145 | RUN_FDISK="overwrite" | |
146 | opsys_off=1 | |
147 | cyls_per_opsys=`expr ${cyls_per_disk} - 1` | |
148 | opsys_part=${unused_last_part:-3} | |
149 | return 0 | |
150 | # Case IIIa: overwrite an existing 386BSD/NetBSD/FreeBSD partition | |
151 | elif [ "$have_opsys_part" ]; then | |
152 | echo | |
153 | echo "386/Net/FreeBSD partition already exists!" | |
154 | echo -n "Overwriting existing partition - okay? [y] " | |
155 | read resp junk | |
156 | [ ! "$resp" ] && resp=y | |
157 | case "$resp" in | |
158 | y*|Y*) | |
159 | # Set existing partiton values as default (after adjusting to | |
160 | # cylinder boundaries) | |
161 | eval opsys_size=\$size${have_opsys_part} | |
162 | eval opsys_start=\$start${have_opsys_part} | |
163 | [ $opsys_size -eq 50000 ] && opsys_size=$disksize | |
164 | opsys_off=`expr $opsys_start / $cylindersize` | |
165 | opsys_adjusted=`expr $opsys_off \* $cylindersize` | |
166 | if [ $opsys_adjusted -lt $opsys_start -o $opsys_off -eq 0 ]; then | |
167 | opsys_off=`expr $opsys_off + 1` | |
168 | opsys_adjusted=`expr $opsys_off \* $cylindersize` | |
169 | opsys_size=`expr $opsys_size - $opsys_adjusted + $opsys_start` | |
170 | fi | |
171 | cyls_per_opsys=`expr $opsys_size / $cylindersize` | |
172 | opsys_part=${have_opsys_part} | |
173 | RUN_FDISK="fdisk -u" | |
174 | return 0 | |
175 | ;; | |
176 | *) | |
177 | have_opsys_part= | |
178 | # FALL THROUGH | |
179 | ;; | |
180 | esac | |
181 | fi | |
182 | ||
183 | # Case IIIb: no partitions available | |
184 | if [ $sysid_cnt -eq $part_cnt -a ! "$have_opsys_part" ]; then | |
185 | echo | |
186 | echo "No unused partitions." | |
187 | echo "$OPSYSTEM cannot selectively overwrite existing partitions." | |
188 | echo -n "Install $OPSYSTEM and overwrite the entire disk? [n] " | |
189 | read resp junk | |
190 | case "$resp" in | |
191 | y*|Y*) | |
192 | # don't use first cylinder! | |
193 | opsys_off=1 | |
194 | cyls_per_opsys=`expr $cyls_per_disk - 1` | |
195 | opsys_part=${unused_last_part} | |
196 | RUN_FDISK="overwrite" | |
197 | return 0 | |
198 | ;; | |
199 | *) | |
200 | return 2 | |
201 | ;; | |
202 | esac | |
203 | fi | |
204 | ||
205 | ||
206 | # *** CAVEAT *** | |
207 | # $OPSYSTEM installs at the end of the disk. If the | |
208 | # beginning of the disk is free but not the end, install fails! | |
209 | ||
210 | # Assume `fdisk -u' to add $OPSYSTEM in last unused partition for remaining cases | |
211 | opsys_part=${unused_last_part} | |
212 | RUN_FDISK="fdisk -u" | |
213 | mb_sect=`expr 1024 \* 1024 / $bytes_per_sect` | |
214 | disk_minimum=`expr $DISKMIN \* $mb_sect` | |
215 | ||
216 | # Case IV: No room (at end of disk) for mininal install | |
217 | disk_remaining=`expr $disksize - $extent_max` | |
218 | if [ $disk_remaining -lt $disk_minimum ]; then | |
219 | echo | |
220 | echo "Not enough space ($DISKMIN Mb) at end of disk to install $OPSYSTEM." | |
221 | echo -n "Install FreeBSD and overwrite the entire disk? [n] " | |
222 | read resp junk | |
223 | case "$resp" in | |
224 | y*|Y*) | |
225 | # don't use first cylinder! | |
226 | opsys_off=1 | |
227 | cyls_per_opsys=`expr $cyls_per_disk - 1` | |
228 | opsys_part=${unused_last_part} | |
229 | RUN_FDISK="overwrite" | |
f078e99d RG |
230 | ;; |
231 | *) | |
362925ff | 232 | echo |
1f49206c AM |
233 | echo " WARNING: To install ${OPSYSTEM}, you're on your own in figuring" |
234 | echo " out where on the disk it will fit without overwriting another" | |
235 | echo " partition..." | |
362925ff AM |
236 | # Set defaults assuming there is only one partition at end of disk |
237 | eval start=\$start${extent_max_part} | |
238 | # don't use first cylinder! | |
239 | opsys_off=1 | |
240 | cyls_per_opsys=`expr $start / $cylindersize - 1` | |
f078e99d | 241 | ;; |
362925ff AM |
242 | esac |
243 | return 0 | |
244 | fi | |
245 | ||
246 | # Case V: Room for $OPSYSTEM and partition data okay | |
247 | opsys_off=`expr $extent_max / $cylindersize` | |
248 | opsys_extent=`expr $opsys_off \* $cylindersize` | |
249 | [ $opsys_extent -lt $extent_max ] && opsys_off=`expr $opsys_off + 1` | |
250 | cyls_per_opsys=`expr $cyls_per_disk - $opsys_off` | |
251 | return 0 | |
252 | } | |
253 | ||
254 | put_fdisk_data() { | |
255 | start=$root_offset | |
256 | size=$partition | |
257 | ||
258 | if [ "$RUN_FDISK" = "overwrite" ]; then | |
259 | # How do you overwrite without explicitly editing each entry? | |
260 | ( | |
261 | echo y | |
262 | echo $cyls_per_disk | |
263 | echo $tracks_per_cyl | |
264 | echo $sects_per_track | |
265 | echo y | |
266 | ) >fdisk.script | |
267 | i=0 | |
268 | n=`expr ${part_cnt:-4} - 1` | |
269 | while [ $i -lt $n ]; do | |
270 | echo y | |
271 | echo 0 | |
272 | echo 0 | |
273 | echo 0 | |
274 | echo n | |
275 | echo y | |
276 | i=`expr $i + 1` | |
277 | done >>fdisk.script | |
278 | ( echo y | |
279 | echo ${OPSYSID} | |
280 | echo ${start} | |
281 | echo ${size} | |
282 | echo n | |
283 | echo y | |
284 | echo y | |
285 | echo ${n} | |
286 | echo y | |
287 | echo y | |
288 | ) >>fdisk.script | |
289 | fdisk -u <fdisk.script >/dev/null 2>&1 | |
290 | elif [ "$RUN_FDISK" ]; then | |
291 | $RUN_FDISK -${opsys_part:-${unused_last_part:-3}} <<-EOF >/dev/null 2>&1 | |
292 | y | |
293 | $cyls_per_disk | |
294 | $tracks_per_cyl | |
295 | $sects_per_track | |
296 | y | |
297 | y | |
298 | ${OPSYSID} | |
299 | ${start} | |
300 | ${size} | |
301 | n | |
302 | y | |
303 | y | |
304 | ${opsys_part:-${unused_last_part:-3}} | |
305 | y | |
306 | y | |
307 | EOF | |
308 | fi | |
309 | ||
310 | } | |
311 | ||
43a91bf9 | 312 | echo "Welcome to ${OPSYSTEM}." |
362925ff | 313 | echo |
43a91bf9 | 314 | echo "This program is designed to help put ${OPSYSTEM} on a hard disk with" |
362925ff AM |
315 | echo "at least $DISKMIN Megabytes of free space." |
316 | echo | |
317 | echo "If other operating systems are already on the disk, ${OPSYSTEM}" | |
318 | echo "should be able to install alongside them. Otherwise, if the disk" | |
319 | echo "is being installed for the first time, it would probably be useful" | |
320 | echo "to have the disk's hardware manual, the installation notes, and a" | |
321 | echo "calculator handy." | |
322 | echo | |
323 | echo "As with anything which modifies a hard drive's contents, this" | |
324 | echo "program can cause SIGNIFICANT data loss, and we strongly recommend" | |
325 | echo "making sure that the hard drive is backed up before going further with" | |
326 | echo "the installation process." | |
327 | echo | |
328 | echo -n "Proceed with installation? [y] " | |
329 | read resp junk | |
330 | resp=${resp:-y} | |
331 | case "$resp" in | |
332 | y*|Y*) | |
333 | echo | |
43a91bf9 | 334 | echo "Cool! Let's get to it..." |
362925ff AM |
335 | echo |
336 | echo "If a mistake is made along the way, don't bail out." | |
337 | echo "At the end, you have the option to redo the configuration." | |
338 | echo "If you really must quit at some point, type <CTRL>+C and" | |
339 | echo "enter \`halt' at the command prompt, \`#'." | |
340 | ;; | |
341 | *) | |
342 | echo | |
43a91bf9 RG |
343 | echo "OK, then. Enter \`halt' to halt the machine." |
344 | echo "Once the machine has halted, remove the floppy," | |
345 | echo "and press any key to reboot." | |
362925ff AM |
346 | exit |
347 | ;; | |
f078e99d | 348 | esac |
c5bc0e81 | 349 | |
362925ff AM |
350 | mount -u /dev/fd0a / |
351 | sync | |
ede9f473 | 352 | verified_install="" |
362925ff | 353 | while [ ! "$verified_install" ]; do # Begin of Big Loop |
ede9f473 | 354 | |
c5bc0e81 RG |
355 | rotdelay="" |
356 | drivename=wd0 | |
357 | drivetype=wd | |
358 | sect_fwd="" | |
362925ff | 359 | echo |
43a91bf9 | 360 | echo "First, we need to know the drive type. This can be can be one of" |
21a421ff | 361 | echo "ESDI, SCSI, ST506, or IDE." |
362925ff AM |
362 | echo -n "Drive type? [${type:-IDE}] " |
363 | read resp junk | |
364 | type=${resp:-${type:-IDE}} | |
f078e99d | 365 | case "$type" in |
362925ff AM |
366 | e*|E*|st*|ST*) |
367 | echo -n "Does it support AUTOMATIC sector remapping? [y] " | |
368 | read remap junk | |
369 | case "$remap" in | |
370 | n*|N*) | |
371 | sect_fwd="sf:" | |
f078e99d | 372 | ;; |
362925ff AM |
373 | esac |
374 | case "$type" in | |
375 | e*|E*) | |
376 | DEFSECT=36 | |
21a421ff | 377 | ;; |
362925ff AM |
378 | esac |
379 | ;; | |
380 | i*|I*) | |
381 | type=ST506 | |
382 | rotdelay="-d 0" | |
383 | ;; | |
384 | sc*|SC*) | |
385 | drivename=sd0 | |
386 | drivetype=sd | |
387 | type=SCSI | |
388 | rotdelay="-d 0" | |
389 | DEFSECT=32 | |
390 | DEFHEAD=64 | |
391 | ;; | |
392 | *) | |
393 | echo "Unknown type. Assuming ST506 with automatic sectoring..." | |
394 | type=ST506 | |
395 | ;; | |
f078e99d | 396 | esac |
362925ff | 397 | echo |
43a91bf9 | 398 | echo "Disk is of device type $drivetype." |
362925ff AM |
399 | if [ ! "$partition" ]; then |
400 | echo | |
43a91bf9 | 401 | echo "Please wait. Examining device /dev/r${drivename}d..." |
362925ff AM |
402 | get_fdisk_data |
403 | if [ $? -gt 1 ]; then | |
404 | echo "Hm - we can't seem to read that drive." | |
405 | echo | |
406 | echo -n "Are you sure that $type is the correct type? [n] " | |
407 | read resp | |
408 | case "$resp" in | |
409 | y*|Y*) | |
10b607dd | 410 | echo |
362925ff AM |
411 | echo "Well, since we can't even open it, there isn't much" |
412 | echo "hope for writing a label on it. But you're free" | |
413 | echo "to give it a try. You need to specify the geometry." | |
414 | ;; | |
415 | *) | |
10b607dd | 416 | echo |
362925ff AM |
417 | echo "Okay. Let's start again from the top." |
418 | continue | |
419 | ;; | |
420 | esac | |
421 | fi | |
422 | fi | |
423 | echo | |
21a421ff AM |
424 | echo "Now we want to build a data base entry in /etc/disktab describing" |
425 | echo "the geometry of the /dev/$drivename disk. The name of the entry" | |
426 | echo "should be descriptive of the disk's type and model. For example," | |
427 | echo "a Maxtor IDE, model 7080 disk might be named \`maxtor7080'." | |
362925ff AM |
428 | echo -n "Disk label name (one word, please)? [${name:-mfr_model}] " |
429 | read resp junk | |
430 | name=${resp:-${name:-mfr_model}} | |
431 | echo | |
1f49206c AM |
432 | echo -n "Number of bytes per disk sector? [${bytes_per_sect:-512}] " |
433 | read resp junk | |
434 | bytes_per_sect=${resp:-${bytes_per_sect:-512}} | |
435 | echo | |
362925ff AM |
436 | echo -n "Total number of disk cylinders? [${cyls_per_disk:-${DEFCYLN}}] " |
437 | read resp junk | |
438 | cyls_per_disk=${resp:-${cyls_per_disk:-${DEFCYLN}}} | |
439 | echo | |
440 | echo -n "Number of disk heads (i.e., tracks/cylinder)? [${tracks_per_cyl:-${DEFHEAD}}] " | |
441 | read resp junk | |
442 | tracks_per_cyl=${resp:-${tracks_per_cyl:-${DEFHEAD}}} | |
443 | echo | |
444 | echo -n "Number of disk sectors (i.e., sectors/track)? [${sects_per_track:-${DEFSECT}}] " | |
445 | read resp junk | |
446 | sects_per_track=${resp:-${sects_per_track:-${DEFSECT}}} | |
f078e99d RG |
447 | cylindersize=`expr $sects_per_track \* $tracks_per_cyl` |
448 | disksize=`expr $cylindersize \* $cyls_per_disk` | |
21a421ff AM |
449 | mb_sect=`expr 1024 \* 1024 / $bytes_per_sect` |
450 | mb_per_disk=`expr $disksize / $mb_sect` | |
362925ff AM |
451 | opsys_cyls_min=`expr $DISKMIN \* $mb_sect / $cylindersize` |
452 | analyze_fdisk_data | |
453 | if [ $? -eq 0 ]; then | |
454 | partition=`expr $cyls_per_opsys \* $cylindersize` | |
455 | part_offset=`expr $opsys_off \* $cylindersize` | |
21a421ff | 456 | fi |
362925ff AM |
457 | echo |
458 | echo "Disk has a total of $mb_per_disk Mb." | |
459 | echo "The size of the ${OPSYSTEM} portion of the disk must be at least" | |
460 | echo "${opsys_cyls_min} cylinders, and should not exceed $(expr $cyls_per_disk - 1) cylinders." | |
461 | echo "The offset of ${OPSYSTEM} from the beginning of the disk should be at" | |
462 | echo "least 1 cylinder." | |
463 | echo | |
464 | echo "For efficiency, partitions begin and end on cylinder boundaries." | |
465 | echo "If you know the size NN in Megabytes (Mb) of a partition you want, then" | |
466 | echo "use the following formula to determine the number NC of cylinders to use:" | |
467 | echo " NC = integer { ( NN * $mb_sect ) / $cylindersize }" | |
468 | while :; do | |
469 | echo -n "Total size of the ${OPSYSTEM} portion of the disk (in cylinders)? [${cyls_per_opsys:-`expr ${cyls_per_disk} - 1`}] " | |
470 | read resp junk | |
471 | cyls_per_opsys=${resp:-${cyls_per_opsys:-`expr ${cyls_per_disk} - 1`}} | |
472 | partition=`expr $cyls_per_opsys \* $cylindersize` | |
473 | if [ $cyls_per_opsys -lt $cyls_per_disk -a ! "$force_offset" ]; then | |
474 | echo | |
475 | echo -n "Offset of ${OPSYSTEM} from beginning of disk (in cylinders)? [${opsys_off:-1}] " | |
476 | read resp junk | |
477 | opsys_off=${resp:-${opsys_off:-1}} | |
478 | else | |
479 | echo | |
1f49206c AM |
480 | echo " WARNING: Existing partitions will be lost. In addition," |
481 | echo " installing at cylinder 0 may cause problems for some disk" | |
482 | echo " controllers. If the filesystem is corrupted or install" | |
483 | echo " fails, install at cylinder 1." | |
362925ff AM |
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 | 565 | echo |
43a91bf9 | 566 | echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk." |
362925ff AM |
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` | |
43a91bf9 RG |
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 |
43a91bf9 RG |
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 |
43a91bf9 RG |
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 | 625 | echo |
43a91bf9 | 626 | echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk." |
362925ff AM |
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 | ||
43a91bf9 | 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 | |
43a91bf9 | 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 | |
43a91bf9 | 711 | echo "OK! Here we go..." |
362925ff AM |
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 | 722 | echo |
43a91bf9 RG |
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." | |
362925ff | 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 | |
43a91bf9 | 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... | |
1f49206c | 753 | badlist=$(bad144 -s $drivename 2>&1 >/dev/null | |
362925ff | 754 | while read data; do |
1f49206c AM |
755 | bad_seek=$(expr "$data" : '[^(]*(seek)[^0-9]*\([0-9]*\)') |
756 | bad_read=$(expr "$data" : '[^(]*(read)[^0-9]*\([0-9]*\)') | |
362925ff | 757 | [ "$bad_seek" -o "$bad_read" ] && echo -n "$bad_seek $bad_read " |
1f49206c AM |
758 | done) |
759 | [ "$badlist" ] && bad144 -a -c $drivename "$badlist" | |
362925ff | 760 | echo " done." |
f078e99d RG |
761 | fi |
762 | ||
43a91bf9 | 763 | echo "Initializing root filesystem, and mounting..." |
c5bc0e81 | 764 | newfs ${rotdelay} /dev/r${drivename}a $name |
f078e99d RG |
765 | mount -v /dev/${drivename}a /mnt |
766 | if [ "$ename" != "" ]; then | |
362925ff | 767 | echo |
43a91bf9 | 768 | echo "Initializing $ename filesystem, and mounting..." |
c5bc0e81 | 769 | newfs ${rotdelay} /dev/r${drivename}e $name |
f078e99d RG |
770 | mkdir -p /mnt/$ename |
771 | mount -v /dev/${drivename}e /mnt/$ename | |
772 | fi | |
773 | if [ "$fname" != "" ]; then | |
362925ff | 774 | echo |
43a91bf9 | 775 | echo "Initializing $fname filesystem, and mounting..." |
c5bc0e81 | 776 | newfs ${rotdelay} /dev/r${drivename}f $name |
f078e99d RG |
777 | mkdir -p /mnt/$fname |
778 | mount -v /dev/${drivename}f /mnt/$fname | |
779 | fi | |
780 | if [ "$gname" != "" ]; then | |
362925ff | 781 | echo |
43a91bf9 | 782 | echo "Initializing $gname filesystem, and mounting..." |
c5bc0e81 | 783 | newfs ${rotdelay} /dev/r${drivename}g $name |
f078e99d RG |
784 | mkdir -p /mnt/$gname |
785 | mount -v /dev/${drivename}g /mnt/$gname | |
786 | fi | |
787 | if [ "$hname" != "" ]; then | |
362925ff | 788 | echo |
43a91bf9 | 789 | echo "Initializing $hname filesystem, and mounting..." |
c5bc0e81 | 790 | newfs ${rotdelay} /dev/r${drivename}h $name |
f078e99d RG |
791 | mkdir -p /mnt/$hname |
792 | mount -v /dev/${drivename}h /mnt/$hname | |
793 | fi | |
794 | ||
8231ed99 | 795 | echo |
362925ff | 796 | echo "Please wait. Copying to disk..." |
f078e99d | 797 | cd / |
362925ff AM |
798 | # cat filelist | cpio -pdamu${cpioverbose} /mnt |
799 | OIFS=$IFS | |
800 | IFS=' | |
801 | ' | |
802 | while read data; do | |
803 | echo $data | |
804 | done <filelist | cpio -pdamu${cpioverbose} /mnt | |
805 | IFS=$OIFS | |
f078e99d RG |
806 | |
807 | cd /mnt | |
c5bc0e81 | 808 | echo "/dev/${drivename}a / ufs rw 1 1" >etc/fstab |
f078e99d | 809 | if [ "$ename" != "" ]; then |
c5bc0e81 | 810 | echo "/dev/${drivename}e /$ename ufs rw 1 2" >>etc/fstab |
f078e99d RG |
811 | fi |
812 | if [ "$fname" != "" ]; then | |
c5bc0e81 | 813 | echo "/dev/${drivename}f /$fname ufs rw 1 3" >>etc/fstab |
f078e99d RG |
814 | fi |
815 | if [ "$gname" != "" ]; then | |
c5bc0e81 | 816 | echo "/dev/${drivename}g /$gname ufs rw 1 4" >>etc/fstab |
f078e99d RG |
817 | fi |
818 | if [ "$hname" != "" ]; then | |
c5bc0e81 | 819 | echo "/dev/${drivename}h /$hname ufs rw 1 5" >>etc/fstab |
f078e99d RG |
820 | fi |
821 | ||
362925ff AM |
822 | # cat /etc/disktab >etc/disktab.install |
823 | OIFS=$IFS | |
824 | IFS=' | |
825 | ' | |
826 | while read data; do | |
827 | echo $data | |
828 | done </etc/disktab >etc/disktab.install | |
829 | IFS=$OIFS | |
0d255f16 | 830 | |
362925ff AM |
831 | # cat << EOF >.profile |
832 | ( | |
919841f8 | 833 | echo "PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:/usr/distbin:.:" |
362925ff AM |
834 | echo "export PATH" |
835 | echo "HOME=/root" | |
836 | echo "export HOME" | |
837 | echo "TERM=pc3" | |
838 | echo "export TERM" | |
839 | echo "mount -at ufs" | |
840 | echo "echo" | |
43a91bf9 RG |
841 | echo "echo \"Insert second installation floppy in drive and\"" |
842 | echo "echo -n \"enter that drive's number (e.g. 0 or 1): [0] \"" | |
362925ff AM |
843 | echo "read resp junk" |
844 | echo "driveno=\${resp:-0}" | |
845 | echo "mount -o ro /dev/fd\${driveno}a /mnt" | |
846 | echo "cd /mnt" | |
847 | echo "install" | |
730f2c4e AM |
848 | echo "cd /" |
849 | echo "umount /mnt >/dev/null 2>&1" | |
850 | echo "echo" | |
83dff685 | 851 | echo "echo -n \"Install optional dos floppy? [n] \"" |
730f2c4e | 852 | echo "read resp junk" |
83dff685 | 853 | echo "case \"\$resp\" in" |
53c2fade | 854 | echo "y*|Y*)" |
83dff685 AM |
855 | echo " echo" |
856 | echo " echo \"Now insert third installation (dos) 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" | |
5ae4c83e | 862 | echo " cp /mnt/* /usr/distbin/ >/dev/null 2>&1" |
83dff685 AM |
863 | echo " sync" |
864 | echo " umount /mnt >/dev/null 2>&1" | |
865 | echo " ;;" | |
866 | echo "esac" | |
730f2c4e | 867 | echo "echo" |
43a91bf9 | 868 | echo "echo \"OK. All of the base files are installed.\"" |
730f2c4e | 869 | echo "echo" |
43a91bf9 RG |
870 | echo "echo \"The next step: reboot from the hard disk, and follow\"" |
871 | echo "echo \"more instrutctions.\"" | |
730f2c4e | 872 | echo "echo" |
43a91bf9 | 873 | echo "echo \"To do this, enter 'halt' at the prompt to halt the machine.\"" |
730f2c4e AM |
874 | echo "echo \"Once the machine has halted, remove the floppy from the disk\"" |
875 | echo "echo \"drive, and hit any key to reboot from the hard disk.\"" | |
362925ff | 876 | ) >.profile |
f078e99d RG |
877 | |
878 | sync | |
879 | ||
362925ff | 880 | echo |
43a91bf9 RG |
881 | echo "The next step: reboot from the kernel-copy disk, copy a kernel" |
882 | echo "to the hard disk, and finally reboot from the hard disk." | |
362925ff | 883 | echo |
43a91bf9 | 884 | echo "To do this, enter 'halt' now to halt the machine. After it" |
21a421ff AM |
885 | echo "announces that it has halted, remove the floppy from the drive" |
886 | echo "and insert the kernel-copy disk that was booted before." | |
730f2c4e AM |
887 | echo "Press any key to reboot. When prompted to insert the filesystem" |
888 | echo "floppy this time, just hit RETURN without changing floppies." | |
362925ff AM |
889 | echo |
890 | echo "If all goes well, you can enter the command \`copy' at the prompt to" | |
891 | echo "copy the kernel to the hard disk. When asked for which partition to" | |
892 | echo "copy to, enter to \`${drivename}a' (without the quotes)." | |
893 | echo | |
21a421ff | 894 | echo "Okay, that's all for now. I'm waiting for you to enter \`halt'..." |