install.md revision 1.6
1# $OpenBSD: install.md,v 1.6 2022/02/06 11:29:18 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 _type=MBR 47 48 local bootpart= 49 local bootparttype="C" 50 local bootsectorstart="32768" 51 local bootsectorsize="32768" 52 local bootfstype="msdos" 53 54 while :; do 55 _d=whole 56 if disk_has $_disk gpt; then 57 [[ $_disk == $ROOTDISK ]] && bootpart="-b ${bootsectorsize}" 58 _type=GPT 59 fdisk $_disk 60 elif disk_has $_disk mbr; then 61 fdisk $_disk 62 else 63 echo "MBR has invalid signature; not showing it." 64 fi 65 ask "Use (W)hole disk or (E)dit the ${_type}?" "$_d" 66 case $resp in 67 [wW]*) 68 echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..." 69 if disk_has $_disk gpt biosboot; then 70 # Preserve BIOS boot partition as it might 71 # contain a PolarFire SoC HSS payload. 72 fdisk -Ay ${bootpart} ${_disk} >/dev/null 73 elif disk_has $_disk gpt; then 74 fdisk -gy ${bootpart} ${_disk} >/dev/null 75 else 76 fdisk -iy -b "${bootsectorsize}@${bootsectorstart}:${bootparttype}" ${_disk} >/dev/null 77 fi 78 echo "done." 79 installboot -p $_disk 80 return ;; 81 [eE]*) 82 if disk_has $_disk gpt; then 83 # Manually configure the GPT. 84 cat <<__EOT 85 86You will now create two GPT partitions. The first must have an id 87of 'EF' and be large enough to contain the OpenBSD boot programs, 88at least 32768 blocks. The second must have an id of 'A6' and will 89contain your OpenBSD data. Neither may overlap other partitions. 90Inside the fdisk command, the 'manual' command describes the fdisk 91commands in detail. 92 93$(fdisk $_disk) 94__EOT 95 fdisk -e $_disk 96 97 if ! disk_has $_disk gpt openbsd; then 98 echo -n "No OpenBSD partition in GPT," 99 elif ! disk_has $_disk gpt efisys; then 100 echo -n "No EFI Sys partition in GPT," 101 else 102 return 103 fi 104 else 105 # Manually configure the MBR. 106 cat <<__EOT 107 108You will now create one MBR partition to contain your OpenBSD data 109and one MBR partition on which the OpenBSD boot program is located. 110Neither partition will overlap any other partition. 111 112The OpenBSD MBR partition will have an id of 'A6' and the boot MBR 113partition will have an id of '${bootparttype}' (${bootfstype}). 114The boot partition will be at least 16MB and be the first 'MSDOS' 115partition on the disk. 116 117$(fdisk ${_disk}) 118__EOT 119 fdisk -e ${_disk} 120 disk_has $_disk mbr openbsd && return 121 echo -n "No OpenBSD partition in MBR," 122 fi 123 echo "try again." ;; 124 esac 125 done 126} 127 128md_prep_disklabel() { 129 local _disk=$1 _f=/tmp/i/fstab.$1 130 131 md_prep_fdisk $_disk 132 133 disklabel_autolayout $_disk $_f || return 134 [[ -s $_f ]] && return 135 136 # Edit disklabel manually. 137 # Abandon all hope, ye who enter here. 138 disklabel -F $_f -E $_disk 139} 140 141md_congrats() { 142} 143 144md_consoleinfo() { 145 CTTY=console 146 DEFCONS=y 147 case $CSPEED in 148 9600|19200|38400|57600|115200|1500000) 149 ;; 150 *) 151 CSPEED=115200;; 152 esac 153} 154