Major hackery to get the 1.1 Beta floppies building. Have a special
[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!"
f1002c06
AM
229 echo "${OPSYSTEM} cannot be installed alongside an existing BSD partition."
230 echo -n "Overwrite existing partition? [y] "
362925ff 231 read resp junk
f1002c06 232 case "${resp:-y}" in
362925ff 233 y*|Y*)
362925ff 234 opsys_part=${have_opsys_part}
691e6212 235 set_existing_part
362925ff
AM
236 return 0
237 ;;
238 *)
f1002c06
AM
239 echo
240 echo "Installation aborted. Enter \`halt' to halt the machine."
241 echo "Once the machine has halted, remove the floppy,"
242 echo "and press any key to reboot."
243 exit
362925ff
AM
244 ;;
245 esac
246fi
247
248# Case IIIb: no partitions available
249if [ $sysid_cnt -eq $part_cnt -a ! "$have_opsys_part" ]; then
250 echo
251 echo "No unused partitions."
362925ff
AM
252 echo -n "Install $OPSYSTEM and overwrite the entire disk? [n] "
253 read resp junk
254 case "$resp" in
255 y*|Y*)
256 # don't use first cylinder!
257 opsys_off=1
258 cyls_per_opsys=`expr $cyls_per_disk - 1`
259 opsys_part=${unused_last_part}
260 RUN_FDISK="overwrite"
362925ff
AM
261 ;;
262 *)
691e6212 263 set_overwrite_part
362925ff
AM
264 ;;
265 esac
691e6212 266 return 0
362925ff
AM
267fi
268
269
270# *** CAVEAT ***
271# $OPSYSTEM installs at the end of the disk. If the
272# beginning of the disk is free but not the end, install fails!
273
274# Assume `fdisk -u' to add $OPSYSTEM in last unused partition for remaining cases
275opsys_part=${unused_last_part}
276RUN_FDISK="fdisk -u"
277mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
278disk_minimum=`expr $DISKMIN \* $mb_sect`
279
280# Case IV: No room (at end of disk) for mininal install
691e6212 281[ $extent_max -eq 50000 ] && extent_max=$disksize
362925ff
AM
282disk_remaining=`expr $disksize - $extent_max`
283if [ $disk_remaining -lt $disk_minimum ]; then
284 echo
285 echo "Not enough space ($DISKMIN Mb) at end of disk to install $OPSYSTEM."
286 echo -n "Install FreeBSD and overwrite the entire disk? [n] "
287 read resp junk
288 case "$resp" in
289 y*|Y*)
290 # don't use first cylinder!
291 opsys_off=1
292 cyls_per_opsys=`expr $cyls_per_disk - 1`
293 opsys_part=${unused_last_part}
294 RUN_FDISK="overwrite"
f078e99d
RG
295 ;;
296 *)
362925ff 297 echo
691e6212
AM
298 echo -n "Overwrite an existing partition? [n] "
299 read resp junk
300 case "$resp" in
301 y*|Y*)
302 set_overwrite_part
303 ;;
304 *)
305 echo
306 echo " WARNING: To install ${OPSYSTEM}, you're on your own in figuring"
307 echo " out where on the disk it will fit without overwriting another"
308 echo " partition..."
309 # Set defaults assuming there is only one partition at end of disk
310 eval start=\$start${extent_max_part}
311 # don't use first cylinder!
312 opsys_off=1
313 cyls_per_opsys=`expr $start / $cylindersize - 1`
314 [ $cyls_per_opsys -lt 0 ] && cyls_per_opsys=0
315 ;;
316 esac
f078e99d 317 ;;
362925ff
AM
318 esac
319 return 0
320fi
321
322# Case V: Room for $OPSYSTEM and partition data okay
323opsys_off=`expr $extent_max / $cylindersize`
324opsys_extent=`expr $opsys_off \* $cylindersize`
325[ $opsys_extent -lt $extent_max ] && opsys_off=`expr $opsys_off + 1`
326cyls_per_opsys=`expr $cyls_per_disk - $opsys_off`
327return 0
328}
329
330put_fdisk_data() {
331start=$root_offset
332size=$partition
333
334if [ "$RUN_FDISK" = "overwrite" ]; then
335 # How do you overwrite without explicitly editing each entry?
336 (
337 echo y
338 echo $cyls_per_disk
339 echo $tracks_per_cyl
340 echo $sects_per_track
341 echo y
342 ) >fdisk.script
343 i=0
344 n=`expr ${part_cnt:-4} - 1`
345 while [ $i -lt $n ]; do
346 echo y
347 echo 0
348 echo 0
349 echo 0
350 echo n
351 echo y
352 i=`expr $i + 1`
353 done >>fdisk.script
354 ( echo y
355 echo ${OPSYSID}
356 echo ${start}
357 echo ${size}
358 echo n
359 echo y
360 echo y
361 echo ${n}
362 echo y
363 echo y
364 ) >>fdisk.script
a631d31f 365 fdisk -u /dev/r${drivename}d <fdisk.script >/dev/null 2>&1
362925ff 366elif [ "$RUN_FDISK" ]; then
a631d31f 367 $RUN_FDISK -${opsys_part:-${unused_last_part:-3}} /dev/r${drivename}d <<-EOF >/dev/null 2>&1
362925ff
AM
368 y
369 $cyls_per_disk
370 $tracks_per_cyl
371 $sects_per_track
372 y
373 y
374 ${OPSYSID}
375 ${start}
376 ${size}
377 n
378 y
379 y
380 ${opsys_part:-${unused_last_part:-3}}
381 y
382 y
383 EOF
384fi
385
386}
387
635dcafb
RG
388echo
389echo
43a91bf9 390echo "Welcome to ${OPSYSTEM}."
362925ff 391echo
43a91bf9 392echo "This program is designed to help put ${OPSYSTEM} on a hard disk with"
362925ff
AM
393echo "at least $DISKMIN Megabytes of free space."
394echo
e72bf634
AM
395echo "Before starting, it is important to know your hard disk's geometry"
396echo "(i.e., number of cylinders, heads and sectors/track). If installing"
397echo "${OPSYSTEM} on the same disk as another operating system, then the"
398echo "two systems should use the same geometry. In particular, ${OPSYSTEM}'s"
399echo "default geometry is inappropriate for MS-DOS. So in this case, the"
400echo "DOS geometry should be used instead."
362925ff 401echo
e72bf634
AM
402echo "As with anything which modifies a hard drive's contents, this program"
403echo "can cause SIGNIFICANT data loss. We strongly recommend making sure"
404echo "that the hard drive is backed up before going further with the"
405echo "installation process."
362925ff
AM
406echo
407echo -n "Proceed with installation? [y] "
408read resp junk
409resp=${resp:-y}
410case "$resp" in
411y*|Y*)
412 echo
43a91bf9 413 echo "Cool! Let's get to it..."
362925ff
AM
414 echo
415 echo "If a mistake is made along the way, don't bail out."
e72bf634 416 echo "At the end, you have the option of redoing the configuration."
362925ff
AM
417 echo "If you really must quit at some point, type <CTRL>+C and"
418 echo "enter \`halt' at the command prompt, \`#'."
419 ;;
420*)
421 echo
f1002c06 422 echo "Installation aborted. Enter \`halt' to halt the machine."
43a91bf9
RG
423 echo "Once the machine has halted, remove the floppy,"
424 echo "and press any key to reboot."
362925ff
AM
425 exit
426 ;;
f078e99d 427esac
c5bc0e81 428
c29d28fa
RG
429mount -u /dev/fd0 / || {
430 if mount -u /dev/fd1 / ; then
2010ccbf
CR
431 echo "[Please ignore the above error message, that's normal.]"
432 else
433 echo "Oh boy, we're in trouble here: Could not mount floppy read-write."
434 exit 1
435 fi
436}
362925ff 437sync
ede9f473 438verified_install=""
362925ff 439while [ ! "$verified_install" ]; do # Begin of Big Loop
ede9f473 440
c5bc0e81
RG
441rotdelay=""
442drivename=wd0
443drivetype=wd
444sect_fwd=""
362925ff 445echo
43a91bf9 446echo "First, we need to know the drive type. This can be can be one of"
21a421ff 447echo "ESDI, SCSI, ST506, or IDE."
362925ff
AM
448echo -n "Drive type? [${type:-IDE}] "
449read resp junk
450type=${resp:-${type:-IDE}}
f078e99d 451case "$type" in
362925ff
AM
452e*|E*|st*|ST*)
453 echo -n "Does it support AUTOMATIC sector remapping? [y] "
454 read remap junk
455 case "$remap" in
456 n*|N*)
457 sect_fwd="sf:"
f078e99d 458 ;;
362925ff
AM
459 esac
460 case "$type" in
461 e*|E*)
462 DEFSECT=36
21a421ff 463 ;;
362925ff
AM
464 esac
465 ;;
466i*|I*)
467 type=ST506
468 rotdelay="-d 0"
469 ;;
470sc*|SC*)
471 drivename=sd0
472 drivetype=sd
473 type=SCSI
474 rotdelay="-d 0"
475 DEFSECT=32
476 DEFHEAD=64
477 ;;
478*)
479 echo "Unknown type. Assuming ST506 with automatic sectoring..."
480 type=ST506
481 ;;
f078e99d 482esac
362925ff 483echo
43a91bf9 484echo "Disk is of device type $drivetype."
362925ff
AM
485if [ ! "$partition" ]; then
486 echo
635dcafb 487 echo "Examining device /dev/r${drivename}d..."
362925ff
AM
488 get_fdisk_data
489 if [ $? -gt 1 ]; then
490 echo "Hm - we can't seem to read that drive."
491 echo
492 echo -n "Are you sure that $type is the correct type? [n] "
493 read resp
494 case "$resp" in
495 y*|Y*)
10b607dd 496 echo
362925ff
AM
497 echo "Well, since we can't even open it, there isn't much"
498 echo "hope for writing a label on it. But you're free"
499 echo "to give it a try. You need to specify the geometry."
500 ;;
501 *)
10b607dd 502 echo
f1002c06 503 echo "Oops. Let's start again from the top."
362925ff
AM
504 continue
505 ;;
506 esac
507 fi
508fi
509echo
21a421ff
AM
510echo "Now we want to build a data base entry in /etc/disktab describing"
511echo "the geometry of the /dev/$drivename disk. The name of the entry"
512echo "should be descriptive of the disk's type and model. For example,"
513echo "a Maxtor IDE, model 7080 disk might be named \`maxtor7080'."
362925ff
AM
514echo -n "Disk label name (one word, please)? [${name:-mfr_model}] "
515read resp junk
516name=${resp:-${name:-mfr_model}}
517echo
e72bf634
AM
518echo "${OPSYSTEM} should use the same hard disk geometry as used by other"
519echo "operating systems on the hard disk."
1f49206c
AM
520echo -n "Number of bytes per disk sector? [${bytes_per_sect:-512}] "
521read resp junk
522bytes_per_sect=${resp:-${bytes_per_sect:-512}}
523echo
362925ff
AM
524echo -n "Total number of disk cylinders? [${cyls_per_disk:-${DEFCYLN}}] "
525read resp junk
526cyls_per_disk=${resp:-${cyls_per_disk:-${DEFCYLN}}}
527echo
528echo -n "Number of disk heads (i.e., tracks/cylinder)? [${tracks_per_cyl:-${DEFHEAD}}] "
529read resp junk
530tracks_per_cyl=${resp:-${tracks_per_cyl:-${DEFHEAD}}}
531echo
532echo -n "Number of disk sectors (i.e., sectors/track)? [${sects_per_track:-${DEFSECT}}] "
533read resp junk
534sects_per_track=${resp:-${sects_per_track:-${DEFSECT}}}
f078e99d
RG
535cylindersize=`expr $sects_per_track \* $tracks_per_cyl`
536disksize=`expr $cylindersize \* $cyls_per_disk`
21a421ff
AM
537mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
538mb_per_disk=`expr $disksize / $mb_sect`
362925ff
AM
539opsys_cyls_min=`expr $DISKMIN \* $mb_sect / $cylindersize`
540analyze_fdisk_data
541if [ $? -eq 0 ]; then
542 partition=`expr $cyls_per_opsys \* $cylindersize`
543 part_offset=`expr $opsys_off \* $cylindersize`
21a421ff 544fi
362925ff
AM
545echo
546echo "Disk has a total of $mb_per_disk Mb."
547echo "The size of the ${OPSYSTEM} portion of the disk must be at least"
548echo "${opsys_cyls_min} cylinders, and should not exceed $(expr $cyls_per_disk - 1) cylinders."
549echo "The offset of ${OPSYSTEM} from the beginning of the disk should be at"
550echo "least 1 cylinder."
551echo
552echo "For efficiency, partitions begin and end on cylinder boundaries."
553echo "If you know the size NN in Megabytes (Mb) of a partition you want, then"
554echo "use the following formula to determine the number NC of cylinders to use:"
555echo " NC = integer { ( NN * $mb_sect ) / $cylindersize }"
556while :; do
557 echo -n "Total size of the ${OPSYSTEM} portion of the disk (in cylinders)? [${cyls_per_opsys:-`expr ${cyls_per_disk} - 1`}] "
558 read resp junk
559 cyls_per_opsys=${resp:-${cyls_per_opsys:-`expr ${cyls_per_disk} - 1`}}
560 partition=`expr $cyls_per_opsys \* $cylindersize`
561 if [ $cyls_per_opsys -lt $cyls_per_disk -a ! "$force_offset" ]; then
562 echo
563 echo -n "Offset of ${OPSYSTEM} from beginning of disk (in cylinders)? [${opsys_off:-1}] "
564 read resp junk
565 opsys_off=${resp:-${opsys_off:-1}}
566 else
567 echo
1f49206c
AM
568 echo " WARNING: Existing partitions will be lost. In addition,"
569 echo " installing at cylinder 0 may cause problems for some disk"
570 echo " controllers. If the filesystem is corrupted or install"
571 echo " fails, install at cylinder 1."
362925ff
AM
572 RUN_FDISK=""
573 cyls_per_opsys=$cyls_per_disk
574 partition=$disksize
575 opsys_off=0
21a421ff 576 fi
362925ff
AM
577 part_offset=`expr $opsys_off \* $cylindersize`
578 opsys_extent=`expr $opsys_off + $cyls_per_opsys`
579 if [ ${opsys_extent} -gt ${cyls_per_disk} ]; then
580 echo
581 echo "${OPSYSTEM} Size + Offset cannot exceed ${cyls_per_disk} cylinders."
582 elif [ ${cyls_per_opsys} -lt ${opsys_cyls_min} ]; then
583 echo
584 echo "${OPSYSTEM} requires at least ${opsys_cyls_min} cylinders to install."
585 else break
586 fi
587done
f078e99d
RG
588badspacesec=0
589if [ "$sect_fwd" = "sf:" ]; then
590 badspacecyl=`expr $sects_per_track + 126`
591 badspacecyl=`expr $badspacecyl + $cylindersize - 1`
592 badspacecyl=`expr $badspacecyl / $cylindersize`
593 badspacesec=`expr $badspacecyl \* $cylindersize`
362925ff 594 echo
f078e99d
RG
595 echo -n "Using $badspacesec sectors ($badspacecyl cylinders) for the "
596 echo "bad144 bad block table"
597fi
598whats_left=`expr $partition - $badspacesec`
599cyl_left=`expr $whats_left / $cylindersize`
21a421ff 600mb_left=`expr $whats_left / $mb_sect`
362925ff
AM
601swap_cyls_min=`expr $SWAPMIN \* $mb_sect / $cylindersize`
602root_cyls_max=`expr ${cyl_left} - ${swap_cyls_min}`
603root_cyls_min=`expr $ROOTMIN \* $mb_sect / $cylindersize`
604echo
605echo "There are $mb_left Mb ($cyl_left cylinders) to allocate."
606echo
607echo "The $OPSYSTEM portion of the disk must itself be divided into at least"
608echo "two partitions: one for the root filesystem and one for swap. It is a"
609echo "good idea to have at least a third (large) $OPSYSTEM partition for the /usr"
610echo "filesystem."
611echo
612echo "The root partition cannot exceed ${root_cyls_max} cylinders. It is usually"
613echo "no larger than about 15 Mb ($(expr 15 \* $mb_sect / $cylindersize) cylinders), and sometimes"
614echo "as small as $ROOTMIN Mb ($root_cyls_min cylinders)."
615if [ ! "$cyls_per_root" ]; then
616 # set default root partition to 15MB
617 cyls_per_root=`expr \( 15 \* $mb_sect \) / $cylindersize`
4c569b4c
AM
618 usr_cyls_max=`expr ${root_cyls_max} - ${cyls_per_root}`
619 mb_usr=`expr ${usr_cyls_max} \* $cylindersize / $mb_sect`
620 [ $cyls_per_root -gt $root_cyls_max -o $mb_usr -lt $USRMIN ] &&
621 cyls_per_root=$root_cyls_max
21a421ff 622fi
362925ff
AM
623while :; do
624 echo -n "Root partition size (in cylinders)? [${cyls_per_root}] "
625 read resp junk
626 cyls_per_root=${resp:-${cyls_per_root}}
627 root=`expr $cyls_per_root \* $cylindersize`
628 if [ ${cyls_per_root} -gt ${root_cyls_max} ]; then
629 echo
630 echo "The root partition size cannot exceed $root_cyls_max cylinders."
631 elif [ ${cyls_per_root} -lt ${root_cyls_min} ]; then
632 echo
633 echo "The root partition size must be at least $root_cyls_min cylinders."
634 else
635 part_used=`expr $root + $badspacesec`
636 break
21a421ff 637 fi
f078e99d
RG
638done
639root_offset=$part_offset
640whats_left=`expr $partition - $part_used`
21a421ff
AM
641cyl_left=`expr $whats_left / $cylindersize`
642mb_left=`expr $whats_left / $mb_sect`
362925ff 643echo
0d255f16
RG
644# DO NOT USE DIFFERENT BLOCKING FACTORS FOR EACH PARITION.. IT TRASHES THE
645# VM SYSTEM! When that gets fixed this can go back the way it was...
646#
647echo "We can build the filesystems with block/fragment sizes of either"
21a421ff
AM
648echo " 1) 4k/512, to save disk space at the expense of speed, or"
649echo " 2) 8k/1k for speed at the expense of disk space."
0d255f16 650echo -n "Which blocking factor should we use for the filesystems? "
362925ff
AM
651echo -n "[${blocking_factor:-${DEFBLOCKING}}] "
652read resp junk
653blocking_factor=${resp:-${blocking_factor:-${DEFBLOCKING}}}
21a421ff
AM
654fragsize=`expr $bytes_per_sect \* $blocking_factor`
655blocksize=`expr $bytes_per_sect \* $blocking_factor \* 8`
362925ff 656echo
43a91bf9 657echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk."
362925ff
AM
658echo
659echo "Minimum swap space is ${swap_cyls_min} cylinders."
660echo "For running X, if your RAM size is NR Mb, then the recomended swap"
661echo "size NS (in cylinders) is:"
662echo " NS = integer { ( NR x `expr 21 \* $mb_sect / 10` ) / ${cylindersize} }"
663if [ ! "$swap_cyl" ]; then
21a421ff
AM
664 # guess memory size
665 mb_ram=16
362925ff
AM
666 swap_cyl=`expr \( 21 \* $mb_ram \* $mb_sect \) / 10`
667 swap_cyl=`expr $swap_cyl / ${cylindersize}`
21a421ff
AM
668
669 # but not swap size more than 10% of disk size...
670 swap_quot=`expr $mb_left / $mb_ram`
671 if [ $swap_quot -lt 10 ]; then
362925ff 672 swap_cyl=$swap_cyls_min
21a421ff 673 fi
362925ff
AM
674fi
675while :; do
676 echo -n "Swap partition size (in cylinders)? [${swap_cyl}] "
677 read resp junk
678 swap_cyl=${resp:-${swap_cyl}}
679 swap=`expr $swap_cyl \* $cylindersize`
680 if [ ${swap_cyl} -gt ${cyl_left} ]; then
681 echo
682 echo "Swap size cannot exceed $cyl_left cylinders."
683 elif [ ${swap_cyl} -lt ${swap_cyls_min} ]; then
684 echo
685 echo "Swap size must be at least ${swap_cyls_min} cylinders."
686 else
687 break
21a421ff 688 fi
f078e99d 689done
f078e99d
RG
690swap_offset=`expr $root_offset + $root`
691part_used=`expr $part_used + $swap`
43a91bf9
RG
692echo "" >/etc/disktab
693echo "$name|${OPSYSTEM} installation generated:\\" >>/etc/disktab
694echo " :dt=${type}:ty=winchester:\\" >>/etc/disktab
f078e99d 695echo -n " :nc#${cyls_per_disk}:ns#${sects_per_track}" >>/etc/disktab
43a91bf9
RG
696echo ":nt#${tracks_per_cyl}:\\" >>/etc/disktab
697echo " :se#${bytes_per_sect}:${sect_fwd}\\" >>/etc/disktab
f078e99d 698echo -n " :pa#${root}:oa#${root_offset}" >>/etc/disktab
43a91bf9
RG
699echo ":ta=4.2BSD:ba#${blocksize}:fa#${fragsize}:\\" >>/etc/disktab
700echo " :pb#${swap}:ob#${swap_offset}:tb=swap:\\" >>/etc/disktab
701echo " :pc#${partition}:oc#${part_offset}:\\" >>/etc/disktab
f078e99d 702ename="";fname="";gname="";hname=""
362925ff
AM
703if [ $part_used -lt $partition ]; then
704 echo
705 echo "Now we enter information about any other partitions and filesystems"
706 echo "to be created in the ${OPSYSTEM} portion of the disk. This process"
707 echo "is complete when we've filled up all remaining space in the ${OPSYSTEM}"
708 echo "portion of the disk."
709fi
f078e99d
RG
710while [ $part_used -lt $partition ]; do
711 part_size=0
712 whats_left=`expr $partition - $part_used`
21a421ff
AM
713 cyl_left=`expr $whats_left / $cylindersize`
714 mb_left=`expr $whats_left / $mb_sect`
362925ff 715 echo
43a91bf9 716 echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk."
362925ff
AM
717 echo
718 while :; do
21a421ff 719 echo -n "Next partition size (in cylinders)? [${cyl_left}] "
362925ff
AM
720 read resp junk
721 part_size=${resp:-${cyl_left}}
722 part_size=`expr $part_size \* $cylindersize`
723 total=`expr $part_used + $part_size`
724 if [ $total -gt $partition ]; then
725 echo
726 echo "Partition size cannot exceed ${cyl_left} cylinders."
727 else
728 part_used=$total
729 part_name=""
730 while [ "$part_name" = "" ]; do
731 echo
732 echo -n "On which directory should this filesystem be mounted? [usr] "
733 read resp junk
734 part_name=${resp:-usr}
52617f4e 735 part_name=`expr X"$part_name" : 'X/*\(.*\)'`
362925ff
AM
736 done
737 break
21a421ff 738 fi
f078e99d 739 done
362925ff 740 if [ ! "$ename" ]; then
f078e99d
RG
741 ename=$part_name
742 offset=`expr $part_offset + $root + $swap`
743 echo -n " :pe#${part_size}:oe#${offset}" >>/etc/disktab
744 echo ":te=4.2BSD:be#${blocksize}:fe#${fragsize}:\\" >>/etc/disktab
745 offset=`expr $offset + $part_size`
362925ff 746 elif [ ! "$fname" ]; then
f078e99d
RG
747 fname=$part_name
748 echo -n " :pf#${part_size}:of#${offset}" >>/etc/disktab
749 echo ":tf=4.2BSD:bf#${blocksize}:ff#${fragsize}:\\" >>/etc/disktab
750 offset=`expr $offset + $part_size`
362925ff 751 elif [ ! "$gname" ]; then
f078e99d
RG
752 gname=$part_name
753 echo -n " :pg#${part_size}:og#${offset}" >>/etc/disktab
754 echo ":tg=4.2BSD:bg#${blocksize}:fg#${fragsize}:\\" >>/etc/disktab
755 offset=`expr $offset + $part_size`
362925ff 756 elif [ ! "$hname" ]; then
f078e99d
RG
757 hname=$part_name
758 echo -n " :ph#${part_size}:oh#${offset}" >>/etc/disktab
759 echo ":th=4.2BSD:bh#${blocksize}:fh#${fragsize}:\\" >>/etc/disktab
760 part_used=partition
761 fi
762done
5cb436ef
AM
763if [ "$have_dos_part" -a "$have_dos_part" != "$opsys_part" -a \
764 "$RUN_FDISK" != "overwrite" -a ! "$hname" ]; then
52617f4e
AM
765 echo
766 echo "There appears to be a MS-DOS filesystem on the hard disk."
767 echo -n "Make this be accessible from ${OPSYSTEM}? [y] "
768 read resp junk
769 case "${resp:-y}" in
770 y*|Y*)
771 part_name=""
772 while [ "$part_name" = "" ]; do
773 echo
774 echo -n "On which directory should this filesystem be mounted? [dos] "
775 read resp junk
776 part_name=${resp:-dos}
777 part_name=`expr X"$part_name" : 'X/*\(.*\)'`
778 done
779 hname=$part_name
780 eval offset=\$start${have_dos_part}
781 eval part_size=\$size${have_dos_part}
782 echo -n " :ph#${part_size}:oh#${offset}" >>/etc/disktab
783 echo ":th=MSDOS:\\" >>/etc/disktab
784 part_used=partition
785 ;;
786 *)
787 have_dos_part=""
788 ;;
789 esac
4c569b4c
AM
790else
791 have_dos_part=""
792fi
43a91bf9 793echo " :pd#${disksize}:od#0:" >>/etc/disktab
f078e99d
RG
794sync
795
362925ff
AM
796# cat /etc/disktab
797OIFS=$IFS
798IFS='
799'
800while read data; do
801 echo $data
802done < /etc/disktab
803IFS=$OIFS
804
805echo
8231ed99
RG
806echo -n "Verbose installation? [n] "
807read resp
808
809case $resp in
362925ff
AM
810y*)
811 cpioverbose=v
812 ;;
813*)
814 cpioverbose=
815 ;;
8231ed99
RG
816esac
817
362925ff
AM
818
819echo
f1002c06 820echo "THIS IS THE LAST CHANCE!!! Data on the hard disk will be lost!"
21a421ff 821echo -n "Are you sure you want to install on the hard drive? (yes/no) "
362925ff
AM
822resp=""
823while [ ! "$resp" ]; do
824 read resp junk
825 case "$resp" in
826 Yes|yes|YES)
827 verified_install=1
828 echo
f1002c06 829 echo "Here we go..."
362925ff
AM
830 ;;
831 No|no|NO)
832 echo
833 echo -n "Would you like to change the configuration? [y] "
834 read resp junk
835 resp=${resp:-y}
836 case "$resp" in
837 y*|Y*)
f078e99d
RG
838 ;;
839 *)
362925ff 840 echo
f1002c06 841 echo "Installation aborted. Enter 'halt' to halt the machine."
43a91bf9
RG
842 echo "Once the machine has halted, remove the floppy,"
843 echo "and press any key to reboot."
362925ff 844 exit
f078e99d 845 ;;
362925ff
AM
846 esac
847 ;;
848 *)
849 echo "Please spell out either of \`yes' or \`no'..."
850 echo -n "Install on the hard disk? (yes/no) "
851 resp=
852 ;;
f078e99d
RG
853 esac
854done
ede9f473
AM
855done # End of Big Loop
856
362925ff
AM
857put_fdisk_data
858
859echo
f078e99d 860echo -n "Labelling disk..."
362925ff
AM
861echo y |
862/sbin/disklabel -w -r ${drivename} $name /usr/mdec/${drivetype}boot /usr/mdec/boot${drivetype} >/dev/null 2>&1
43a91bf9 863echo " done."
f078e99d 864
00bf7f83 865# XXX - Do it again, incase we disklabeled sector 0!
635dcafb 866# XXX - this is not working for some reason, need to look at it closer!
00bf7f83
RG
867put_fdisk_data
868
f078e99d
RG
869if [ "$sect_fwd" = "sf:" ]; then
870 echo -n "Initializing bad144 badblock table..."
871 bad144 $drivename 0
872 echo " done."
362925ff
AM
873 echo "Updating badblock table..."
874 # `2>&1 >/dev/null' filters stdout and leaves only stderr...
1f49206c 875 badlist=$(bad144 -s $drivename 2>&1 >/dev/null |
362925ff 876 while read data; do
1f49206c
AM
877 bad_seek=$(expr "$data" : '[^(]*(seek)[^0-9]*\([0-9]*\)')
878 bad_read=$(expr "$data" : '[^(]*(read)[^0-9]*\([0-9]*\)')
362925ff 879 [ "$bad_seek" -o "$bad_read" ] && echo -n "$bad_seek $bad_read "
1f49206c
AM
880 done)
881 [ "$badlist" ] && bad144 -a -c $drivename "$badlist"
362925ff 882 echo " done."
f078e99d
RG
883fi
884
43a91bf9 885echo "Initializing root filesystem, and mounting..."
c5bc0e81 886newfs ${rotdelay} /dev/r${drivename}a $name
f078e99d
RG
887mount -v /dev/${drivename}a /mnt
888if [ "$ename" != "" ]; then
362925ff 889 echo
43a91bf9 890 echo "Initializing $ename filesystem, and mounting..."
c5bc0e81 891 newfs ${rotdelay} /dev/r${drivename}e $name
f078e99d
RG
892 mkdir -p /mnt/$ename
893 mount -v /dev/${drivename}e /mnt/$ename
894fi
895if [ "$fname" != "" ]; then
362925ff 896 echo
43a91bf9 897 echo "Initializing $fname filesystem, and mounting..."
c5bc0e81 898 newfs ${rotdelay} /dev/r${drivename}f $name
f078e99d
RG
899 mkdir -p /mnt/$fname
900 mount -v /dev/${drivename}f /mnt/$fname
901fi
902if [ "$gname" != "" ]; then
362925ff 903 echo
43a91bf9 904 echo "Initializing $gname filesystem, and mounting..."
c5bc0e81 905 newfs ${rotdelay} /dev/r${drivename}g $name
f078e99d
RG
906 mkdir -p /mnt/$gname
907 mount -v /dev/${drivename}g /mnt/$gname
908fi
909if [ "$hname" != "" ]; then
362925ff 910 echo
4c569b4c
AM
911 if [ ! "$have_dos_part" ]; then
912 echo "Initializing $hname filesystem, and mounting..."
913 newfs ${rotdelay} /dev/r${drivename}h $name
914 else
915 echo "Initializing $hname filesystem..."
916 fi
f078e99d 917 mkdir -p /mnt/$hname
4c569b4c 918 [ ! "$have_dos_part" ] &&
f078e99d
RG
919 mount -v /dev/${drivename}h /mnt/$hname
920fi
921
8231ed99 922echo
635dcafb 923echo -n "Copying to disk... "
f078e99d 924cd /
635dcafb
RG
925cpio -pdamu${cpioverbose} /mnt <filelist
926echo -n "Copying more to disk... "
f078e99d 927cd /mnt
635dcafb
RG
928gzcat < /inst1.cpio.gz | cpio -idmu
929
930echo -n "Building /etc/fstab... "
931echo "proc /proc procfs rw 0 0" >etc/fstab
2847e70e
RG
932echo "/dev/${drivename}b none swap sw 0 0" >>etc/fstab
933echo "/dev/${drivename}a / ufs rw 1 1" >>etc/fstab
f078e99d 934if [ "$ename" != "" ]; then
c5bc0e81 935 echo "/dev/${drivename}e /$ename ufs rw 1 2" >>etc/fstab
f078e99d
RG
936fi
937if [ "$fname" != "" ]; then
c5bc0e81 938 echo "/dev/${drivename}f /$fname ufs rw 1 3" >>etc/fstab
f078e99d
RG
939fi
940if [ "$gname" != "" ]; then
c5bc0e81 941 echo "/dev/${drivename}g /$gname ufs rw 1 4" >>etc/fstab
f078e99d
RG
942fi
943if [ "$hname" != "" ]; then
4c569b4c
AM
944 if [ ! "$have_dos_part" ]; then
945 echo "/dev/${drivename}h /$hname ufs rw 1 5" >>etc/fstab
946 else
635dcafb 947 echo "/dev/${drivename}h /$hname pcfs ro 0 0" >>etc/fstab
4c569b4c 948 fi
f078e99d
RG
949fi
950
362925ff
AM
951# cat /etc/disktab >etc/disktab.install
952OIFS=$IFS
953IFS='
954'
955while read data; do
956 echo $data
957done </etc/disktab >etc/disktab.install
958IFS=$OIFS
635dcafb 959echo "done."
0d255f16 960
635dcafb 961echo -n "Building /etc/rc... "
362925ff 962(
635dcafb 963echo "PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/distbin:"
362925ff
AM
964echo "export PATH"
965echo "HOME=/root"
966echo "export HOME"
967echo "TERM=pc3"
968echo "export TERM"
969echo "mount -at ufs"
970echo "echo"
635dcafb 971echo "echo"
a8a6c1e9 972echo "echo \"Insert cpio installation floppy in drive and\""
52617f4e 973echo "echo -n \"enter that drive's number (0 or 1): [0] \""
362925ff
AM
974echo "read resp junk"
975echo "driveno=\${resp:-0}"
00bf7f83 976echo "mount -o ro /dev/fd\${driveno} /mnt"
362925ff
AM
977echo "cd /mnt"
978echo "install"
730f2c4e
AM
979echo "cd /"
980echo "umount /mnt >/dev/null 2>&1"
981echo "echo"
83dff685 982echo "echo -n \"Install optional dos floppy? [n] \""
730f2c4e 983echo "read resp junk"
83dff685 984echo "case \"\$resp\" in"
53c2fade 985echo "y*|Y*)"
83dff685 986echo " echo"
52617f4e
AM
987echo " echo \"Remove cpio floppy from drive, insert dos floppy, and\""
988echo " echo -n \"enter that drive's number (0 or 1): [0] \""
83dff685
AM
989echo " read resp junk"
990echo " driveno=\${resp:-0}"
00bf7f83 991echo " mount -t pcfs -o ro /dev/fd\${driveno} /mnt"
83dff685 992echo " mkdir -p /usr/distbin"
5ae4c83e 993echo " cp /mnt/* /usr/distbin/ >/dev/null 2>&1"
83dff685
AM
994echo " sync"
995echo " umount /mnt >/dev/null 2>&1"
996echo " ;;"
997echo "esac"
730f2c4e 998echo "echo"
43a91bf9 999echo "echo \"OK. All of the base files are installed.\""
730f2c4e 1000echo "echo"
39087e97
AM
1001echo "echo \"The next step: reboot from the hard disk. Further\""
1002echo "echo \"instructions are presented upon rebooting.\""
730f2c4e 1003echo "echo"
39087e97
AM
1004echo "echo \"Enter 'halt' now at the prompt to halt the machine.\""
1005echo "echo \"After the machine has halted, remove the floppy from the disk\""
730f2c4e 1006echo "echo \"drive, and hit any key to reboot from the hard disk.\""
635dcafb
RG
1007echo "exit 1"
1008) >etc/rc
1009echo "done."
f078e99d
RG
1010
1011sync
1012
362925ff 1013echo
43a91bf9
RG
1014echo "The next step: reboot from the kernel-copy disk, copy a kernel"
1015echo "to the hard disk, and finally reboot from the hard disk."
362925ff 1016echo
39087e97 1017echo "To do this, enter \`halt' now to halt the machine. After it"
21a421ff
AM
1018echo "announces that it has halted, remove the floppy from the drive"
1019echo "and insert the kernel-copy disk that was booted before."
730f2c4e
AM
1020echo "Press any key to reboot. When prompted to insert the filesystem"
1021echo "floppy this time, just hit RETURN without changing floppies."
362925ff
AM
1022echo
1023echo "If all goes well, you can enter the command \`copy' at the prompt to"
1024echo "copy the kernel to the hard disk. When asked for which partition to"
635dcafb 1025echo "copy to, enter \`${drivename}a' (without the quotes)."
362925ff 1026echo
21a421ff 1027echo "Okay, that's all for now. I'm waiting for you to enter \`halt'..."
635dcafb
RG
1028
1029sync;sync;sync;sync
1030