install.sh revision 1.1 1 #!/bin/sh
2 #
3 # Copyright (c) 1994 Christopher G. Demetriou
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. All advertising materials mentioning features or use of this software
15 # must display the following acknowledgement:
16 # This product includes software developed by Christopher G. Demetriou.
17 # 4. The name of the author may not be used to endorse or promote products
18 # derived from this software without specific prior written permission
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # $Id: install.sh,v 1.1 1994/10/06 20:25:47 chopps Exp $
32
33 # NetBSD installation script.
34 # In a perfect world, this would be a nice C program, with a reasonable
35 # user interface.
36
37 DT=/etc/disktab # /etc/disktab
38 FSTABDIR=/mnt/etc # /mnt/etc
39 #DONTDOIT=echo
40
41 VERSION=1.0
42 FSTAB=${FSTABDIR}/fstab
43
44 getresp() {
45 read resp
46 if [ "X$resp" = "X" ]; then
47 resp=$1
48 fi
49 }
50
51 echo "Welcome to the NetBSD ${VERSION} installation program."
52 echo ""
53 echo "This program is designed to help you put NetBSD on your hard disk,"
54 echo "in a simple and rational way. You'll be asked several questions,"
55 echo "and it would probably be useful to have your disk's hardware"
56 echo "manual, the installation notes, and a calculator handy."
57 echo ""
58 echo "In particular, you will need to know some reasonably detailed"
59 echo "information about your disk's geometry, because there is currently"
60 echo "no way this this program can figure that information out."
61 echo ""
62 echo "As with anything which modifies your hard drive's contents, this"
63 echo "program can cause SIGNIFICANT data loss, and you are advised"
64 echo "to make sure your hard drive is backed up before beginning the"
65 echo "installation process."
66 echo ""
67 echo "Default answers are displyed in brackets after the questions."
68 echo "You can hit Control-C at any time to quit, but if you do so at a"
69 echo "prompt, you may have to hit return. Also, quitting in the middle of"
70 echo "installation may leave your system in an inconsistent state."
71 echo ""
72 echo -n "Proceed with installation? [n] "
73 getresp "n"
74 case "$resp" in
75 y*|Y*)
76 echo "Cool! Let's get to it..."
77 ;;
78 *)
79 echo ""
80 echo "OK, then. Enter 'halt' at the prompt to halt the"
81 echo "machine. Once the machine has halted, remove the"
82 echo "floppy and press any key to reboot."
83 exit
84 ;;
85 esac
86
87 echo ""
88 echo "To do the installation, you'll need to provide some information about"
89 echo "your disk."
90 echo ""
91 echo "NetBSD can be installed on ST506, ESDI, IDE, or SCSI disks."
92 echo -n "What kind of disk will you be installing on? [SCSI] "
93 getresp "SCSI"
94 case "$resp" in
95 esdi|ESDI|st506|ST506)
96 drivetype=wd
97 echo -n "Does it support _automatic_ sector remapping? [y] "
98 getresp "y"
99 case "$resp" in
100 n*|N*)
101 sect_fwd="sf:"
102 ;;
103 *)
104 sect_fwd=""
105 ;;
106 esac
107 ;;
108 ide|IDE)
109 drivetype=wd
110 sect_fwd=""
111 type=ST506
112 ;;
113 scsi|SCSI)
114 drivetype=sd
115 sect_fwd=""
116 type=SCSI
117 ;;
118 esac
119
120 # find out what units are possible for that disk, and query the user.
121 driveunits=`ls /dev/${drivetype}?a | sed -e 's,/dev/\(...\)a,\1,g'`
122 if [ "X${driveunits}" = "X" ]; then
123 echo "FATAL ERROR:"
124 echo "No devices for disks of type '${drivetype}'."
125 echo "This is probably a bug in the install disks."
126 echo "Exiting install program."
127 exit
128 fi
129 prefdrive=${drivetype}0
130
131 echo ""
132 echo "The following ${drivetype}-type disks are supported by this"
133 echo "installation procedure:"
134 echo " "${driveunits}
135 echo "Note that they may not exist in _your_ machine; the list of"
136 echo "disks in your machine was printed when the system was booting."
137 echo ""
138 while [ "X${drivename}" = "X" ]; do
139 echo -n "Which disk would like to install on? [${prefdrive}] "
140 getresp ${prefdrive}
141 otherdrives=`echo "${driveunits}" | sed -e s,${resp},,`
142 if [ "X${driveunits}" = "X${otherdrives}" ]; then
143 echo ""
144 echo "\"${resp}\" is an invalid drive name. Valid choices"
145 echo "are: "${driveunits}
146 echo ""
147 else
148 drivename=${resp}
149 fi
150 done
151
152 echo ""
153 echo "Using disk ${drivename}."
154 echo ""
155 echo -n "What kind of disk is it? (one word please) [my${drivetype}] "
156 getresp "my${drivetype}"
157 labelname=$resp
158
159 echo ""
160 echo "You will now need to provide some information about your disk's"
161 echo "geometry. This should either be in the User's Manual for your disk,"
162 echo "or you should have written down what NetBSD printed when booting."
163 echo "(Note that he geometry that's printed at boot time is preferred.)"
164 echo ""
165 echo -n "Number of bytes per disk sector? [512] "
166 getresp 512
167 bytes_per_sect="$resp"
168
169 echo -n "Number of disk cylinders? "
170 getresp
171 cyls_per_disk="$resp"
172
173 echo -n "Number of disk tracks (heads) per disk cylinder? "
174 getresp
175 tracks_per_cyl="$resp"
176
177 echo -n "Number of disk sectors per disk track? "
178 getresp
179 sects_per_track="$resp"
180
181 cylindersize=`expr $sects_per_track \* $tracks_per_cyl`
182 cylbytes=`expr $cylindersize \* $bytes_per_sect`
183 disksize=`expr $cylindersize \* $cyls_per_disk`
184
185 echo ""
186 echo "Your disk has a total of $disksize $bytes_per_sect byte sectors,"
187 echo "arranged as $cyls_per_disk cylinders which contain $cylindersize"
188 echo "sectors ($cylbytes bytes) each."
189 echo ""
190 echo "You can specify partition sizes in cylinders ('c') or sectors ('s')."
191 while [ "X${sizemult}" = "X" ]; do
192 echo -n "What units would you like to use? [cylinders] "
193 getresp cylinders
194 case "$resp" in
195 c*|C*)
196 sizemult=$cylindersize
197 sizeunit="cylinders"
198 ;;
199 s*|S*)
200 sizemult=1
201 sizeunit="sectors"
202 ;;
203 *)
204 echo ""
205 echo "Enter cylinders ('c') or sectors ('s')."
206 ;;
207 esac
208 done
209
210 if [ $sizeunit = "sectors" ]; then
211 echo ""
212 echo "For best disk performance, partitions should being and end on"
213 echo "cylinder boundaries. Wherever possible, pick sizes that are"
214 echo -n "multiples are multiples of the cylinder size ($cylindersize"
215 echo "sectors)."
216 fi
217
218 echo -n ""
219 echo -n "Size of NetBSD portion of disk (in $sizeunit)? "
220 getresp
221 partition=$resp
222 partition_sects=`expr $resp \* $sizemult`
223 part_offset=0
224 if [ $partition_sects -lt $disksize ]; then
225 echo -n "Offset of NetBSD portion of disk (in $sizeunit)? "
226 getresp
227 part_offset=$resp
228 fi
229 badspacesec=0
230 if [ "$sect_fwd" = "sf:" ]; then
231 badspacecyl=`expr $sects_per_track + 126`
232 badspacecyl=`expr $badspacecyl + $cylindersize - 1`
233 badspacecyl=`expr $badspacecyl / $cylindersize`
234 badspacesec=`expr $badspacecyl \* $cylindersize`
235 echo ""
236 echo -n "Using $badspacesec sectors ($badspacecyl cylinders) for the "
237 echo "bad144 bad block table"
238 fi
239
240 sects_left=`expr $partition_sects - $badspacesec`
241 units_left=`expr $sects_left / $sizemult`
242 echo ""
243 echo "There are $units_left $sizeunit left to allocate."
244 echo ""
245 root=0
246 while [ $root -eq 0 ]; do
247 echo -n "Root partition size (in $sizeunit)? "
248 getresp
249 case $resp in
250 [1-9]*)
251 total=$resp
252 if [ $total -gt $units_left ]; then
253 echo -n "Root size is greater than remaining "
254 echo "free space on disk."
255 else
256 root=$resp
257 fi
258 ;;
259 esac
260 done
261 root_offset=$part_offset
262 part_used=`expr $root + $badspacesec / $sizemult`
263 units_left=`expr $partition - $part_used`
264 echo ""
265
266 swap=0
267 while [ $swap -eq 0 ]; do
268 echo "$units_left $sizeunit remaining in NetBSD portion of disk."
269 echo -n "Swap partition size (in $sizeunit)? "
270 getresp
271 case $resp in
272 [1-9]*)
273 if [ $swap -gt $units_left ]; then
274 echo -n "Swap size is greater than remaining "
275 echo "free space on disk."
276 else
277 swap=$resp
278 fi
279 ;;
280 esac
281 done
282 swap_offset=`expr $root_offset + $root`
283 part_used=`expr $part_used + $swap`
284 echo ""
285
286 fragsize=1024
287 blocksize=8192
288 $DONTDOIT mount -u /dev/fd0a /
289 cat /etc/disktab.preinstall > $DT
290 echo "" >> $DT
291 echo "$labelname|NetBSD installation generated:\\" >> $DT
292 echo " :dt=${type}:ty=winchester:\\" >> $DT
293 echo -n " :nc#${cyls_per_disk}:ns#${sects_per_track}" >> $DT
294 echo ":nt#${tracks_per_cyl}:\\" >> $DT
295 echo " :se#${bytes_per_sect}:${sect_fwd}\\" >> $DT
296 _size=`expr $root \* $sizemult`
297 _offset=`expr $root_offset \* $sizemult`
298 echo -n " :pa#${_size}:oa#${_offset}" >> $DT
299 echo ":ta=4.2BSD:ba#${blocksize}:fa#${fragsize}:\\" >> $DT
300 _size=`expr $swap \* $sizemult`
301 _offset=`expr $swap_offset \* $sizemult`
302 echo " :pb#${_size}:ob#${_offset}:tb=swap:\\" >> $DT
303 _size=`expr $partition \* $sizemult`
304 _offset=`expr $part_offset \* $sizemult`
305 echo " :pc#${_size}:oc#${_offset}:\\" >> $DT
306
307 echo "You will now have to enter information about any other partitions"
308 echo "to be created in the NetBSD portion of the disk. This process will"
309 echo "be complete when you've filled up all remaining space in the NetBSD"
310 echo "portion of the disk."
311
312 while [ $part_used -lt $partition ]; do
313 part_size=0
314 units_left=`expr $partition - $part_used`
315 while [ $part_size -eq 0 ]; do
316 echo ""
317 echo -n "$units_left $sizeunit remaining in NetBSD portion of "
318 echo "the disk"
319 echo -n "Next partition size (in $sizeunit)? "
320 getresp
321 case $resp in
322 [1-9]*)
323 total=`expr $part_used + $resp`
324 if [ $total -gt $partition ]; then
325 echo -n "That would make the parition"
326 echo "too large to fit!"
327 else
328 part_size=$resp
329 part_used=$total
330 part_name=""
331 while [ "$part_name" = "" ]; do
332 echo -n "Mount point? "
333 getresp
334 part_name=$resp
335 done
336 fi
337 ;;
338 esac
339 done
340 if [ "$ename" = "" ]; then
341 ename=$part_name
342 offset=`expr $part_offset + $root + $swap`
343 _size=`expr $part_size \* $sizemult`
344 _offset=`expr $offset \* $sizemult`
345 echo -n " :pe#${_size}:oe#${_offset}" >> $DT
346 echo ":te=4.2BSD:be#${blocksize}:fe#${fragsize}:\\" >> $DT
347 offset=`expr $offset + $part_size`
348 elif [ "$fname" = "" ]; then
349 fname=$part_name
350 _size=`expr $part_size \* $sizemult`
351 _offset=`expr $offset \* $sizemult`
352 echo -n " :pf#${_size}:of#${_offset}" >> $DT
353 echo ":tf=4.2BSD:bf#${blocksize}:ff#${fragsize}:\\" >> $DT
354 offset=`expr $offset + $part_size`
355 elif [ "$gname" = "" ]; then
356 gname=$part_name
357 _size=`expr $part_size \* $sizemult`
358 _offset=`expr $offset \* $sizemult`
359 echo -n " :pg#${_size}:og#${_offset}" >> $DT
360 echo ":tg=4.2BSD:bg#${blocksize}:fg#${fragsize}:\\" >> $DT
361 offset=`expr $offset + $part_size`
362 elif [ "$hname" = "" ]; then
363 hname=$part_name
364 _size=`expr $part_size \* $sizemult`
365 _offset=`expr $offset \* $sizemult`
366 echo -n " :ph#${_size}:oh#${_offset}" >> $DT
367 echo ":th=4.2BSD:bh#${blocksize}:fh#${fragsize}:\\" >> $DT
368 part_used=$partition
369 fi
370 done
371 echo " :pd#${disksize}:od#0:" >> $DT
372 sync
373
374 echo ""
375 echo "THIS IS YOUR LAST CHANCE!!!"
376 echo ""
377 echo -n "Are you SURE you want NetBSD installed on your hard drive? (yes/no) "
378 answer=""
379 while [ "$answer" = "" ]; do
380 getresp
381 case $resp in
382 yes|YES)
383 echo ""
384 echo "Here we go..."
385 answer=yes
386 ;;
387 no|NO)
388 echo ""
389 echo -n "OK, then. enter 'halt' to halt the machine. "
390 echo "Once the machine has halted,"
391 echo -n "remove the floppy, and press any key to "
392 echo "reboot."
393 exit
394 ;;
395 *)
396 echo -n "I want a yes or no answer... well? "
397 ;;
398 esac
399 done
400
401 echo ""
402 echo -n "Labellling disk $drivename..."
403 $DONTDOIT disklabel -w -B $drivename $labelname
404 echo " done."
405
406 if [ "$sect_fwd" = "sf:" ]; then
407 echo -n "Initializing bad144 badblock table..."
408 $DONTDOIT bad144 $drivename 0
409 echo " done."
410 fi
411
412 echo "Initializing root filesystem, and mounting..."
413 $DONTDOIT newfs /dev/r${drivename}a $name
414 $DONTDOIT mount -v /dev/${drivename}a /mnt
415 if [ "$ename" != "" ]; then
416 echo ""
417 echo "Initializing $ename filesystem, and mounting..."
418 $DONTDOIT newfs /dev/r${drivename}e $name
419 $DONTDOIT mkdir -p /mnt/$ename
420 $DONTDOIT mount -v /dev/${drivename}e /mnt/$ename
421 fi
422 if [ "$fname" != "" ]; then
423 echo ""
424 echo "Initializing $fname filesystem, and mounting..."
425 $DONTDOIT newfs /dev/r${drivename}f $name
426 $DONTDOIT mkdir -p /mnt/$fname
427 $DONTDOIT mount -v /dev/${drivename}f /mnt/$fname
428 fi
429 if [ "$gname" != "" ]; then
430 echo ""
431 echo "Initializing $gname filesystem, and mounting..."
432 $DONTDOIT newfs /dev/r${drivename}g $name
433 $DONTDOIT mkdir -p /mnt/$gname
434 $DONTDOIT mount -v /dev/${drivename}g /mnt/$gname
435 fi
436 if [ "$hname" != "" ]; then
437 echo ""
438 echo "Initializing $hname filesystem, and mounting..."
439 $DONTDOIT newfs /dev/r${drivename}h $name
440 $DONTDOIT mkdir -p /mnt/$hname
441 $DONTDOIT mount -v /dev/${drivename}h /mnt/$hname
442 fi
443
444 echo -n "Creating a fstab..."
445 $DONTDOIT mkdir -p $FSTABDIR
446 echo /dev/${drivename}a / ufs rw 1 1 | sed -e s,//,/, > $FSTAB
447 if [ "$ename" != "" ]; then
448 echo /dev/${drivename}e /$ename ufs rw 1 2 | sed -e s,//,/, >> $FSTAB
449 fi
450 if [ "$fname" != "" ]; then
451 echo /dev/${drivename}f /$fname ufs rw 1 3 | sed -e s,//,/, >> $FSTAB
452 fi
453 if [ "$gname" != "" ]; then
454 echo /dev/${drivename}g /$gname ufs rw 1 4 | sed -e s,//,/, >> $FSTAB
455 fi
456 if [ "$hname" != "" ]; then
457 echo /dev/${drivename}h /$hname ufs rw 1 5 | sed -e s,//,/, >> $FSTAB
458 fi
459 sync
460 echo " done."
461
462 echo ""
463 echo ""
464 echo "OK! The preliminary work of setting up your disk is now complete,"
465 echo "and you can install the actual NetBSD software."
466 echo ""
467 echo "Right now, your disk is mounted on /mnt. You should consult"
468 echo "the installation notes to determine how to load and install the"
469 echo "NetBSD distribution sets, and how to configure your system when"
470 echo "you are done."
471 echo ""
472 echo "GOOD LUCK!"
473 echo ""
474