1# $OpenBSD: install.md,v 1.18 2017/02/20 16:13:35 visa 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 34MDDKDEVS='/^[sw]d[0-9] /s/ .*//p;/^octcf[0-9] /s/ .*//p' 35 36md_installboot() { 37 local _disk=$1 38 39 if mount -t msdos /dev/${_disk}i /mnt2 && \ 40 cp /mnt/bsd /mnt2/bsd && cp /mnt/bsd.rd /mnt2/bsd.rd; then 41 umount /mnt2 42 return 43 fi 44 45 echo "Failed to install bootblocks." 46 echo "You will not be able to boot OpenBSD from $_disk." 47 exit 48} 49 50md_prep_fdisk() { 51 local _disk=$1 _q _d 52 53 while :; do 54 _d=whole 55 if disk_has $_disk mbr; then 56 fdisk $_disk 57 if disk_has $_disk mbr openbsd; then 58 _q=", use the (O)penBSD area" 59 _d=OpenBSD 60 fi 61 else 62 echo "MBR has invalid signature; not showing it." 63 fi 64 ask "Use (W)hole disk$_q or (E)dit the MBR?" "$_d" 65 case $resp in 66 [wW]*) 67 echo -n "Creating a FAT partition and an OpenBSD partition for rest of $_disk..." 68 fdisk -e ${_disk} <<__EOT >/dev/null 69reinit 70e 0 71C 72n 7364 7465536 75f 0 76e 3 77A6 78n 7965600 80 81write 82quit 83__EOT 84 echo "done." 85 disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk 86 newfs -t msdos ${_disk}i 87 return ;; 88 [eE]*) 89 # Manually configure the MBR. 90 cat <<__EOT 91 92You will now create one MBR partition to contain your OpenBSD data 93and one MBR partition on which kernels are located which are loaded 94by U-Boot. Neither partition will overlap any other partition. 95 96The OpenBSD MBR partition will have an id of 'A6' and the boot MBR 97partition will have an id of 'C' (MSDOS). The boot partition will be 98at least 32MB and be the first 'MSDOS' partition on the disk. 99 100$(fdisk ${_disk}) 101__EOT 102 fdisk -e ${_disk} 103 disk_has $_disk mbr openbsd && return 104 echo No OpenBSD partition in MBR, try again. ;; 105 [oO]*) 106 [[ $_d == OpenBSD ]] || continue 107 return ;; 108 esac 109 done 110} 111 112md_prep_disklabel() { 113 local _disk=$1 _f=/tmp/i/fstab.$1 114 115 md_prep_fdisk $_disk 116 117 disklabel_autolayout $_disk $_f || return 118 [[ -s $_f ]] && return 119 120 # Edit disklabel manually. 121 # Abandon all hope, ye who enter here. 122 disklabel -F $_f -E $_disk 123} 124 125md_congrats() { 126 cat <<__EOT 127 128INSTALL.$ARCH describes how to configure U-Boot to boot OpenBSD. 129__EOT 130} 131 132md_consoleinfo() { 133} 134