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