xref: /openbsd/distrib/loongson/ramdisk/install.md (revision 274d7c50)
1#	$OpenBSD: install.md,v 1.27 2017/01/22 23:43:54 rpe Exp $
2#
3# Copyright (c) 1996 The NetBSD Foundation, Inc.
4# All rights reserved.
5#
6# This code is derived from software contributed to The NetBSD Foundation
7# by Jason R. Thorpe.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30#
31# machine dependent section of installation/upgrade script.
32#
33
34md_installboot() {
35	local _disk=$1
36
37	# Use cat below to avoid holes created by cp(1)
38	if mount -t ext2fs /dev/${_disk}i /mnt2 &&
39	   mkdir -p /mnt2/boot &&
40	   cat /mnt/usr/mdec/boot > /mnt2/boot/boot &&
41	   { [[ $(sysctl -n hw.product) != Gdium ]] ||
42	     cp /mnt/bsd /mnt2/boot/bsd; }; then
43		umount /mnt2
44		return
45	fi
46
47	echo "Failed to install bootblocks."
48	echo "You will not be able to boot OpenBSD from $_disk."
49	exit
50}
51
52md_prep_fdisk() {
53	local _disk=$1 _q _d _s _o
54
55	while :; do
56		_d=whole
57		if disk_has $_disk mbr; then
58			fdisk $_disk
59			if disk_has $_disk mbr openbsd; then
60				_q=", use the (O)penBSD area"
61				_d=OpenBSD
62			fi
63		else
64			echo "MBR has invalid signature; not showing it."
65		fi
66		ask "Use (W)hole disk$_q or (E)dit the MBR?" "$_d"
67		case $resp in
68		[wW]*)
69			case $(sysctl -n hw.product) in
70			Gdium)
71				_s=32
72				_o="-O 1 -b 4096"
73				;;
74			EBT700)
75				_s=1
76				_o="-O 1"
77				;;
78			*)
79				_s=1
80				_o=""
81				;;
82			esac
83			echo -n "Creating a ${_s}MB ext2 partition and an OpenBSD partition for rest of $_disk..."
84			fdisk -e $_disk <<__EOT >/dev/null
85re
86e 0
8783
88
891
90$((_s * 2048))
91e 3
920
93e 3
94A6
95
96$((_s * 2048 + 1))
97*
98update
99write
100quit
101__EOT
102			echo "done."
103			disklabel $_disk 2>/dev/null | grep -q "^  i:" || disklabel -w -d $_disk
104			newfs -qt ext2fs $_o ${_disk}i
105			break ;;
106		[eE]*)
107			# Manually configure the MBR.
108			cat <<__EOT
109
110You will now create one MBR partition to contain your OpenBSD data
111and one MBR partition to contain the program that PMON uses
112to boot OpenBSD. Neither partition will overlap any other partition.
113
114The OpenBSD MBR partition will have an id of 'A6' and the boot MBR
115partition will have an id of '83' (Linux files). The boot partition will be
116at least 1MB and be the first 'Linux files' partition on the disk.
117The installer assumes there is already an ext2 or ext3 filesystem on the
118first 'Linux files' partition.
119
120$(fdisk ${_disk})
121__EOT
122			fdisk -e $_disk
123			disk_has $_disk mbr linux ||
124				{ echo "\nNo Linux files (id 83) partition!\n"; continue; }
125			disk_has $_disk mbr openbsd ||
126				{ echo "\nNo OpenBSD (id A6) partition!\n"; continue; }
127			disklabel $_disk 2>/dev/null | grep -q "^  i:" || disklabel -w -d $_disk
128			break ;;
129		[oO]*)
130			[[ $_d == OpenBSD ]] || continue
131			break ;;
132		esac
133	done
134
135}
136
137md_prep_disklabel() {
138	local _disk=$1 _f=/tmp/i/fstab.$1
139
140	md_prep_fdisk $_disk
141
142	disklabel_autolayout $_disk $_f || return
143	[[ -s $_f ]] && return
144
145	# Edit disklabel manually.
146	# Abandon all hope, ye who enter here.
147	disklabel -F $_f -E $_disk
148}
149
150md_congrats() {
151	cat <<__EOT
152
153Once the machine has rebooted use PMON to boot into OpenBSD, as
154described in the INSTALL.$ARCH document.
155To load the OpenBSD bootloader, use 'boot /dev/fs/ext2@wd0/boot/boot',
156where wd0 is the PMON name of the boot disk.
157
158__EOT
159}
160
161md_consoleinfo() {
162}
163