install.md revision 1.2.10.1 1 #!/bin/sh
2 #
3 # $NetBSD: install.md,v 1.2.10.1 2001/08/16 19:16:46 tv 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
45 MDSETS=""
46
47 md_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
66 md_makerootwritable() {
67 # Just remount the root device read-write.
68 __mount_kernfs
69 echo "Remounting root read-write..."
70 mount -t ffs -u /kern/rootdev /
71 }
72
73 md_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
80 md_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
87 md_get_ifdevs() {
88 # return available network devices
89 __mount_kernfs
90 sed -n -e '/^le[0-9] /s/ .*//p' \
91 -e '/^ie[0-9] /s/ .*//p' \
92 < /kern/msgbuf | sort -u
93 }
94
95 md_get_partition_range() {
96 # return an expression describing the valid partition id's
97 echo '[a-h]'
98 }
99
100 md_installboot() {
101 # install the boot block on disk $1
102 echo "Installing boot block..."
103 ( cd /usr/mdec ;\
104 cp -p ./bootsd /mnt/.bootsd ;\
105 sync ; sleep 1 ; sync ;\
106 ./installboot -v /mnt/.bootsd bootxx /dev/r${1}a )
107 echo "done."
108 }
109
110 md_native_fstype() {
111 }
112
113 md_native_fsopts() {
114 }
115
116 md_checkfordisklabel() {
117 # $1 is the disk to check
118 local rval
119
120 disklabel $1 > /dev/null 2> /tmp/checkfordisklabel
121 if grep "no disk label" /tmp/checkfordisklabel; then
122 rval=1
123 elif grep "disk label corrupted" /tmp/checkfordisklabel; then
124 rval=2
125 else
126 rval=0
127 fi
128
129 rm -f /tmp/checkfordisklabel
130 return $rval
131 }
132
133 md_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
162 Here is an example of what the partition information will look like once
163 you have entered the disklabel editor. Disk partition sizes and offsets
164 are in sector (most likely 512 bytes) units. Make sure these size/offset
165 pairs are on cylinder boundaries (the number of sector per cylinder is
166 given in the `sectors/cylinder' entry, which is not shown here).
167
168 Do not change any parameters except the partition layout and the label name.
169 It's probably also wisest not to touch the `8 partitions:' line, even
170 in case you have defined less than eight partitions.
171
172 [Example]
173 8 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 edlabel /dev/r${_disk}c
185 }
186
187 md_copy_kernel() {
188 echo -n "Copying kernel..."
189 cp -p /netbsd /mnt/netbsd
190 echo "done."
191 }
192
193 md_welcome_banner() {
194 echo "Welcome to the NetBSD/mvme68k ${VERSION} installation program."
195 cat << \__welcome_banner_1
196
197 This program is designed to help you install NetBSD on your system in a simple
198 and rational way. You'll be asked several questions, and it would probably be
199 useful to have your disk's hardware manual, the installation notes, and a
200 calculator handy.
201
202 In particular, you will need to know some reasonably detailed information
203 about your disk's geometry. The kernel will attempt to display geometry
204 information for SCSI disks during boot, if possible. If you did not make it
205 note of it before, you may wish to reboot and jot down your disk's geometry
206 before proceeding.
207
208 As with anything which modifies your hard disk's contents, this program can
209 cause SIGNIFICANT data loss, and you are advised to make sure your hard drive
210 is backed up before beginning the installation process.
211
212 Default answers are displyed in brackets after the questions. You can hit
213 Control-C at any time to quit, but if you do so at a prompt, you may have to
214 hit return. Also, quitting in the middle of installation may leave your
215 system in an inconsistent state.
216 __welcome_banner_1
217 }
218
219 md_not_going_to_install() {
220 cat << \__not_going_to_install_1
221
222 OK, then. Enter 'halt' at the prompt to halt the machine. Once the
223 machine has halted, power-cycle the system to load new boot code.
224
225 __not_going_to_install_1
226 }
227
228 md_congrats() {
229 cat << \__congratulations_1
230
231 CONGRATULATIONS! You have successfully installed NetBSD! To boot the
232 installed system, enter halt at the command prompt. Once the system has
233 halted, power-cycle the machine in order to load new boot code. Make sure
234 you boot from the root disk.
235
236 __congratulations_1
237 }
238
239 md_native_fstype() {
240 # Nothing to do.
241 }
242
243 md_native_fsopts() {
244 # Nothing to do.
245 }
246