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