install.md revision 1.7 1 1.7 tsutsui # $NetBSD: install.md,v 1.7 2020/12/05 18:52:06 tsutsui Exp $
2 1.1 lukem #
3 1.1 lukem #
4 1.1 lukem # Copyright (c) 1996 The NetBSD Foundation, Inc.
5 1.1 lukem # All rights reserved.
6 1.1 lukem #
7 1.1 lukem # This code is derived from software contributed to The NetBSD Foundation
8 1.1 lukem # by Jason R. Thorpe.
9 1.1 lukem #
10 1.1 lukem # Redistribution and use in source and binary forms, with or without
11 1.1 lukem # modification, are permitted provided that the following conditions
12 1.1 lukem # are met:
13 1.1 lukem # 1. Redistributions of source code must retain the above copyright
14 1.1 lukem # notice, this list of conditions and the following disclaimer.
15 1.1 lukem # 2. Redistributions in binary form must reproduce the above copyright
16 1.1 lukem # notice, this list of conditions and the following disclaimer in the
17 1.1 lukem # documentation and/or other materials provided with the distribution.
18 1.1 lukem #
19 1.1 lukem # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 lukem # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 lukem # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 lukem # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 lukem # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 lukem # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 lukem # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 lukem # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 lukem # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 lukem # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 lukem # POSSIBILITY OF SUCH DAMAGE.
30 1.1 lukem #
31 1.1 lukem
32 1.1 lukem #
33 1.1 lukem # machine dependent section of installation/upgrade script.
34 1.1 lukem #
35 1.1 lukem
36 1.1 lukem # Machine-dependent install sets
37 1.1 lukem # MDSETS="xbin xman xinc xcon" XXX
38 1.6 tsutsui MDSETS="kern-GENERIC kern-GENERIC3X xbase xcomp xetc xfont xserver"
39 1.1 lukem
40 1.1 lukem md_set_term() {
41 1.1 lukem if [ ! -z "$TERM" ]; then
42 1.1 lukem return
43 1.1 lukem fi
44 1.1 lukem echo -n "Specify terminal type [sun]: "
45 1.1 lukem getresp "sun"
46 1.1 lukem TERM="$resp"
47 1.1 lukem export TERM
48 1.1 lukem }
49 1.1 lukem
50 1.1 lukem md_makerootwritable() {
51 1.1 lukem # Just remount the root device read-write.
52 1.1 lukem if [ ! -e /tmp/root_writable ]; then
53 1.1 lukem echo "Remounting root read-write..."
54 1.5 christos mi_mount_kernfs
55 1.1 lukem mount -u /kern/rootdev /
56 1.1 lukem swapctl -a /kern/rootdev
57 1.1 lukem cp /dev/null /tmp/root_writable
58 1.1 lukem fi
59 1.1 lukem }
60 1.1 lukem
61 1.1 lukem md_get_diskdevs() {
62 1.1 lukem # return available disk devices
63 1.5 christos mi_mount_kernfs
64 1.5 christos mi_filter_msgbuf | sed -ne '/^[xs]d[0-9] /s/ .*//p' \
65 1.5 christos -e '/^xy[0-9] /s/ .*//p'
66 1.1 lukem }
67 1.1 lukem
68 1.1 lukem md_get_cddevs() {
69 1.1 lukem # return available CDROM devices
70 1.5 christos mi_mount_kernfs
71 1.5 christos mi_filter_msgbuf | sed -ne '/^cd[0-9] /s/ .*//p'
72 1.1 lukem }
73 1.1 lukem
74 1.1 lukem md_get_ifdevs() {
75 1.1 lukem # return available network devices
76 1.5 christos mi_mount_kernfs
77 1.5 christos mi_filter_msgbuf | sed -ne '/^[il]e[0-9] /s/ .*//p'
78 1.1 lukem }
79 1.1 lukem
80 1.1 lukem md_get_partition_range() {
81 1.1 lukem # return an expression describing the valid partition id's
82 1.1 lukem echo '[a-h]'
83 1.1 lukem }
84 1.1 lukem
85 1.1 lukem md_installboot() {
86 1.1 lukem # install the boot block on disk $1
87 1.1 lukem echo "Installing boot block..."
88 1.1 lukem ( cd /usr/mdec ;\
89 1.1 lukem cp -p ./ufsboot /mnt/ufsboot ;\
90 1.1 lukem sync ; sleep 1 ; sync ;\
91 1.1 lukem /usr/sbin/installboot -v /dev/r${1}a bootxx ufsboot )
92 1.1 lukem echo "done."
93 1.1 lukem }
94 1.1 lukem
95 1.1 lukem md_native_fstype() {
96 1.1 lukem }
97 1.1 lukem
98 1.1 lukem md_native_fsopts() {
99 1.1 lukem }
100 1.1 lukem
101 1.1 lukem md_prep_disklabel() {
102 1.1 lukem # $1 is the root disk
103 1.1 lukem echo -n "Do you wish to edit the disklabel on ${1}? [y]"
104 1.1 lukem getresp "y"
105 1.1 lukem case "$resp" in
106 1.1 lukem y*|Y*) ;;
107 1.1 lukem *) return ;;
108 1.1 lukem esac
109 1.1 lukem
110 1.1 lukem # display example
111 1.1 lukem cat << \__md_prep_disklabel_1
112 1.1 lukem Here is an example of what the partition information will look like once
113 1.1 lukem you have entered the disklabel editor. Disk partition sizes and offsets
114 1.1 lukem are in sector (most likely 512 bytes) units. Make sure all partitions
115 1.1 lukem start on a cylinder boundary (c/t/s == XXX/0/0).
116 1.1 lukem
117 1.1 lukem [Example]
118 1.1 lukem partition start (c/t/s) nblks (c/t/s) type
119 1.1 lukem
120 1.1 lukem a (root) 0 (0/00/00) 31392 (109/00/00) 4.2BSD
121 1.1 lukem b (swap) 31392 (109/00/00) 73440 (255/00/00) swap
122 1.1 lukem c (disk) 0 (0/00/00) 1070496 (3717/00/00) unused
123 1.1 lukem d (user) 104832 (364/00/00) 30528 (106/00/00) 4.2BSD
124 1.1 lukem e (user) 135360 (470/00/00) 40896 (142/00/00) 4.2BSD
125 1.1 lukem f (user) 176256 (612/00/00) 92160 (320/00/00) 4.2BSD
126 1.1 lukem g (user) 268416 (932/00/00) 802080 (2785/00/00) 4.2BSD
127 1.1 lukem
128 1.1 lukem [End of example]
129 1.1 lukem
130 1.1 lukem Hit the <return> key when you have read this...
131 1.1 lukem
132 1.1 lukem __md_prep_disklabel_1
133 1.1 lukem getresp ""
134 1.1 lukem edlabel /dev/r${1}c
135 1.1 lukem }
136 1.1 lukem
137 1.1 lukem md_copy_kernel() {
138 1.2 tsutsui if [ ! -f /mnt/netbsd ]; then
139 1.4 christos set -- $(sysctl -n hw.model)
140 1.2 tsutsui echo -n "No kernel set extracted. Copying $1 miniroot kernel..."
141 1.2 tsutsui cp -p /netbsd.$1 /mnt/netbsd
142 1.2 tsutsui echo "done."
143 1.2 tsutsui fi
144 1.1 lukem }
145 1.1 lukem
146 1.1 lukem md_welcome_banner() {
147 1.1 lukem if [ "$MODE" = "install" ]; then
148 1.1 lukem echo ""
149 1.7 tsutsui echo "Welcome to the NetBSD/${MACHINE} ${RELEASE} installation program."
150 1.1 lukem cat << \__welcome_banner_1
151 1.1 lukem
152 1.1 lukem This program is designed to help you put NetBSD on your disk,
153 1.1 lukem in a simple and rational way. You'll be asked several questions,
154 1.1 lukem and it would probably be useful to have your disk's hardware
155 1.1 lukem manual, the installation notes, and a calculator handy.
156 1.1 lukem __welcome_banner_1
157 1.1 lukem
158 1.1 lukem else
159 1.1 lukem echo ""
160 1.7 tsutsui echo "Welcome to the NetBSD/${MACHINE} ${RELEASE} upgrade program."
161 1.1 lukem cat << \__welcome_banner_2
162 1.1 lukem
163 1.1 lukem This program is designed to help you upgrade your NetBSD system in a
164 1.1 lukem simple and rational way.
165 1.1 lukem
166 1.4 christos As a reminder, installing the 'etc' binary set is NOT recommended.
167 1.1 lukem Once the rest of your system has been upgraded, you should manually
168 1.4 christos merge any changes to files in the 'etc' set into those files which
169 1.1 lukem already exist on your system.
170 1.1 lukem __welcome_banner_2
171 1.1 lukem fi
172 1.1 lukem
173 1.1 lukem cat << \__welcome_banner_3
174 1.1 lukem
175 1.1 lukem As with anything which modifies your disk's contents, this
176 1.1 lukem program can cause SIGNIFICANT data loss, and you are advised
177 1.1 lukem to make sure your data is backed up before beginning the
178 1.1 lukem installation process.
179 1.1 lukem
180 1.1 lukem Default answers are displayed in brackets after the questions.
181 1.1 lukem You can hit Control-C at any time to quit, but if you do so at a
182 1.1 lukem prompt, you may have to hit return. Also, quitting in the middle of
183 1.1 lukem installation may leave your system in an inconsistent state.
184 1.1 lukem
185 1.1 lukem __welcome_banner_3
186 1.1 lukem }
187 1.1 lukem
188 1.1 lukem md_not_going_to_install() {
189 1.1 lukem cat << \__not_going_to_install_1
190 1.1 lukem
191 1.4 christos OK, then. Enter 'halt' at the prompt to halt the machine. Once the
192 1.1 lukem machine has halted, power-cycle the system to load new boot code.
193 1.1 lukem
194 1.1 lukem __not_going_to_install_1
195 1.1 lukem }
196 1.1 lukem
197 1.1 lukem md_congrats() {
198 1.1 lukem local what;
199 1.1 lukem if [ "$MODE" = "install" ]; then
200 1.1 lukem what="installed";
201 1.1 lukem else
202 1.1 lukem what="upgraded";
203 1.1 lukem fi
204 1.1 lukem cat << __congratulations_1
205 1.1 lukem
206 1.1 lukem CONGRATULATIONS! You have successfully $what NetBSD!
207 1.1 lukem To boot the installed system, enter halt at the command prompt. Once the
208 1.1 lukem system has halted, reset the machine and boot from the disk.
209 1.1 lukem
210 1.1 lukem __congratulations_1
211 1.1 lukem }
212