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