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