install.md revision 1.4
1#	$OpenBSD: install.md,v 1.4 2022/02/03 10:27:33 visa 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 REGENTS OR CONTRIBUTORS BE
23# 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# machine dependent section of installation/upgrade script.
33#
34
35NCPU=$(sysctl -n hw.ncpufound)
36
37md_installboot() {
38	if ! installboot -r /mnt ${1}; then
39		echo "\nFailed to install bootblocks."
40		echo "You will not be able to boot OpenBSD from ${1}."
41		exit
42	fi
43}
44
45md_prep_fdisk() {
46	local _disk=$1 _d
47
48	local bootparttype="C"
49	local bootsectorstart="32768"
50	local bootsectorsize="32768"
51	local bootsectorend=$(($bootsectorstart + $bootsectorsize))
52	local bootfstype="msdos"
53
54	while :; do
55		_d=whole
56		if disk_has $_disk mbr; then
57			fdisk $_disk
58		else
59			echo "MBR has invalid signature; not showing it."
60		fi
61		ask "Use (W)hole disk or (E)dit the MBR?" "$_d"
62		case $resp in
63		[wW]*)
64			echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..."
65			fdisk -e ${_disk} <<__EOT >/dev/null
66reinit
67e 0
68${bootparttype}
69n
70${bootsectorstart}
71${bootsectorsize}
72f 0
73e 3
74A6
75n
76${bootsectorend}
77
78write
79quit
80__EOT
81			echo "done."
82			installboot -p $_disk
83			return ;;
84		[eE]*)
85			# Manually configure the MBR.
86			cat <<__EOT
87
88You will now create one MBR partition to contain your OpenBSD data
89and one MBR partition on which the OpenBSD boot program is located.
90Neither partition will overlap any other partition.
91
92The OpenBSD MBR partition will have an id of 'A6' and the boot MBR
93partition will have an id of '${bootparttype}' (${bootfstype}).
94The boot partition will be at least 16MB and be the first 'MSDOS'
95partition on the disk.
96
97$(fdisk ${_disk})
98__EOT
99			fdisk -e ${_disk}
100			disk_has $_disk mbr openbsd && return
101			echo No OpenBSD partition in MBR, try again. ;;
102		esac
103	done
104}
105
106md_prep_disklabel() {
107	local _disk=$1 _f=/tmp/i/fstab.$1
108
109	md_prep_fdisk $_disk
110
111	disklabel_autolayout $_disk $_f || return
112	[[ -s $_f ]] && return
113
114	# Edit disklabel manually.
115	# Abandon all hope, ye who enter here.
116	disklabel -F $_f -E $_disk
117}
118
119md_congrats() {
120}
121
122md_consoleinfo() {
123	CTTY=console
124	DEFCONS=y
125	case $CSPEED in
126	9600|19200|38400|57600|115200|1500000)
127		;;
128	*)
129		CSPEED=115200;;
130	esac
131}
132