The scsi cd.c driver is now fully dynamic. You can change the lines
[unix-history] / etc / etc.i386 / inst1.install
CommitLineData
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 7OPSYSTEM=FreeBSD
362925ff
AM
8OPSYSID=165
9ROOTMIN=7
10SWAPMIN=8
11DISKMIN=`expr $ROOTMIN + $SWAPMIN + 1`
0d255f16 12DEFBLOCKING=2
8231ed99
RG
13DEFSECT=17
14DEFHEAD=12
15DEFCYLN=1024
362925ff 16RUN_FDISK=""
f078e99d 17
362925ff
AM
18set_arbitrary_defaults() {
19cyls_per_disk=$DEFCYLN
20tracks_per_cyl=$DEFHEAD
21sects_per_track=$DEFSECT
22unused_last_part=3
23part_cnt=4
24}
25
26
27get_fdisk_data() {
28cyls_per_disk=
29part_id=
30got_sysid=
31part_cnt=0
32sysid_cnt=0
33have_opsys_part=
34unused_last_part=
35extent_max=0
36extent_max_part=
37
38fdisk /dev/r${drivename}d >fdisk.out 2>fdisk.err
39if [ $? -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
45elif [ -s fdisk.err ]; then
46 echo "Disk doesn't appear to be initialized..."
47 no_part_table=1
21a421ff 48fi
362925ff
AM
49while 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
102done <fdisk.out
103if [ ! "$cyls_per_disk" ]; then
104 set_arbitrary_defaults
105 return 2
106fi
107>fdisk.out
108>fdisk.err
109return 0
110}
111
112analyze_fdisk_data() {
113# Case I: >1024 cylinders
114force_offset=
115if [ $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 142fi
362925ff 143# Case II: no partitions used
730f2c4e 144if [ $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
155elif [ "$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
185fi
186
187# Case IIIb: no partitions available
188if [ $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
207fi
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
215opsys_part=${unused_last_part}
216RUN_FDISK="fdisk -u"
217mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
218disk_minimum=`expr $DISKMIN \* $mb_sect`
219
220# Case IV: No room (at end of disk) for mininal install
221disk_remaining=`expr $disksize - $extent_max`
222if [ $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
248fi
249
250# Case V: Room for $OPSYSTEM and partition data okay
251opsys_off=`expr $extent_max / $cylindersize`
252opsys_extent=`expr $opsys_off \* $cylindersize`
253[ $opsys_extent -lt $extent_max ] && opsys_off=`expr $opsys_off + 1`
254cyls_per_opsys=`expr $cyls_per_disk - $opsys_off`
255return 0
256}
257
258put_fdisk_data() {
259start=$root_offset
260size=$partition
261
262if [ "$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
294elif [ "$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
312fi
313
314}
315
316echo "Welcome to ${OPSYSTEM}."
317echo
318echo "This program is designed to help put ${OPSYSTEM} on a hard disk with"
319echo "at least $DISKMIN Megabytes of free space."
320echo
321echo "If other operating systems are already on the disk, ${OPSYSTEM}"
322echo "should be able to install alongside them. Otherwise, if the disk"
323echo "is being installed for the first time, it would probably be useful"
324echo "to have the disk's hardware manual, the installation notes, and a"
325echo "calculator handy."
326echo
327echo "As with anything which modifies a hard drive's contents, this"
328echo "program can cause SIGNIFICANT data loss, and we strongly recommend"
329echo "making sure that the hard drive is backed up before going further with"
330echo "the installation process."
331echo
332echo -n "Proceed with installation? [y] "
333read resp junk
334resp=${resp:-y}
335case "$resp" in
336y*|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 352esac
c5bc0e81 353
362925ff
AM
354mount -u /dev/fd0a /
355sync
ede9f473 356verified_install=""
362925ff 357while [ ! "$verified_install" ]; do # Begin of Big Loop
ede9f473 358
c5bc0e81
RG
359rotdelay=""
360drivename=wd0
361drivetype=wd
362sect_fwd=""
362925ff
AM
363echo
364echo "First, we need to know the drive type. This can be can be one of"
21a421ff 365echo "ESDI, SCSI, ST506, or IDE."
362925ff
AM
366echo -n "Drive type? [${type:-IDE}] "
367read resp junk
368type=${resp:-${type:-IDE}}
f078e99d 369case "$type" in
362925ff
AM
370e*|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 ;;
384i*|I*)
385 type=ST506
386 rotdelay="-d 0"
387 ;;
388sc*|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 400esac
362925ff
AM
401echo
402echo "Disk is of device type $drivetype."
403echo
404echo -n "Number of bytes per disk sector? [${bytes_per_sect:-512}] "
405read resp junk
406bytes_per_sect=${resp:-${bytes_per_sect:-512}}
407if [ ! "$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
428fi
429echo
21a421ff
AM
430echo "Now we want to build a data base entry in /etc/disktab describing"
431echo "the geometry of the /dev/$drivename disk. The name of the entry"
432echo "should be descriptive of the disk's type and model. For example,"
433echo "a Maxtor IDE, model 7080 disk might be named \`maxtor7080'."
362925ff
AM
434echo -n "Disk label name (one word, please)? [${name:-mfr_model}] "
435read resp junk
436name=${resp:-${name:-mfr_model}}
437echo
438echo -n "Total number of disk cylinders? [${cyls_per_disk:-${DEFCYLN}}] "
439read resp junk
440cyls_per_disk=${resp:-${cyls_per_disk:-${DEFCYLN}}}
441echo
442echo -n "Number of disk heads (i.e., tracks/cylinder)? [${tracks_per_cyl:-${DEFHEAD}}] "
443read resp junk
444tracks_per_cyl=${resp:-${tracks_per_cyl:-${DEFHEAD}}}
445echo
446echo -n "Number of disk sectors (i.e., sectors/track)? [${sects_per_track:-${DEFSECT}}] "
447read resp junk
448sects_per_track=${resp:-${sects_per_track:-${DEFSECT}}}
f078e99d
RG
449cylindersize=`expr $sects_per_track \* $tracks_per_cyl`
450disksize=`expr $cylindersize \* $cyls_per_disk`
21a421ff
AM
451mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
452mb_per_disk=`expr $disksize / $mb_sect`
362925ff
AM
453opsys_cyls_min=`expr $DISKMIN \* $mb_sect / $cylindersize`
454analyze_fdisk_data
455if [ $? -eq 0 ]; then
456 partition=`expr $cyls_per_opsys \* $cylindersize`
457 part_offset=`expr $opsys_off \* $cylindersize`
21a421ff 458fi
362925ff
AM
459echo
460echo "Disk has a total of $mb_per_disk Mb."
461echo "The size of the ${OPSYSTEM} portion of the disk must be at least"
462echo "${opsys_cyls_min} cylinders, and should not exceed $(expr $cyls_per_disk - 1) cylinders."
463echo "The offset of ${OPSYSTEM} from the beginning of the disk should be at"
464echo "least 1 cylinder."
465echo
466echo "For efficiency, partitions begin and end on cylinder boundaries."
467echo "If you know the size NN in Megabytes (Mb) of a partition you want, then"
468echo "use the following formula to determine the number NC of cylinders to use:"
469echo " NC = integer { ( NN * $mb_sect ) / $cylindersize }"
470while :; 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
499done
f078e99d
RG
500badspacesec=0
501if [ "$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"
509fi
510whats_left=`expr $partition - $badspacesec`
511cyl_left=`expr $whats_left / $cylindersize`
21a421ff 512mb_left=`expr $whats_left / $mb_sect`
362925ff
AM
513swap_cyls_min=`expr $SWAPMIN \* $mb_sect / $cylindersize`
514root_cyls_max=`expr ${cyl_left} - ${swap_cyls_min}`
515root_cyls_min=`expr $ROOTMIN \* $mb_sect / $cylindersize`
516echo
517echo "There are $mb_left Mb ($cyl_left cylinders) to allocate."
518echo
519echo "The $OPSYSTEM portion of the disk must itself be divided into at least"
520echo "two partitions: one for the root filesystem and one for swap. It is a"
521echo "good idea to have at least a third (large) $OPSYSTEM partition for the /usr"
522echo "filesystem."
523echo
524echo "The root partition cannot exceed ${root_cyls_max} cylinders. It is usually"
525echo "no larger than about 15 Mb ($(expr 15 \* $mb_sect / $cylindersize) cylinders), and sometimes"
526echo "as small as $ROOTMIN Mb ($root_cyls_min cylinders)."
527if [ ! "$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 531fi
362925ff
AM
532while :; 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
547done
548root_offset=$part_offset
549whats_left=`expr $partition - $part_used`
21a421ff
AM
550cyl_left=`expr $whats_left / $cylindersize`
551mb_left=`expr $whats_left / $mb_sect`
362925ff 552echo
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#
556echo "We can build the filesystems with block/fragment sizes of either"
21a421ff
AM
557echo " 1) 4k/512, to save disk space at the expense of speed, or"
558echo " 2) 8k/1k for speed at the expense of disk space."
0d255f16 559echo -n "Which blocking factor should we use for the filesystems? "
362925ff
AM
560echo -n "[${blocking_factor:-${DEFBLOCKING}}] "
561read resp junk
562blocking_factor=${resp:-${blocking_factor:-${DEFBLOCKING}}}
21a421ff
AM
563fragsize=`expr $bytes_per_sect \* $blocking_factor`
564blocksize=`expr $bytes_per_sect \* $blocking_factor \* 8`
362925ff
AM
565echo
566echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk."
567echo
568echo "Minimum swap space is ${swap_cyls_min} cylinders."
569echo "For running X, if your RAM size is NR Mb, then the recomended swap"
570echo "size NS (in cylinders) is:"
571echo " NS = integer { ( NR x `expr 21 \* $mb_sect / 10` ) / ${cylindersize} }"
572if [ ! "$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
583fi
584while :; 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 598done
362925ff 599echo
f078e99d
RG
600swap_offset=`expr $root_offset + $root`
601part_used=`expr $part_used + $swap`
362925ff
AM
602echo "" >/etc/disktab
603echo "$name|${OPSYSTEM} installation generated:\\" >>/etc/disktab
604echo " :dt=${type}:ty=winchester:\\" >>/etc/disktab
f078e99d 605echo -n " :nc#${cyls_per_disk}:ns#${sects_per_track}" >>/etc/disktab
362925ff
AM
606echo ":nt#${tracks_per_cyl}:\\" >>/etc/disktab
607echo " :se#${bytes_per_sect}:${sect_fwd}\\" >>/etc/disktab
f078e99d 608echo -n " :pa#${root}:oa#${root_offset}" >>/etc/disktab
362925ff
AM
609echo ":ta=4.2BSD:ba#${blocksize}:fa#${fragsize}:\\" >>/etc/disktab
610echo " :pb#${swap}:ob#${swap_offset}:tb=swap:\\" >>/etc/disktab
611echo " :pc#${partition}:oc#${part_offset}:\\" >>/etc/disktab
f078e99d 612ename="";fname="";gname="";hname=""
362925ff
AM
613if [ $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."
619fi
f078e99d
RG
620while [ $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
673done
674
362925ff 675echo " :pd#${disksize}:od#0:" >>/etc/disktab
f078e99d
RG
676sync
677
362925ff
AM
678# cat /etc/disktab
679OIFS=$IFS
680IFS='
681'
682while read data; do
683 echo $data
684done < /etc/disktab
685IFS=$OIFS
686
687echo
8231ed99
RG
688echo -n "Verbose installation? [n] "
689read resp
690
691case $resp in
362925ff
AM
692y*)
693 cpioverbose=v
694 ;;
695*)
696 cpioverbose=
697 ;;
8231ed99
RG
698esac
699
362925ff
AM
700
701echo
702echo "OK! THIS IS THE LAST CHANCE!!! Data on the hard disk wil be lost."
21a421ff 703echo -n "Are you sure you want to install on the hard drive? (yes/no) "
362925ff
AM
704resp=""
705while [ ! "$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
736done
ede9f473
AM
737done # End of Big Loop
738
362925ff
AM
739put_fdisk_data
740
741echo
f078e99d 742echo -n "Labelling disk..."
362925ff
AM
743echo y |
744/sbin/disklabel -w -r ${drivename} $name /usr/mdec/${drivetype}boot /usr/mdec/boot${drivetype} >/dev/null 2>&1
745echo " done."
f078e99d
RG
746
747if [ "$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
765fi
766
362925ff 767echo "Initializing root filesystem, and mounting..."
c5bc0e81 768newfs ${rotdelay} /dev/r${drivename}a $name
f078e99d
RG
769mount -v /dev/${drivename}a /mnt
770if [ "$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
776fi
777if [ "$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
783fi
784if [ "$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
790fi
791if [ "$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
797fi
798
8231ed99 799echo
362925ff 800echo "Please wait. Copying to disk..."
f078e99d 801cd /
362925ff
AM
802# cat filelist | cpio -pdamu${cpioverbose} /mnt
803OIFS=$IFS
804IFS='
805'
806while read data; do
807 echo $data
808done <filelist | cpio -pdamu${cpioverbose} /mnt
809IFS=$OIFS
0d255f16 810sync
f078e99d
RG
811
812cd /mnt
c5bc0e81 813echo "/dev/${drivename}a / ufs rw 1 1" >etc/fstab
f078e99d 814if [ "$ename" != "" ]; then
c5bc0e81 815 echo "/dev/${drivename}e /$ename ufs rw 1 2" >>etc/fstab
f078e99d
RG
816fi
817if [ "$fname" != "" ]; then
c5bc0e81 818 echo "/dev/${drivename}f /$fname ufs rw 1 3" >>etc/fstab
f078e99d
RG
819fi
820if [ "$gname" != "" ]; then
c5bc0e81 821 echo "/dev/${drivename}g /$gname ufs rw 1 4" >>etc/fstab
f078e99d
RG
822fi
823if [ "$hname" != "" ]; then
c5bc0e81 824 echo "/dev/${drivename}h /$hname ufs rw 1 5" >>etc/fstab
f078e99d
RG
825fi
826
362925ff
AM
827# cat /etc/disktab >etc/disktab.install
828OIFS=$IFS
829IFS='
830'
831while read data; do
832 echo $data
833done </etc/disktab >etc/disktab.install
834IFS=$OIFS
0d255f16 835
362925ff
AM
836# cat << EOF >.profile
837(
919841f8 838echo "PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:/usr/distbin:.:"
362925ff
AM
839echo "export PATH"
840echo "HOME=/root"
841echo "export HOME"
842echo "TERM=pc3"
843echo "export TERM"
844echo "mount -at ufs"
845echo "echo"
846echo "echo \"Insert second installation floppy in drive and\""
847echo "echo -n \"enter that drive's number (e.g. 0 or 1): [0] \""
848echo "read resp junk"
849echo "driveno=\${resp:-0}"
850echo "mount -o ro /dev/fd\${driveno}a /mnt"
851echo "cd /mnt"
852echo "install"
730f2c4e
AM
853echo "cd /"
854echo "umount /mnt >/dev/null 2>&1"
855echo "echo"
856echo "echo \"Now insert third installation floppy in drive and\""
857echo "echo -n \"enter that drive's number (e.g. 0 or 1): [0] \""
858echo "read resp junk"
859echo "driveno=\${resp:-0}"
860echo "mount -t pcfs -o ro /dev/fd\${driveno}a /mnt"
861echo "mkdir -p /usr/distbin"
862echo "cp /mnt/* /usr/distbin/"
919841f8 863echo "sync"
730f2c4e
AM
864echo "umount /mnt >/dev/null 2>&1"
865echo "echo"
866echo "echo \"OK. All of the base files are installed.\""
867echo "echo"
868echo "echo \"The next step: reboot from the hard disk, and follow\""
869echo "echo \"more instrutctions.\""
870echo "echo"
871echo "echo \"To do this, enter 'halt' at the prompt to halt the machine.\""
872echo "echo \"Once the machine has halted, remove the floppy from the disk\""
873echo "echo \"drive, and hit any key to reboot from the hard disk.\""
362925ff 874) >.profile
f078e99d
RG
875
876sync
877
362925ff
AM
878echo
879echo "The next step: reboot from the kernel-copy disk, copy a kernel"
880echo "to the hard disk, and finally reboot from the hard disk."
881echo
882echo "To do this, enter 'halt' now to halt the machine. After it"
21a421ff
AM
883echo "announces that it has halted, remove the floppy from the drive"
884echo "and insert the kernel-copy disk that was booted before."
730f2c4e
AM
885echo "Press any key to reboot. When prompted to insert the filesystem"
886echo "floppy this time, just hit RETURN without changing floppies."
362925ff
AM
887echo
888echo "If all goes well, you can enter the command \`copy' at the prompt to"
889echo "copy the kernel to the hard disk. When asked for which partition to"
890echo "copy to, enter to \`${drivename}a' (without the quotes)."
891echo
21a421ff 892echo "Okay, that's all for now. I'm waiting for you to enter \`halt'..."