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