1# $OpenBSD: install.md,v 1.10 2022/09/11 04:38:28 gkoehler 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 bootfstype="msdos" 52 53 while :; do 54 _d=whole 55 if disk_has $_disk mbr; then 56 fdisk $_disk 57 else 58 echo "MBR has invalid signature; not showing it." 59 fi 60 ask "Use (W)hole disk or (E)dit the MBR?" "$_d" 61 case $resp in 62 [wW]*) 63 echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..." 64 fdisk -iy -b "${bootsectorsize}@${bootsectorstart}:${bootparttype}" ${_disk} >/dev/null 65 echo "done." 66 installboot -p $_disk 67 return ;; 68 [eE]*) 69 # Manually configure the MBR. 70 cat <<__EOT 71 72You will now create one MBR partition to contain your OpenBSD data 73and one MBR partition on which the OpenBSD boot program is located. 74Neither partition will overlap any other partition. 75 76The OpenBSD MBR partition will have an id of 'A6' and the boot MBR 77partition will have an id of '${bootparttype}' (${bootfstype}). 78The boot partition will be at least 16MB and be the first 'MSDOS' 79partition on the disk. 80 81$(fdisk ${_disk}) 82__EOT 83 fdisk -e ${_disk} 84 disk_has $_disk mbr openbsd && return 85 echo No OpenBSD partition in MBR, try again. ;; 86 esac 87 done 88} 89 90md_prep_disklabel() { 91 local _disk=$1 _f=/tmp/i/fstab.$1 92 93 md_prep_fdisk $_disk 94 95 disklabel_autolayout $_disk $_f || return 96 [[ -s $_f ]] && return 97 98 # Edit disklabel manually. 99 # Abandon all hope, ye who enter here. 100 disklabel -F $_f -E $_disk 101} 102 103md_congrats() { 104} 105 106md_consoleinfo() { 107} 108