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