Home | History | Annotate | Line # | Download | only in miniroot
install.md revision 1.1
      1  1.1  scw #!/bin/sh
      2  1.1  scw #
      3  1.1  scw #	$NetBSD: install.md,v 1.1 1997/12/17 22:10:31 scw Exp $
      4  1.1  scw #
      5  1.1  scw # Copyright (c) 1996 The NetBSD Foundation, Inc.
      6  1.1  scw # All rights reserved.
      7  1.1  scw #
      8  1.1  scw # This code is derived from software contributed to The NetBSD Foundation
      9  1.1  scw # by Jason R. Thorpe.
     10  1.1  scw #
     11  1.1  scw # Redistribution and use in source and binary forms, with or without
     12  1.1  scw # modification, are permitted provided that the following conditions
     13  1.1  scw # are met:
     14  1.1  scw # 1. Redistributions of source code must retain the above copyright
     15  1.1  scw #    notice, this list of conditions and the following disclaimer.
     16  1.1  scw # 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  scw #    notice, this list of conditions and the following disclaimer in the
     18  1.1  scw #    documentation and/or other materials provided with the distribution.
     19  1.1  scw # 3. All advertising materials mentioning features or use of this software
     20  1.1  scw #    must display the following acknowledgement:
     21  1.1  scw #        This product includes software developed by the NetBSD
     22  1.1  scw #        Foundation, Inc. and its contributors.
     23  1.1  scw # 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.1  scw #    contributors may be used to endorse or promote products derived
     25  1.1  scw #    from this software without specific prior written permission.
     26  1.1  scw #
     27  1.1  scw # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.1  scw # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.1  scw # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.1  scw # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
     31  1.1  scw # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.1  scw # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.1  scw # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.1  scw # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.1  scw # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.1  scw # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.1  scw # POSSIBILITY OF SUCH DAMAGE.
     38  1.1  scw #
     39  1.1  scw 
     40  1.1  scw #
     41  1.1  scw # machine dependent section of installation/upgrade script
     42  1.1  scw #
     43  1.1  scw 
     44  1.1  scw # Machine-dependent install sets
     45  1.1  scw MDSETS=""
     46  1.1  scw 
     47  1.1  scw md_set_term() {
     48  1.1  scw 	if [ ! -z "$TERM" ]; then
     49  1.1  scw 		return
     50  1.1  scw 	fi
     51  1.1  scw 	echo -n "Specify terminal type [vt100]: "
     52  1.1  scw 	getresp "vt100"
     53  1.1  scw 	TERM="$resp"
     54  1.1  scw 	export TERM
     55  1.1  scw 	# XXX call tset?
     56  1.1  scw }
     57  1.1  scw 
     58  1.1  scw __mount_kernfs() {
     59  1.1  scw 	# Make sure kernfs is mounted.
     60  1.1  scw 	if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
     61  1.1  scw 		mkdir /kern > /dev/null 2>&1
     62  1.1  scw 		/sbin/mount_kernfs /kern /kern >/dev/null 2>&1
     63  1.1  scw 	fi
     64  1.1  scw }
     65  1.1  scw 
     66  1.1  scw md_makerootwritable() {
     67  1.1  scw 	# Just remount the root device read-write.
     68  1.1  scw 	__mount_kernfs
     69  1.1  scw 	echo "Remounting root read-write..."
     70  1.1  scw 	mount -u /kern/rootdev /
     71  1.1  scw }
     72  1.1  scw 
     73  1.1  scw md_get_diskdevs() {
     74  1.1  scw 	# return available disk devices
     75  1.1  scw 	__mount_kernfs
     76  1.1  scw 	sed -n -e '/^sd[0-9] /s/ .*//p' \
     77  1.1  scw 		< /kern/msgbuf | sort -u
     78  1.1  scw }
     79  1.1  scw 
     80  1.1  scw md_get_cddevs() {
     81  1.1  scw 	# return available CDROM devices
     82  1.1  scw 	__mount_kernfs
     83  1.1  scw 	sed -n -e '/^cd[0-9] /s/ .*//p' \
     84  1.1  scw 		< /kern/msgbuf | sort -u
     85  1.1  scw }
     86  1.1  scw 
     87  1.1  scw md_get_ifdevs() {
     88  1.1  scw 	# return available network devices
     89  1.1  scw 	__mount_kernfs
     90  1.1  scw 	sed -n -e '/^le[0-9] /s/ .*//p' \
     91  1.1  scw 		< /kern/msgbuf | sort -u
     92  1.1  scw }
     93  1.1  scw 
     94  1.1  scw md_get_partition_range() {
     95  1.1  scw 	# return an expression describing the valid partition id's
     96  1.1  scw 	echo '[a-h]'
     97  1.1  scw }
     98  1.1  scw 
     99  1.1  scw md_installboot() {
    100  1.1  scw 	# install the boot block on disk $1
    101  1.1  scw 	echo "Installing boot block..."
    102  1.1  scw 	( cd /usr/mdec ;\
    103  1.1  scw 	cp -p ./bootsd /mnt/.bootsd ;\
    104  1.1  scw 	sync ; sleep 1 ; sync ;\
    105  1.1  scw 	./installboot -v /mnt/.bootsd bootxx /dev/r${1}a )
    106  1.1  scw 	echo "done."
    107  1.1  scw }
    108  1.1  scw 
    109  1.1  scw md_native_fstype() {
    110  1.1  scw }
    111  1.1  scw 
    112  1.1  scw md_native_fsopts() {
    113  1.1  scw }
    114  1.1  scw 
    115  1.1  scw md_checkfordisklabel() {
    116  1.1  scw 	# $1 is the disk to check
    117  1.1  scw 	local rval
    118  1.1  scw 
    119  1.1  scw 	disklabel $1 > /dev/null 2> /tmp/checkfordisklabel
    120  1.1  scw 	if grep "no disk label" /tmp/checkfordisklabel; then
    121  1.1  scw 		rval=1
    122  1.1  scw 	elif grep "disk label corrupted" /tmp/checkfordisklabel; then
    123  1.1  scw 		rval=2
    124  1.1  scw 	else
    125  1.1  scw 		rval=0
    126  1.1  scw 	fi
    127  1.1  scw 
    128  1.1  scw 	rm -f /tmp/checkfordisklabel
    129  1.1  scw 	return $rval
    130  1.1  scw }
    131  1.1  scw 
    132  1.1  scw md_prep_disklabel()
    133  1.1  scw {
    134  1.1  scw 	local _disk
    135  1.1  scw 
    136  1.1  scw 	_disk=$1
    137  1.1  scw 	md_checkfordisklabel $_disk
    138  1.1  scw 	case $? in
    139  1.1  scw 	0)
    140  1.1  scw 		echo -n "Do you wish to edit the disklabel on $_disk? [y]"
    141  1.1  scw 		;;
    142  1.1  scw 	1)
    143  1.1  scw 		echo "WARNING: Disk $_disk has no label"
    144  1.1  scw 		echo -n "Do you want to create one with the disklabel editor? [y]"
    145  1.1  scw 		;;
    146  1.1  scw 	2)
    147  1.1  scw 		echo "WARNING: Label on disk $_disk is corrupted"
    148  1.1  scw 		echo -n "Do you want to try and repair the damage using the disklabel editor? [y]"
    149  1.1  scw 		;;
    150  1.1  scw 	esac
    151  1.1  scw 
    152  1.1  scw 	getresp "y"
    153  1.1  scw 	case "$resp" in
    154  1.1  scw 	y*|Y*) ;;
    155  1.1  scw 	*)	return ;;
    156  1.1  scw 	esac
    157  1.1  scw 
    158  1.1  scw 	# display example
    159  1.1  scw 	cat << \__md_prep_disklabel_1
    160  1.1  scw 
    161  1.1  scw Here is an example of what the partition information will look like once
    162  1.1  scw you have entered the disklabel editor. Disk partition sizes and offsets
    163  1.1  scw are in sector (most likely 512 bytes) units. Make sure these size/offset
    164  1.1  scw pairs are on cylinder boundaries (the number of sector per cylinder is
    165  1.1  scw given in the `sectors/cylinder' entry, which is not shown here).
    166  1.1  scw 
    167  1.1  scw Do not change any parameters except the partition layout and the label name.
    168  1.1  scw It's probably also wisest not to touch the `8 partitions:' line, even
    169  1.1  scw in case you have defined less than eight partitions.
    170  1.1  scw 
    171  1.1  scw [Example]
    172  1.1  scw 8 partitions:
    173  1.1  scw #        size   offset    fstype   [fsize bsize   cpg]
    174  1.1  scw   a:    50176        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 111)
    175  1.1  scw   b:    64512    50176      swap                        # (Cyl.  112 - 255)
    176  1.1  scw   c:   640192        0   unknown                        # (Cyl.    0 - 1428)
    177  1.1  scw   d:   525504   114688    4.2BSD     1024  8192    16   # (Cyl.  256 - 1428)
    178  1.1  scw [End of example]
    179  1.1  scw 
    180  1.1  scw __md_prep_disklabel_1
    181  1.1  scw 	echo -n "Press [Enter] to continue "
    182  1.1  scw 	getresp ""
    183  1.1  scw 	edlabel /dev/r${_disk}c
    184  1.1  scw }
    185  1.1  scw 
    186  1.1  scw md_copy_kernel() {
    187  1.1  scw 	echo -n "Copying kernel..."
    188  1.1  scw 	cp -p /netbsd /mnt/netbsd
    189  1.1  scw 	echo "done."
    190  1.1  scw }
    191  1.1  scw 
    192  1.1  scw md_welcome_banner() {
    193  1.1  scw 	echo	"Welcome to the NetBSD/mvme68k ${VERSION} installation program."
    194  1.1  scw 	cat << \__welcome_banner_1
    195  1.1  scw 
    196  1.1  scw This program is designed to help you install NetBSD on your system in a simple
    197  1.1  scw and rational way.  You'll be asked several questions, and it would probably be
    198  1.1  scw useful to have your disk's hardware manual, the installation notes, and a
    199  1.1  scw calculator handy.
    200  1.1  scw 
    201  1.1  scw In particular, you will need to know some reasonably detailed information
    202  1.1  scw about your disk's geometry. The kernel will attempt to display geometry
    203  1.1  scw information for SCSI disks during boot, if possible. If you did not make it
    204  1.1  scw note of it before, you may wish to reboot and jot down your disk's geometry
    205  1.1  scw before proceeding.
    206  1.1  scw 
    207  1.1  scw As with anything which modifies your hard disk's contents, this program can
    208  1.1  scw cause SIGNIFICANT data loss, and you are advised to make sure your hard drive
    209  1.1  scw is backed up before beginning the installation process.
    210  1.1  scw 
    211  1.1  scw Default answers are displyed in brackets after the questions. You can hit
    212  1.1  scw Control-C at any time to quit, but if you do so at a prompt, you may have to
    213  1.1  scw hit return.  Also, quitting in the middle of installation may leave your
    214  1.1  scw system in an inconsistent state.
    215  1.1  scw __welcome_banner_1
    216  1.1  scw }
    217  1.1  scw 
    218  1.1  scw md_not_going_to_install() {
    219  1.1  scw 		cat << \__not_going_to_install_1
    220  1.1  scw 
    221  1.1  scw OK, then.  Enter 'halt' at the prompt to halt the machine.  Once the
    222  1.1  scw machine has halted, power-cycle the system to load new boot code.
    223  1.1  scw 
    224  1.1  scw __not_going_to_install_1
    225  1.1  scw }
    226  1.1  scw 
    227  1.1  scw md_congrats() {
    228  1.1  scw 	cat << \__congratulations_1
    229  1.1  scw 
    230  1.1  scw CONGRATULATIONS!  You have successfully installed NetBSD!  To boot the
    231  1.1  scw installed system, enter halt at the command prompt.  Once the system has
    232  1.1  scw halted, power-cycle the machine in order to load new boot code.  Make sure
    233  1.1  scw you boot from the root disk.
    234  1.1  scw 
    235  1.1  scw __congratulations_1
    236  1.1  scw }
    237  1.1  scw 
    238  1.1  scw md_native_fstype() {
    239  1.1  scw 	# Nothing to do.
    240  1.1  scw }
    241  1.1  scw 
    242  1.1  scw md_native_fsopts() {
    243  1.1  scw 	# Nothing to do.
    244  1.1  scw }
    245