1#	$NetBSD: install.md,v 1.6 2019/04/10 14:52:53 christos Exp $
2#
3#
4# Copyright (c) 1996 The NetBSD Foundation, Inc.
5# All rights reserved.
6#
7# This code is derived from software contributed to The NetBSD Foundation
8# by Jason R. Thorpe.
9#
10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions
12# are met:
13# 1. Redistributions of source code must retain the above copyright
14#    notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright
16#    notice, this list of conditions and the following disclaimer in the
17#    documentation and/or other materials provided with the distribution.
18#
19# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30#
31
32#
33# machine dependent section of installation/upgrade script.
34#
35
36VERSION=				# filled in automatically (see list)
37export VERSION
38
39md_set_term() {
40	if [ ! -z "$TERM" ]; then
41		return
42	fi
43	echo -n "Specify terminal type [vt220]: "
44	getresp "vt220"
45	TERM="$resp"
46	export TERM
47}
48
49md_makerootwritable() {
50	# Mount root rw for convenience of the tester ;-)
51	if [ ! -e /tmp/.root_writable ]; then
52		__mount_kernfs
53		mount -u /kern/rootdev /
54		cp /dev/null /tmp/.root_writable
55	fi
56}
57
58md_get_diskdevs() {
59	# return available disk devices
60	mi_mount_kernfs
61	mi_filter_msgbuf | sed -ne '/^[sw]d[0-9] /s/ .*//p'
62}
63
64md_prep_disklabel()
65{
66	# $1 is the root disk
67	# Note that the first part of this function is just a *very* verbose
68	# version of md_label_disk().
69
70	cat << \__md_prep_disklabel_1
71You now have to prepare your root disk for the installation of NetBSD. This
72is further referred to as 'labeling' a disk.
73
74First you get the chance to edit or create an AHDI compatible partitioning on
75the installation disk. Note that NetBSD can do without AHDI partitions,
76check the documentation.
77If you want to use an AHDI compatible partitioning, you have to assign some
78partitions to NetBSD before NetBSD is able to use the disk. Change the 'id'
79of all partitions you want to use for NetBSD filesystems to 'NBD'. Change
80the 'id' of the partition you wish to use for swap to 'SWP'.
81
82Hit the <return> key when you have read this...
83__md_prep_disklabel_1
84	getresp ""
85	ahdilabel /dev/r${1}c
86
87	# display example
88	cat << \__md_prep_disklabel_3
89Here is an example of what the partition information will look like once
90you have entered the disklabel editor. Disk partition sizes and offsets
91are in sector (most likely 512 bytes) units.
92
93[Example]
94partition      start         (c/t/s)      nblks         (c/t/s)  type
95
96 a (root)          0       (0/00/00)      31392     (109/00/00)  4.2BSD
97 b (swap)      31392     (109/00/00)      73440     (255/00/00)  swap
98 c (disk)          0       (0/00/00)    1070496    (3717/00/00)  unused
99 d (user)     104832     (364/00/00)      30528     (106/00/00)  4.2BSD
100 e (user)     135360     (470/00/00)      40896     (142/00/00)  4.2BSD
101 f (user)     176256     (612/00/00)      92160     (320/00/00)  4.2BSD
102 g (user)     268416     (932/00/00)     802080    (2785/00/00)  4.2BSD
103
104[End of example]
105
106Hit the <return> key when you have read this...
107
108__md_prep_disklabel_3
109	getresp ""
110	edlabel /dev/r${1}c
111
112	cat << \__md_prep_disklabel_4
113
114You will now be given the opportunity to place disklabels on any additional
115disks on your system.
116__md_prep_disklabel_4
117
118	_DKDEVS=$(rmel ${1} ${_DKDEVS})
119	resp="not-done"	# force at least one iteration
120	while [ "$resp" != "done" ]; do
121		labelmoredisks
122	done
123}
124
125md_labeldisk() {
126	edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
127	[ $? -eq 0 ] && edahdi /dev/r${1}c
128	edlabel /dev/r${1}c
129}
130
131md_welcome_banner() {
132	echo ""
133	echo "Welcome to the NetBSD/atari ${VERSION} preparation program."
134		cat << \__welcome_banner_1
135
136This program is designed to partition your disk in preparation of the
137NetBSD installation. At this stage, the only thing you _must_ setup
138is a swap partition. If you wish, the remaining partitioning work might
139be delayed until the actual installation.
140
141As with anything which modifies your disk's contents, this
142program can cause SIGNIFICANT data loss, and you are advised
143to make sure your data is backed up before beginning the
144preparation process.
145
146Default answers are displayed in brackets after the questions.
147You can hit Control-C at any time to quit, but if you do so at a
148prompt, you may have to hit return.
149__welcome_banner_1
150}
151
152md_not_going_to_install() {
153	cat << \__not_going_to_install_1
154
155OK, then.  Enter 'halt' at the prompt to halt the machine.  Once the
156machine has halted, power-cycle the system to load new boot code.
157
158Note: If you wish to have another try. Just type '^D' at the prompt. After
159      a moment, the program will restart itself.
160
161__not_going_to_install_1
162}
163
164md_congrats() {
165	cat << __congratulations_1
166
167CONGRATULATIONS!  You have successfully partitioned your disks!
168Now you can use file2swap.ttp to transfer the install.fs to your
169swap partition and continue the installation.
170Enter halt at the command prompt. Once the system has halted, reset the
171machine and re-boot it.
172
173Note: If you wish to have another try. Just type '^D' at the prompt. After
174      a moment, the installer will restart itself.
175
176__congratulations_1
177}
178