install.md revision 1.7 1 1.7 is # $NetBSD: install.md,v 1.7 1997/11/21 21:16:41 is Exp $
2 1.1 is #
3 1.1 is #
4 1.1 is # Copyright (c) 1996 The NetBSD Foundation, Inc.
5 1.1 is # All rights reserved.
6 1.1 is #
7 1.1 is # This code is derived from software contributed to The NetBSD Foundation
8 1.1 is # by Jason R. Thorpe.
9 1.1 is #
10 1.1 is # Redistribution and use in source and binary forms, with or without
11 1.1 is # modification, are permitted provided that the following conditions
12 1.1 is # are met:
13 1.1 is # 1. Redistributions of source code must retain the above copyright
14 1.1 is # notice, this list of conditions and the following disclaimer.
15 1.1 is # 2. Redistributions in binary form must reproduce the above copyright
16 1.1 is # notice, this list of conditions and the following disclaimer in the
17 1.1 is # documentation and/or other materials provided with the distribution.
18 1.1 is # 3. All advertising materials mentioning features or use of this software
19 1.1 is # must display the following acknowledgement:
20 1.1 is # This product includes software developed by the NetBSD
21 1.1 is # Foundation, Inc. and its contributors.
22 1.1 is # 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 is # contributors may be used to endorse or promote products derived
24 1.1 is # from this software without specific prior written permission.
25 1.1 is #
26 1.1 is # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 is # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 is # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.3 jtc # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.3 jtc # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 is # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 is # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 is # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 is # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 is # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 is # POSSIBILITY OF SUCH DAMAGE.
37 1.1 is #
38 1.1 is
39 1.1 is #
40 1.1 is # machine dependent section of installation/upgrade script.
41 1.1 is #
42 1.1 is
43 1.1 is # Machine-dependent install sets
44 1.1 is MDSETS=""
45 1.1 is
46 1.1 is md_set_term() {
47 1.1 is if [ ! -z "$TERM" ]; then
48 1.1 is return
49 1.1 is fi
50 1.1 is echo -n "Specify terminal type [vt220]: "
51 1.1 is getresp "vt220"
52 1.1 is TERM="$resp"
53 1.1 is export TERM
54 1.1 is }
55 1.1 is
56 1.1 is __mount_kernfs() {
57 1.1 is #
58 1.1 is # Force kern_fs to be mounted
59 1.1 is #
60 1.1 is if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
61 1.1 is mkdir /kern > /dev/null 2>&1
62 1.1 is /sbin/mount_kernfs /kern /kern >/dev/null 2>&1
63 1.1 is fi
64 1.1 is }
65 1.1 is
66 1.1 is md_makerootwritable() {
67 1.1 is # Mount root rw for convenience of the tester ;-)
68 1.1 is if [ ! -e /tmp/.root_writable ]; then
69 1.1 is __mount_kernfs
70 1.1 is # XXX: Use /kern/rootdev instead?
71 1.5 mhitch mount -u /kern/rootdev / > /dev/null 2>&1
72 1.1 is cp /dev/null /tmp/.root_writable
73 1.1 is fi
74 1.1 is }
75 1.1 is
76 1.1 is md_get_diskdevs() {
77 1.1 is # return available disk devices
78 1.1 is __mount_kernfs
79 1.1 is sed -n -e '/^[sw]d[0-9] /s/ .*//p' \
80 1.1 is < /kern/msgbuf | sort -u
81 1.1 is }
82 1.1 is
83 1.1 is md_get_cddevs() {
84 1.1 is # return available CDROM devices
85 1.1 is __mount_kernfs
86 1.1 is sed -n -e '/^cd[0-9] /s/ .*//p' \
87 1.1 is < /kern/msgbuf | sort -u
88 1.1 is }
89 1.1 is
90 1.1 is md_get_partition_range() {
91 1.1 is # return an expression describing the valid partition id's
92 1.1 is echo '[a-p]'
93 1.1 is }
94 1.1 is
95 1.1 is md_installboot() {
96 1.1 is if [ -x /mnt/usr/mdec/installboot ]; then
97 1.1 is echo -n "Should a boot block be installed? [y] "
98 1.1 is getresp "y"
99 1.1 is case "$resp" in
100 1.1 is y*|Y*)
101 1.1 is echo "Installing boot block..."
102 1.4 mhitch chroot /mnt /usr/mdec/installboot /usr/mdec/xxboot /dev/r${1}a
103 1.1 is ;;
104 1.1 is *)
105 1.1 is echo "No bootblock installed..."
106 1.1 is ;;
107 1.1 is esac
108 1.1 is elif [ "$MODE" = "install" ]; then
109 1.1 is cat << \__md_installboot_1
110 1.1 is There is no installboot program found on the installed filesystems. No boot
111 1.1 is programs are installed.
112 1.1 is __md_installboot_1
113 1.1 is else
114 1.1 is cat << \__md_installboot_2
115 1.1 is There is no installboot program found on the upgraded filesystems. No boot
116 1.1 is programs are installed.
117 1.1 is __md_installboot_2
118 1.1 is fi
119 1.1 is }
120 1.1 is
121 1.1 is md_native_fstype() {
122 1.1 is echo "ados"
123 1.1 is }
124 1.1 is
125 1.1 is md_native_fsopts() {
126 1.6 veego echo "ro"
127 1.1 is }
128 1.1 is
129 1.1 is #md_prep_disklabel()
130 1.1 is #{
131 1.1 is # # $1 is the root disk
132 1.1 is # # Note that the first part of this function is just a *very* verbose
133 1.1 is # # version of md_label_disk().
134 1.1 is #
135 1.1 is # cat << \__md_prep_disklabel_1
136 1.1 is #You now have to prepare your root disk for the installation of NetBSD. This
137 1.1 is #is further referred to as 'labeling' a disk.
138 1.1 is #
139 1.1 is #Hit the <return> key when you have read this...
140 1.1 is #__md_prep_disklabel_1
141 1.1 is # getresp ""
142 1.1 is #
143 1.1 is # edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
144 1.1 is # if [ $? -eq 0 ]; then
145 1.1 is # cat << \__md_prep_disklabel_2
146 1.1 is #The disk you wish to install on is partitioned with AHDI or an AHDI compatible
147 1.1 is #program. You have to assign some partitions to NetBSD before NetBSD is able
148 1.1 is #to use the disk. Change the 'id' of all partitions you want to use for NetBSD
149 1.1 is #filesystems to 'NBD'. Change the 'id' of the partition you wish to use for swap
150 1.1 is #to 'NBS' or 'SWP'.
151 1.1 is #
152 1.1 is #Hit the <return> key when you have read this...
153 1.1 is #__md_prep_disklabel_2
154 1.1 is # getresp ""
155 1.1 is # edahdi /dev/r${1}c
156 1.1 is # fi
157 1.1 is #
158 1.1 is # # display example
159 1.1 is # cat << \__md_prep_disklabel_3
160 1.1 is #Here is an example of what the partition information will look like once
161 1.1 is #you have entered the disklabel editor. Disk partition sizes and offsets
162 1.1 is #are in sector (most likely 512 bytes) units.
163 1.1 is #
164 1.1 is #[Example]
165 1.1 is #partition start (c/t/s) nblks (c/t/s) type
166 1.1 is #
167 1.1 is # a (root) 0 (0/00/00) 31392 (109/00/00) 4.2BSD
168 1.1 is # b (swap) 31392 (109/00/00) 73440 (255/00/00) swap
169 1.1 is # c (disk) 0 (0/00/00) 1070496 (3717/00/00) unused
170 1.1 is # d (user) 104832 (364/00/00) 30528 (106/00/00) 4.2BSD
171 1.1 is # e (user) 135360 (470/00/00) 40896 (142/00/00) 4.2BSD
172 1.1 is # f (user) 176256 (612/00/00) 92160 (320/00/00) 4.2BSD
173 1.1 is # g (user) 268416 (932/00/00) 802080 (2785/00/00) 4.2BSD
174 1.1 is #
175 1.1 is #[End of example]
176 1.1 is #
177 1.1 is #Hit the <return> key when you have read this...
178 1.1 is #
179 1.1 is #__md_prep_disklabel_3
180 1.1 is # getresp ""
181 1.1 is # edlabel /dev/r${1}c
182 1.1 is #
183 1.1 is # cat << \__md_prep_disklabel_4
184 1.1 is #
185 1.1 is #You will now be given the opportunity to place disklabels on any additional
186 1.1 is #disks on your system.
187 1.1 is #__md_prep_disklabel_4
188 1.1 is #
189 1.1 is # _DKDEVS=`rmel ${1} ${_DKDEVS}`
190 1.1 is # resp="X" # force at least one iteration
191 1.1 is # while [ "X$resp" != X"done" ]; do
192 1.1 is # labelmoredisks
193 1.1 is # done
194 1.1 is #}
195 1.1 is #
196 1.1 is #md_labeldisk() {
197 1.1 is # edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
198 1.1 is # [ $? -eq 0 ] && edahdi /dev/r${1}c
199 1.1 is # edlabel /dev/r${1}c
200 1.1 is #}
201 1.1 is
202 1.1 is md_prep_disklabel() {
203 1.1 is }
204 1.1 is
205 1.1 is md_labeldisk() {
206 1.1 is }
207 1.1 is
208 1.1 is md_welcome_banner() {
209 1.1 is if [ "$MODE" = "install" ]; then
210 1.1 is echo ""
211 1.1 is echo "Welcome to the NetBSD/amiga ${VERSION} installation program."
212 1.1 is cat << \__welcome_banner_1
213 1.1 is
214 1.1 is This program is designed to help you put NetBSD on your disk,
215 1.1 is in a simple and rational way. You'll be asked several questions,
216 1.1 is and it would probably be useful to have your disk's hardware
217 1.1 is manual, the installation notes, and a calculator handy.
218 1.1 is __welcome_banner_1
219 1.1 is
220 1.1 is else
221 1.1 is echo ""
222 1.1 is echo "Welcome to the NetBSD/amiga ${VERSION} upgrade program."
223 1.1 is cat << \__welcome_banner_2
224 1.1 is
225 1.1 is This program is designed to help you upgrade your NetBSD system in a
226 1.1 is simple and rational way.
227 1.1 is
228 1.1 is As a reminder, installing the `etc' binary set is NOT recommended.
229 1.1 is Once the rest of your system has been upgraded, you should manually
230 1.1 is merge any changes to files in the `etc' set into those files which
231 1.1 is already exist on your system.
232 1.1 is __welcome_banner_2
233 1.1 is fi
234 1.1 is
235 1.1 is cat << \__welcome_banner_3
236 1.1 is
237 1.1 is As with anything which modifies your disk's contents, this
238 1.1 is program can cause SIGNIFICANT data loss, and you are advised
239 1.1 is to make sure your data is backed up before beginning the
240 1.1 is installation process.
241 1.1 is
242 1.1 is Default answers are displayed in brackets after the questions.
243 1.1 is You can hit Control-C at any time to quit, but if you do so at a
244 1.1 is prompt, you may have to hit return. Also, quitting in the middle of
245 1.1 is installation may leave your system in an inconsistent state.
246 1.1 is
247 1.1 is __welcome_banner_3
248 1.1 is }
249 1.1 is
250 1.1 is md_not_going_to_install() {
251 1.1 is cat << \__not_going_to_install_1
252 1.1 is
253 1.1 is OK, then. Enter `halt' at the prompt to halt the machine. Once the
254 1.1 is machine has halted, power-cycle the system to load new boot code.
255 1.1 is
256 1.1 is Note: If you wish to have another try. Just type '^D' at the prompt. After
257 1.1 is a moment, the installer will restart itself.
258 1.1 is
259 1.1 is __not_going_to_install_1
260 1.1 is }
261 1.1 is
262 1.1 is md_congrats() {
263 1.1 is local what;
264 1.1 is if [ "$MODE" = "install" ]; then
265 1.1 is what="installed";
266 1.1 is else
267 1.1 is what="upgraded";
268 1.1 is fi
269 1.1 is cat << __congratulations_1
270 1.1 is
271 1.1 is CONGRATULATIONS! You have successfully $what NetBSD!
272 1.1 is To boot the installed system, enter halt at the command prompt. Once the
273 1.1 is system has halted, reset the machine and boot from the disk.
274 1.1 is
275 1.1 is Note: If you wish to have another try. Just type '^D' at the prompt. After
276 1.1 is a moment, the installer will restart itself.
277 1.1 is
278 1.1 is __congratulations_1
279 1.1 is }
280 1.1 is
281 1.1 is md_copy_kernel() {
282 1.1 is # This is largely a copy of install_disk and install_from_mounted_fs()
283 1.1 is # with some special frobbing.
284 1.1 is
285 1.1 is local _directory
286 1.1 is local _sets
287 1.1 is local _filename
288 1.1 is local _f
289 1.7 is
290 1.7 is if [ "$MODE" = "install" ]; then
291 1.7 is echo -n "Adding keymap initialization to rc.local..."
292 1.7 is echo /usr/sbin/loadkmap ${__keymap__} >> /mnt/etc/rc.local
293 1.7 is echo "done."
294 1.7 is fi
295 1.1 is
296 1.1 is if [ -e /netbsd ]; then
297 1.1 is echo -n "Copying kernel..."
298 1.1 is cp -p /netbsd /mnt/netbsd
299 1.1 is echo "done."
300 1.1 is return
301 1.1 is fi
302 1.1 is
303 1.1 is cat << \__md_copy_kernel_1
304 1.1 is Your installation set did not include a netbsd kernel on the installation
305 1.1 is filesystem. You are now given the opportunity install it from either the
306 1.1 is kernel-floppy from the distribution or another location on one of your disks.
307 1.1 is
308 1.1 is The following disk devices are installed on your system; please select
309 1.1 is the disk device containing the partition with the netbsd kernel:
310 1.1 is __md_copy_kernel_1
311 1.1 is
312 1.1 is _DKDEVS=`md_get_diskdevs`
313 1.1 is echo "$_DKDEVS"
314 1.1 is echo "fd0"
315 1.1 is echo ""
316 1.1 is _DKDEVS="$_DKDEVS fd0" # Might be on the kernel floppy!
317 1.1 is echo -n "Which is the disk with the kernel? [abort] "
318 1.1 is
319 1.1 is if mount_a_disk ; then
320 1.1 is return # couldn't mount the disk
321 1.1 is fi
322 1.1 is
323 1.1 is # Get the directory where the file lives
324 1.1 is resp="" # force one iteration
325 1.1 is while [ "X${resp}" = X"" ]; do
326 1.1 is echo "Enter the directory relative to the mount point that"
327 1.1 is echo -n "contains the file. [${_directory}] "
328 1.1 is getresp "${_directory}"
329 1.1 is done
330 1.1 is _directory=$resp
331 1.1 is
332 1.1 is _sets=`(cd /mnt2/$_directory; ls netbsd* 2> /dev/null)`
333 1.1 is if [ -z "$_sets" ]; then
334 1.1 is echo "There are no NetBSD kernels available in \"$1\""
335 1.1 is umount -f /mnt2 > /dev/null 2>&1
336 1.1 is return
337 1.1 is fi
338 1.1 is while : ; do
339 1.1 is echo "The following kernels are available:"
340 1.1 is echo ""
341 1.1 is
342 1.1 is for _f in $_sets ; do
343 1.1 is echo " $_f"
344 1.1 is done
345 1.1 is echo ""
346 1.1 is set -- $_sets
347 1.1 is echo -n "File name [$1]? "
348 1.1 is getresp "$1"
349 1.1 is _f=$resp
350 1.1 is _filename="/mnt2/$_directory/$_f"
351 1.1 is
352 1.1 is # Ensure file exists
353 1.1 is if [ ! -f $_filename ]; then
354 1.1 is echo "File $_filename does not exist. Check to make"
355 1.1 is echo "sure you entered the information properly."
356 1.1 is echo -n "Do you want to retry [y]? "
357 1.1 is getresp "y"
358 1.1 is if [ "$resp" = "n" ]; then
359 1.1 is break
360 1.1 is fi
361 1.1 is continue
362 1.1 is fi
363 1.1 is
364 1.1 is # Copy the kernel
365 1.1 is cp $_filename /mnt
366 1.1 is break
367 1.1 is done
368 1.1 is umount -f /mnt2 > /dev/null 2>&1
369 1.1 is }
370