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