Only put var and var/tmp in the cpio archive floppy, do not really need
[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#
d39e7451 7PATH=/sbin:/bin:/usr/bin:/usr/sbin:.
56164db9 8export PATH
d39e7451 9
c5bc0e81 10OPSYSTEM=FreeBSD
362925ff
AM
11OPSYSID=165
12ROOTMIN=7
13SWAPMIN=8
14DISKMIN=`expr $ROOTMIN + $SWAPMIN + 1`
0d255f16 15DEFBLOCKING=2
8231ed99
RG
16DEFSECT=17
17DEFHEAD=12
18DEFCYLN=1024
362925ff 19RUN_FDISK=""
f078e99d 20
362925ff
AM
21set_arbitrary_defaults() {
22cyls_per_disk=$DEFCYLN
23tracks_per_cyl=$DEFHEAD
24sects_per_track=$DEFSECT
25unused_last_part=3
26part_cnt=4
27}
28
29
30get_fdisk_data() {
31cyls_per_disk=
32part_id=
33got_sysid=
34part_cnt=0
35sysid_cnt=0
36have_opsys_part=
37unused_last_part=
38extent_max=0
39extent_max_part=
40
41fdisk /dev/r${drivename}d >fdisk.out 2>fdisk.err
42if [ $? -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
48elif [ -s fdisk.err ]; then
49 echo "Disk doesn't appear to be initialized..."
50 no_part_table=1
21a421ff 51fi
362925ff
AM
52while 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
97done <fdisk.out
98if [ ! "$cyls_per_disk" ]; then
99 set_arbitrary_defaults
100 return 2
101fi
102>fdisk.out
103>fdisk.err
104return 0
105}
106
107analyze_fdisk_data() {
108# Case I: >1024 cylinders
109force_offset=
110if [ $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 138fi
362925ff 139# Case II: no partitions used
730f2c4e 140if [ $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
151elif [ "$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
181fi
182
183# Case IIIb: no partitions available
184if [ $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
203fi
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
211opsys_part=${unused_last_part}
212RUN_FDISK="fdisk -u"
213mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
214disk_minimum=`expr $DISKMIN \* $mb_sect`
215
216# Case IV: No room (at end of disk) for mininal install
217disk_remaining=`expr $disksize - $extent_max`
218if [ $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
244fi
245
246# Case V: Room for $OPSYSTEM and partition data okay
247opsys_off=`expr $extent_max / $cylindersize`
248opsys_extent=`expr $opsys_off \* $cylindersize`
249[ $opsys_extent -lt $extent_max ] && opsys_off=`expr $opsys_off + 1`
250cyls_per_opsys=`expr $cyls_per_disk - $opsys_off`
251return 0
252}
253
254put_fdisk_data() {
255start=$root_offset
256size=$partition
257
258if [ "$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
290elif [ "$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
308fi
309
310}
311
43a91bf9 312echo "Welcome to ${OPSYSTEM}."
362925ff 313echo
43a91bf9 314echo "This program is designed to help put ${OPSYSTEM} on a hard disk with"
362925ff
AM
315echo "at least $DISKMIN Megabytes of free space."
316echo
317echo "If other operating systems are already on the disk, ${OPSYSTEM}"
318echo "should be able to install alongside them. Otherwise, if the disk"
319echo "is being installed for the first time, it would probably be useful"
320echo "to have the disk's hardware manual, the installation notes, and a"
321echo "calculator handy."
322echo
323echo "As with anything which modifies a hard drive's contents, this"
324echo "program can cause SIGNIFICANT data loss, and we strongly recommend"
325echo "making sure that the hard drive is backed up before going further with"
326echo "the installation process."
327echo
328echo -n "Proceed with installation? [y] "
329read resp junk
330resp=${resp:-y}
331case "$resp" in
332y*|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 348esac
c5bc0e81 349
362925ff
AM
350mount -u /dev/fd0a /
351sync
ede9f473 352verified_install=""
362925ff 353while [ ! "$verified_install" ]; do # Begin of Big Loop
ede9f473 354
c5bc0e81
RG
355rotdelay=""
356drivename=wd0
357drivetype=wd
358sect_fwd=""
362925ff 359echo
43a91bf9 360echo "First, we need to know the drive type. This can be can be one of"
21a421ff 361echo "ESDI, SCSI, ST506, or IDE."
362925ff
AM
362echo -n "Drive type? [${type:-IDE}] "
363read resp junk
364type=${resp:-${type:-IDE}}
f078e99d 365case "$type" in
362925ff
AM
366e*|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 ;;
380i*|I*)
381 type=ST506
382 rotdelay="-d 0"
383 ;;
384sc*|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 396esac
362925ff 397echo
43a91bf9 398echo "Disk is of device type $drivetype."
362925ff
AM
399if [ ! "$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
422fi
423echo
21a421ff
AM
424echo "Now we want to build a data base entry in /etc/disktab describing"
425echo "the geometry of the /dev/$drivename disk. The name of the entry"
426echo "should be descriptive of the disk's type and model. For example,"
427echo "a Maxtor IDE, model 7080 disk might be named \`maxtor7080'."
362925ff
AM
428echo -n "Disk label name (one word, please)? [${name:-mfr_model}] "
429read resp junk
430name=${resp:-${name:-mfr_model}}
431echo
1f49206c
AM
432echo -n "Number of bytes per disk sector? [${bytes_per_sect:-512}] "
433read resp junk
434bytes_per_sect=${resp:-${bytes_per_sect:-512}}
435echo
362925ff
AM
436echo -n "Total number of disk cylinders? [${cyls_per_disk:-${DEFCYLN}}] "
437read resp junk
438cyls_per_disk=${resp:-${cyls_per_disk:-${DEFCYLN}}}
439echo
440echo -n "Number of disk heads (i.e., tracks/cylinder)? [${tracks_per_cyl:-${DEFHEAD}}] "
441read resp junk
442tracks_per_cyl=${resp:-${tracks_per_cyl:-${DEFHEAD}}}
443echo
444echo -n "Number of disk sectors (i.e., sectors/track)? [${sects_per_track:-${DEFSECT}}] "
445read resp junk
446sects_per_track=${resp:-${sects_per_track:-${DEFSECT}}}
f078e99d
RG
447cylindersize=`expr $sects_per_track \* $tracks_per_cyl`
448disksize=`expr $cylindersize \* $cyls_per_disk`
21a421ff
AM
449mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
450mb_per_disk=`expr $disksize / $mb_sect`
362925ff
AM
451opsys_cyls_min=`expr $DISKMIN \* $mb_sect / $cylindersize`
452analyze_fdisk_data
453if [ $? -eq 0 ]; then
454 partition=`expr $cyls_per_opsys \* $cylindersize`
455 part_offset=`expr $opsys_off \* $cylindersize`
21a421ff 456fi
362925ff
AM
457echo
458echo "Disk has a total of $mb_per_disk Mb."
459echo "The size of the ${OPSYSTEM} portion of the disk must be at least"
460echo "${opsys_cyls_min} cylinders, and should not exceed $(expr $cyls_per_disk - 1) cylinders."
461echo "The offset of ${OPSYSTEM} from the beginning of the disk should be at"
462echo "least 1 cylinder."
463echo
464echo "For efficiency, partitions begin and end on cylinder boundaries."
465echo "If you know the size NN in Megabytes (Mb) of a partition you want, then"
466echo "use the following formula to determine the number NC of cylinders to use:"
467echo " NC = integer { ( NN * $mb_sect ) / $cylindersize }"
468while :; 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
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 565echo
43a91bf9 566echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk."
362925ff
AM
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`
43a91bf9
RG
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
43a91bf9
RG
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
43a91bf9
RG
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 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
673done
674
43a91bf9 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
43a91bf9 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
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
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
43a91bf9 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...
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
761fi
762
43a91bf9 763echo "Initializing root filesystem, and mounting..."
c5bc0e81 764newfs ${rotdelay} /dev/r${drivename}a $name
f078e99d
RG
765mount -v /dev/${drivename}a /mnt
766if [ "$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
772fi
773if [ "$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
779fi
780if [ "$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
786fi
787if [ "$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
793fi
794
8231ed99 795echo
362925ff 796echo "Please wait. Copying to disk..."
f078e99d 797cd /
362925ff
AM
798# cat filelist | cpio -pdamu${cpioverbose} /mnt
799OIFS=$IFS
800IFS='
801'
802while read data; do
803 echo $data
804done <filelist | cpio -pdamu${cpioverbose} /mnt
805IFS=$OIFS
f078e99d
RG
806
807cd /mnt
c5bc0e81 808echo "/dev/${drivename}a / ufs rw 1 1" >etc/fstab
f078e99d 809if [ "$ename" != "" ]; then
c5bc0e81 810 echo "/dev/${drivename}e /$ename ufs rw 1 2" >>etc/fstab
f078e99d
RG
811fi
812if [ "$fname" != "" ]; then
c5bc0e81 813 echo "/dev/${drivename}f /$fname ufs rw 1 3" >>etc/fstab
f078e99d
RG
814fi
815if [ "$gname" != "" ]; then
c5bc0e81 816 echo "/dev/${drivename}g /$gname ufs rw 1 4" >>etc/fstab
f078e99d
RG
817fi
818if [ "$hname" != "" ]; then
c5bc0e81 819 echo "/dev/${drivename}h /$hname ufs rw 1 5" >>etc/fstab
f078e99d
RG
820fi
821
362925ff
AM
822# cat /etc/disktab >etc/disktab.install
823OIFS=$IFS
824IFS='
825'
826while read data; do
827 echo $data
828done </etc/disktab >etc/disktab.install
829IFS=$OIFS
0d255f16 830
362925ff
AM
831# cat << EOF >.profile
832(
919841f8 833echo "PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:/usr/distbin:.:"
362925ff
AM
834echo "export PATH"
835echo "HOME=/root"
836echo "export HOME"
837echo "TERM=pc3"
838echo "export TERM"
839echo "mount -at ufs"
840echo "echo"
43a91bf9
RG
841echo "echo \"Insert second installation floppy in drive and\""
842echo "echo -n \"enter that drive's number (e.g. 0 or 1): [0] \""
362925ff
AM
843echo "read resp junk"
844echo "driveno=\${resp:-0}"
845echo "mount -o ro /dev/fd\${driveno}a /mnt"
846echo "cd /mnt"
847echo "install"
730f2c4e
AM
848echo "cd /"
849echo "umount /mnt >/dev/null 2>&1"
850echo "echo"
83dff685 851echo "echo -n \"Install optional dos floppy? [n] \""
730f2c4e 852echo "read resp junk"
83dff685 853echo "case \"\$resp\" in"
53c2fade 854echo "y*|Y*)"
83dff685
AM
855echo " echo"
856echo " echo \"Now insert third installation (dos) 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"
5ae4c83e 862echo " cp /mnt/* /usr/distbin/ >/dev/null 2>&1"
83dff685
AM
863echo " sync"
864echo " umount /mnt >/dev/null 2>&1"
865echo " ;;"
866echo "esac"
730f2c4e 867echo "echo"
43a91bf9 868echo "echo \"OK. All of the base files are installed.\""
730f2c4e 869echo "echo"
43a91bf9
RG
870echo "echo \"The next step: reboot from the hard disk, and follow\""
871echo "echo \"more instrutctions.\""
730f2c4e 872echo "echo"
43a91bf9 873echo "echo \"To do this, enter 'halt' at the prompt to halt the machine.\""
730f2c4e
AM
874echo "echo \"Once the machine has halted, remove the floppy from the disk\""
875echo "echo \"drive, and hit any key to reboot from the hard disk.\""
362925ff 876) >.profile
f078e99d
RG
877
878sync
879
362925ff 880echo
43a91bf9
RG
881echo "The next step: reboot from the kernel-copy disk, copy a kernel"
882echo "to the hard disk, and finally reboot from the hard disk."
362925ff 883echo
43a91bf9 884echo "To do this, enter 'halt' now to halt the machine. After it"
21a421ff
AM
885echo "announces that it has halted, remove the floppy from the drive"
886echo "and insert the kernel-copy disk that was booted before."
730f2c4e
AM
887echo "Press any key to reboot. When prompted to insert the filesystem"
888echo "floppy this time, just hit RETURN without changing floppies."
362925ff
AM
889echo
890echo "If all goes well, you can enter the command \`copy' at the prompt to"
891echo "copy the kernel to the hard disk. When asked for which partition to"
892echo "copy to, enter to \`${drivename}a' (without the quotes)."
893echo
21a421ff 894echo "Okay, that's all for now. I'm waiting for you to enter \`halt'..."