install.md revision 1.4 1 1.1 scw #!/bin/sh
2 1.1 scw #
3 1.3 tv # $NetBSD: install.md,v 1.4 2003/03/07 17:00:22 he 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.3 tv mount -t ffs -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.2 scw -e '/^ie[0-9] /s/ .*//p' \
92 1.1 scw < /kern/msgbuf | sort -u
93 1.1 scw }
94 1.1 scw
95 1.1 scw md_get_partition_range() {
96 1.1 scw # return an expression describing the valid partition id's
97 1.1 scw echo '[a-h]'
98 1.1 scw }
99 1.1 scw
100 1.1 scw md_installboot() {
101 1.1 scw # install the boot block on disk $1
102 1.1 scw echo "Installing boot block..."
103 1.1 scw ( cd /usr/mdec ;\
104 1.1 scw cp -p ./bootsd /mnt/.bootsd ;\
105 1.1 scw sync ; sleep 1 ; sync ;\
106 1.1 scw ./installboot -v /mnt/.bootsd bootxx /dev/r${1}a )
107 1.1 scw echo "done."
108 1.1 scw }
109 1.1 scw
110 1.1 scw md_native_fstype() {
111 1.1 scw }
112 1.1 scw
113 1.1 scw md_native_fsopts() {
114 1.1 scw }
115 1.1 scw
116 1.4 he grep_check () {
117 1.4 he pattern=$1; shift
118 1.4 he awk 'BEGIN{ es=1; } /'"$pattern"'/{ print; es=0; } END{ exit es; }' "$@"
119 1.4 he }
120 1.4 he
121 1.1 scw md_checkfordisklabel() {
122 1.1 scw # $1 is the disk to check
123 1.1 scw local rval
124 1.1 scw
125 1.1 scw disklabel $1 > /dev/null 2> /tmp/checkfordisklabel
126 1.4 he if grep_check "no disklabel" /tmp/checkfordisklabel; then
127 1.1 scw rval=1
128 1.4 he elif grep_check "disk label corrupted" /tmp/checkfordisklabel; then
129 1.1 scw rval=2
130 1.1 scw else
131 1.1 scw rval=0
132 1.1 scw fi
133 1.1 scw
134 1.1 scw rm -f /tmp/checkfordisklabel
135 1.1 scw return $rval
136 1.1 scw }
137 1.1 scw
138 1.1 scw md_prep_disklabel()
139 1.1 scw {
140 1.1 scw local _disk
141 1.1 scw
142 1.1 scw _disk=$1
143 1.1 scw md_checkfordisklabel $_disk
144 1.1 scw case $? in
145 1.1 scw 0)
146 1.1 scw echo -n "Do you wish to edit the disklabel on $_disk? [y]"
147 1.1 scw ;;
148 1.1 scw 1)
149 1.1 scw echo "WARNING: Disk $_disk has no label"
150 1.1 scw echo -n "Do you want to create one with the disklabel editor? [y]"
151 1.1 scw ;;
152 1.1 scw 2)
153 1.1 scw echo "WARNING: Label on disk $_disk is corrupted"
154 1.1 scw echo -n "Do you want to try and repair the damage using the disklabel editor? [y]"
155 1.1 scw ;;
156 1.1 scw esac
157 1.1 scw
158 1.1 scw getresp "y"
159 1.1 scw case "$resp" in
160 1.1 scw y*|Y*) ;;
161 1.1 scw *) return ;;
162 1.1 scw esac
163 1.1 scw
164 1.1 scw # display example
165 1.1 scw cat << \__md_prep_disklabel_1
166 1.1 scw
167 1.1 scw Here is an example of what the partition information will look like once
168 1.1 scw you have entered the disklabel editor. Disk partition sizes and offsets
169 1.1 scw are in sector (most likely 512 bytes) units. Make sure these size/offset
170 1.1 scw pairs are on cylinder boundaries (the number of sector per cylinder is
171 1.1 scw given in the `sectors/cylinder' entry, which is not shown here).
172 1.1 scw
173 1.1 scw Do not change any parameters except the partition layout and the label name.
174 1.1 scw It's probably also wisest not to touch the `8 partitions:' line, even
175 1.1 scw in case you have defined less than eight partitions.
176 1.1 scw
177 1.1 scw [Example]
178 1.1 scw 8 partitions:
179 1.1 scw # size offset fstype [fsize bsize cpg]
180 1.1 scw a: 50176 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 111)
181 1.1 scw b: 64512 50176 swap # (Cyl. 112 - 255)
182 1.1 scw c: 640192 0 unknown # (Cyl. 0 - 1428)
183 1.1 scw d: 525504 114688 4.2BSD 1024 8192 16 # (Cyl. 256 - 1428)
184 1.1 scw [End of example]
185 1.1 scw
186 1.1 scw __md_prep_disklabel_1
187 1.1 scw echo -n "Press [Enter] to continue "
188 1.1 scw getresp ""
189 1.1 scw edlabel /dev/r${_disk}c
190 1.1 scw }
191 1.1 scw
192 1.1 scw md_copy_kernel() {
193 1.1 scw echo -n "Copying kernel..."
194 1.1 scw cp -p /netbsd /mnt/netbsd
195 1.1 scw echo "done."
196 1.1 scw }
197 1.1 scw
198 1.1 scw md_welcome_banner() {
199 1.1 scw echo "Welcome to the NetBSD/mvme68k ${VERSION} installation program."
200 1.1 scw cat << \__welcome_banner_1
201 1.1 scw
202 1.1 scw This program is designed to help you install NetBSD on your system in a simple
203 1.1 scw and rational way. You'll be asked several questions, and it would probably be
204 1.1 scw useful to have your disk's hardware manual, the installation notes, and a
205 1.1 scw calculator handy.
206 1.1 scw
207 1.1 scw In particular, you will need to know some reasonably detailed information
208 1.1 scw about your disk's geometry. The kernel will attempt to display geometry
209 1.1 scw information for SCSI disks during boot, if possible. If you did not make it
210 1.1 scw note of it before, you may wish to reboot and jot down your disk's geometry
211 1.1 scw before proceeding.
212 1.1 scw
213 1.1 scw As with anything which modifies your hard disk's contents, this program can
214 1.1 scw cause SIGNIFICANT data loss, and you are advised to make sure your hard drive
215 1.1 scw is backed up before beginning the installation process.
216 1.1 scw
217 1.1 scw Default answers are displyed in brackets after the questions. You can hit
218 1.1 scw Control-C at any time to quit, but if you do so at a prompt, you may have to
219 1.1 scw hit return. Also, quitting in the middle of installation may leave your
220 1.1 scw system in an inconsistent state.
221 1.1 scw __welcome_banner_1
222 1.1 scw }
223 1.1 scw
224 1.1 scw md_not_going_to_install() {
225 1.1 scw cat << \__not_going_to_install_1
226 1.1 scw
227 1.1 scw OK, then. Enter 'halt' at the prompt to halt the machine. Once the
228 1.1 scw machine has halted, power-cycle the system to load new boot code.
229 1.1 scw
230 1.1 scw __not_going_to_install_1
231 1.1 scw }
232 1.1 scw
233 1.1 scw md_congrats() {
234 1.1 scw cat << \__congratulations_1
235 1.1 scw
236 1.1 scw CONGRATULATIONS! You have successfully installed NetBSD! To boot the
237 1.1 scw installed system, enter halt at the command prompt. Once the system has
238 1.1 scw halted, power-cycle the machine in order to load new boot code. Make sure
239 1.1 scw you boot from the root disk.
240 1.1 scw
241 1.1 scw __congratulations_1
242 1.1 scw }
243 1.1 scw
244 1.1 scw md_native_fstype() {
245 1.1 scw # Nothing to do.
246 1.1 scw }
247 1.1 scw
248 1.1 scw md_native_fsopts() {
249 1.1 scw # Nothing to do.
250 1.1 scw }
251