2 # $NetBSD: install.sh,v 1.5 2009/09/16 10:40:02 abs Exp $
4 # Copyright (c) 1997 Perry E. Metzger
5 # Copyright (c) 1994 Christopher G. Demetriou
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. All advertising materials mentioning features or use of this software
17 # must display the following acknowledgement:
18 # This product includes software developed for the
19 # NetBSD Project. See http://www.NetBSD.org/ for
20 # information about NetBSD.
21 # 4. The name of the author may not be used to endorse or promote products
22 # derived from this software without specific prior written permission.
24 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 # <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
37 # NetBSD installation script.
38 # In a perfect world, this would be a nice C program, with a reasonable
41 DT
=/etc
/disktab
# /etc/disktab
42 FSTABDIR
=/mnt
/etc
# /mnt/etc
46 FSTAB
=${FSTABDIR}/fstab
50 if [ "X$resp" = "X" ]; then
55 echo "Welcome to the original NetBSD/alpha installation program."
57 echo "This version of the program has been largely replaced by the new
58 echo "sysinst utility. Both programs are on this installation media
set.
59 echo -n "Type the return key to continue..."
61 echo "This program is designed to help you put NetBSD on your hard disk,"
62 echo "in a simple and rational way. You'll be asked several questions,"
63 echo "and it would probably be useful to have your disk's hardware"
64 echo "manual, the installation notes, and a calculator handy."
66 echo "In particular, you will need to know some reasonably detailed"
67 echo "information about your disk's geometry, because there is currently"
68 echo "no way this program can figure that information out."
70 echo "As with anything which modifies your hard drive's contents, this"
71 echo "program can cause SIGNIFICANT data loss, and you are advised"
72 echo "to make sure your hard drive is backed up before beginning the"
73 echo "installation process."
75 echo "Default answers are displyed in brackets after the questions."
76 echo "You can hit Control-C at any time to quit, but if you do so at a"
77 echo "prompt, you may have to hit return. Also, quitting in the middle of"
78 echo "installation may leave your system in an inconsistent state."
80 echo -n "Proceed with installation? [n] "
84 echo "Cool! Let's get to it..."
88 echo "OK, then. Enter 'halt' at the prompt to halt the"
89 echo "machine. Once the machine has halted, remove the"
90 echo "floppy and press any key to reboot."
96 echo "To do the installation, you'll need to provide some information about"
99 echo "NetBSD can be installed on ST506, ESDI, IDE, or SCSI disks."
100 echo -n "What kind of disk will you be installing on? [SCSI] "
103 esdi|ESDI|st506|ST506
)
105 echo -n "Does it support _automatic_ sector remapping? [y] "
128 # find out what units are possible for that disk, and query the user.
129 driveunits
=`echo /dev/${drivetype}?a | sed -e 's,/dev/\(...\)a,\1,g'`
130 if [ "X${driveunits}" = "X" ]; then
132 echo "No devices for disks of type '${drivetype}'."
133 echo "This is probably a bug in the install disks."
134 echo "Exiting install program."
137 prefdrive
=${drivetype}0
140 echo "The following ${drivetype}-type disks are supported by this"
141 echo "installation procedure:"
142 echo " "${driveunits}
143 echo "Note that they may not exist in _your_ machine; the list of"
144 echo "disks in your machine was printed when the system was booting."
146 while [ "X${drivename}" = "X" ]; do
147 echo -n "Which disk would like to install on? [${prefdrive}] "
149 otherdrives
=`echo "${driveunits}" | sed -e s,${resp},,`
150 if [ "X${driveunits}" = "X${otherdrives}" ]; then
152 echo "\"${resp}\" is an invalid drive name. Valid choices"
153 echo "are: "${driveunits}
161 echo "Using disk ${drivename}."
163 echo -n "What kind of disk is it? (one word please) [my${drivetype}] "
164 getresp
"my${drivetype}"
168 echo "You will now need to provide some information about your disk's"
169 echo "geometry. This should either be in the User's Manual for your disk,"
170 echo "or you should have written down what NetBSD printed when booting."
171 echo "(Note that he geometry that's printed at boot time is preferred.)"
173 echo "You may choose to view the initial boot messages for your system"
174 echo "again right now if you like."
175 echo -n "View the boot messages again? [n] "
187 echo "You will now enter the disk geometry information"
190 echo -n "Number of bytes per disk sector? [512] "
192 bytes_per_sect
="$resp"
194 echo -n "Number of disk cylinders? "
196 cyls_per_disk
="$resp"
198 echo -n "Number of disk tracks (heads) per disk cylinder? "
200 tracks_per_cyl
="$resp"
202 echo -n "Number of disk sectors per disk track? "
204 sects_per_track
="$resp"
206 cylindersize
=$
(( $sects_per_track * $tracks_per_cyl ))
207 cylbytes
=$
(( $cylindersize * $bytes_per_sect ))
208 disksize
=$
(( $cylindersize * $cyls_per_disk ))
211 echo "Your disk has a total of $disksize $bytes_per_sect byte sectors,"
212 echo "arranged as $cyls_per_disk cylinders which contain $cylindersize "
213 echo "sectors ($cylbytes bytes) each."
215 echo "You can specify partition sizes in cylinders ('c') or sectors ('s')."
216 while [ "X${sizemult}" = "X" ]; do
217 echo -n "What units would you like to use? [cylinders] "
221 sizemult
=$cylindersize
230 echo "Enter cylinders ('c') or sectors ('s')."
235 if [ $sizeunit = "sectors" ]; then
237 echo "For best disk performance, partitions should begin and end on"
238 echo "cylinder boundaries. Wherever possible, pick sizes that are"
239 echo "multiples of the cylinder size ($cylindersize sectors)."
242 partition_sects
=$disksize
243 partition
=$
(( $disksize / $sizemult ))
247 if [ "$sect_fwd" = "sf:" ]; then
248 badspacecyl
=$
(( $sects_per_track + 126 ))
249 badspacecyl
=$
(( $badspacecyl + $cylindersize - 1 ))
250 badspacecyl
=$
(( $badspacecyl / $cylindersize ))
251 badspacesec
=$
(( $badspacecyl * $cylindersize ))
253 echo -n "Using $badspacesec sectors ($badspacecyl cylinders) for the "
254 echo "bad144 bad block table"
257 sects_left
=$
(( $partition_sects - $badspacesec ))
258 units_left
=$
(( $sects_left / $sizemult ))
260 echo "There are $units_left $sizeunit left to allocate."
263 while [ $root -eq 0 ]; do
264 echo -n "Root partition size (in $sizeunit)? "
269 if [ $total -gt $units_left ]; then
270 echo -n "Root size is greater than remaining "
271 echo "free space on disk."
278 root_offset
=$part_offset
279 part_used
=$
(( $root + $badspacesec / $sizemult ))
280 units_left
=$
(( $partition - $part_used ))
284 while [ $swap -eq 0 ]; do
285 echo "$units_left $sizeunit remaining in NetBSD portion of disk."
286 echo -n "Swap partition size (in $sizeunit)? "
290 if [ $swap -gt $units_left ]; then
291 echo -n "Swap size is greater than remaining "
292 echo "free space on disk."
299 swap_offset
=$
(( $root_offset + $root ))
300 part_used
=$
(( $part_used + $swap ))
308 echo "$labelname|NetBSD installation generated:\\" >> $DT
309 echo " :dt=${type}:ty=winchester:\\" >> $DT
310 echo -n " :nc#${cyls_per_disk}:ns#${sects_per_track}" >> $DT
311 echo ":nt#${tracks_per_cyl}:\\" >> $DT
312 echo " :se#${bytes_per_sect}:${sect_fwd}\\" >> $DT
313 _size
=$
(( $root * $sizemult ))
314 _offset
=$
(( $root_offset * $sizemult ))
315 echo -n " :pa#${_size}:oa#${_offset}" >> $DT
316 echo ":ta=4.2BSD:ba#${blocksize}:fa#${fragsize}:\\" >> $DT
317 _size
=$
(( $swap * $sizemult ))
318 _offset
=$
(( $swap_offset * $sizemult ))
319 echo " :pb#${_size}:ob#${_offset}:tb=swap:\\" >> $DT
320 _size
=$
(( $partition * $sizemult ))
321 _offset
=$
(( $part_offset * $sizemult ))
322 echo " :pc#${_size}:oc#${_offset}:\\" >> $DT
324 echo "You will now have to enter information about any other partitions"
325 echo "to be created in the NetBSD portion of the disk. This process will"
326 echo "be complete when you've filled up all remaining space in the NetBSD"
327 echo "portion of the disk."
329 while [ $part_used -lt $partition ]; do
331 units_left
=$
(( $partition - $part_used ))
332 while [ $part_size -eq 0 ]; do
334 echo -n "$units_left $sizeunit remaining in NetBSD portion of "
336 echo -n "Next partition size (in $sizeunit)? "
340 total
=$
(( $part_used + $resp ))
341 if [ $total -gt $partition ]; then
342 echo -n "That would make the parition"
343 echo "too large to fit!"
348 while [ "$part_name" = "" ]; do
349 echo -n "Mount point? "
357 if [ "$dname" = "" ]; then
359 offset
=$
(( $part_offset + $root + $swap ))
360 _size
=$
(( $part_size * $sizemult ))
361 _offset
=$
(( $offset * $sizemult ))
362 echo -n " :pd#${_size}:od#${_offset}" >> $DT
363 echo ":td=4.2BSD:bd#${blocksize}:fd#${fragsize}:\\" >> $DT
364 offset
=$
(( $offset + $part_size ))
365 elif [ "$ename" = "" ]; then
367 _size
=$
(( $part_size * $sizemult ))
368 _offset
=$
(( $offset * $sizemult ))
369 echo -n " :pe#${_size}:oe#${_offset}" >> $DT
370 echo ":te=4.2BSD:be#${blocksize}:fe#${fragsize}:\\" >> $DT
371 offset
=$
(( $offset + $part_size ))
372 elif [ "$fname" = "" ]; then
374 _size
=$
(( $part_size * $sizemult ))
375 _offset
=$
(( $offset * $sizemult ))
376 echo -n " :pf#${_size}:of#${_offset}" >> $DT
377 echo ":tf=4.2BSD:bf#${blocksize}:ff#${fragsize}:\\" >> $DT
378 offset
=$
(( $offset + $part_size ))
379 elif [ "$gname" = "" ]; then
381 _size
=$
(( $part_size * $sizemult ))
382 _offset
=$
(( $offset * $sizemult ))
383 echo -n " :pg#${_size}:og#${_offset}" >> $DT
384 echo ":tg=4.2BSD:bg#${blocksize}:fg#${fragsize}:\\" >> $DT
385 offset
=$
(( $offset + $part_size ))
386 elif [ "$hname" = "" ]; then
388 _size
=$
(( $part_size * $sizemult ))
389 _offset
=$
(( $offset * $sizemult ))
390 echo -n " :ph#${_size}:oh#${_offset}" >> $DT
391 echo ":th=4.2BSD:bh#${blocksize}:fh#${fragsize}:\\" >> $DT
399 echo "THIS IS YOUR LAST CHANCE!!!"
401 echo -n "Are you SURE you want NetBSD installed on your hard drive? (yes/no) "
403 while [ "$answer" = "" ]; do
413 echo -n "OK, then. enter 'halt' to halt the machine. "
414 echo "Once the machine has halted,"
415 echo -n "remove the floppy, and press any key to "
420 echo -n "I want a yes or no answer... well? "
426 echo -n "Labeling disk $drivename..."
427 $DONTDOIT disklabel
-w -r $drivename $labelname
430 if [ "$sect_fwd" = "sf:" ]; then
431 echo -n "Initializing bad144 badblock table..."
432 $DONTDOIT bad144
$drivename 0
436 echo "Initializing root filesystem, and mounting..."
437 $DONTDOIT newfs
/dev
/r
${drivename}a
$name
438 $DONTDOIT mount
-v $ASYNC /dev
/${drivename}a
/mnt
439 if [ "$dname" != "" ]; then
441 echo "Initializing $dname filesystem, and mounting..."
442 $DONTDOIT newfs
/dev
/r
${drivename}d
$name
443 $DONTDOIT mkdir
-p /mnt
/$dname
444 $DONTDOIT mount
-v $ASYNC /dev
/${drivename}d
/mnt
/$dname
446 if [ "$ename" != "" ]; then
448 echo "Initializing $ename filesystem, and mounting..."
449 $DONTDOIT newfs
/dev
/r
${drivename}e
$name
450 $DONTDOIT mkdir
-p /mnt
/$ename
451 $DONTDOIT mount
-v $ASYNC /dev
/${drivename}e
/mnt
/$ename
453 if [ "$fname" != "" ]; then
455 echo "Initializing $fname filesystem, and mounting..."
456 $DONTDOIT newfs
/dev
/r
${drivename}f
$name
457 $DONTDOIT mkdir
-p /mnt
/$fname
458 $DONTDOIT mount
-v $ASYNC /dev
/${drivename}f
/mnt
/$fname
460 if [ "$gname" != "" ]; then
462 echo "Initializing $gname filesystem, and mounting..."
463 $DONTDOIT newfs
/dev
/r
${drivename}g
$name
464 $DONTDOIT mkdir
-p /mnt
/$gname
465 $DONTDOIT mount
-v $ASYNC /dev
/${drivename}g
/mnt
/$gname
467 if [ "$hname" != "" ]; then
469 echo "Initializing $hname filesystem, and mounting..."
470 $DONTDOIT newfs
/dev
/r
${drivename}h
$name
471 $DONTDOIT mkdir
-p /mnt
/$hname
472 $DONTDOIT mount
-v $ASYNC /dev
/${drivename}h
/mnt
/$hname
476 echo "Populating filesystems with bootstrapping binaries and config files"
477 $DONTDOIT pax
-Xrwpe .
/mnt
478 $DONTDOIT cp /tmp
/.hdprofile
/mnt
/.profile
481 echo -n "Creating an fstab..."
482 echo /dev
/${drivename}a
/ ffs rw
1 1 |
sed -e s
,//,/, > $FSTAB
483 echo /dev
/${drivename}b none swap sw
0 0 |
sed -e s
,//,/, >> $FSTAB
484 if [ "$dname" != "" ]; then
485 echo /dev
/${drivename}d
/$dname ffs rw
1 2 |
sed -e s
,//,/, >> $FSTAB
487 if [ "$ename" != "" ]; then
488 echo /dev
/${drivename}e
/$ename ffs rw
1 2 |
sed -e s
,//,/, >> $FSTAB
490 if [ "$fname" != "" ]; then
491 echo /dev
/${drivename}f
/$fname ffs rw
1 3 |
sed -e s
,//,/, >> $FSTAB
493 if [ "$gname" != "" ]; then
494 echo /dev
/${drivename}g
/$gname ffs rw
1 4 |
sed -e s
,//,/, >> $FSTAB
496 if [ "$hname" != "" ]; then
497 echo /dev
/${drivename}h
/$hname ffs rw
1 5 |
sed -e s
,//,/, >> $FSTAB
503 echo -n "Installing boot blocks on $drivename..."
504 $DONTDOIT rm -f /mnt
/boot
505 $DONTDOIT cp /usr
/mdec
/boot
/mnt
/boot
506 $DONTDOIT /usr
/sbin
/installboot
/dev
/r
${drivename}c
/usr
/mdec
/bootxx_ffs
512 echo "OK! The preliminary work of setting up your disk is now complete."
514 echo "The remaining tasks are:"
516 echo "To load and install the NetBSD distribution sets."
517 echo "Currently the hard drive's root filesystem is mounted on /mnt"
519 echo "To copy a NetBSD kernel to the hard drive's root filesystem."
520 echo "Once accomplished, you can boot off the hard drive."
522 echo "Consult the installation notes which will describe how to"
523 echo "install the distribution sets and kernel. Post-installation"
524 echo "configuration is also discussed therein."