1# $OpenBSD: install.md,v 1.25 2016/02/08 17:28:09 krw 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 35md_installboot() { 36 local _disk=$1 37 38 # Use cat below to avoid holes created by cp(1) 39 if mount -t ext2fs /dev/${_disk}i /mnt2 && 40 mkdir -p /mnt2/boot && 41 cat /mnt/usr/mdec/boot > /mnt2/boot/boot && 42 { [[ $(sysctl -n hw.product) != Gdium ]] || 43 cp /mnt/bsd /mnt2/boot/bsd; }; then 44 umount /mnt2 45 return 46 fi 47 48 echo "Failed to install bootblocks." 49 echo "You will not be able to boot OpenBSD from $_disk." 50 exit 51} 52 53md_prep_fdisk() { 54 local _disk=$1 _q _d _s _o 55 56 while :; do 57 _d=whole 58 if disk_has $_disk mbr; then 59 fdisk $_disk 60 if disk_has $_disk mbr openbsd; then 61 _q=", use the (O)penBSD area" 62 _d=OpenBSD 63 fi 64 else 65 echo "MBR has invalid signature; not showing it." 66 fi 67 ask "Use (W)hole disk$_q or (E)dit the MBR?" "$_d" 68 case $resp in 69 [wW]*) 70 case $(sysctl -n hw.product) in 71 Gdium) 72 _s=32 73 _o="-O 1 -b 4096" 74 ;; 75 EBT700) 76 _s=1 77 _o="-O 1" 78 ;; 79 *) 80 _s=1 81 _o="" 82 ;; 83 esac 84 echo -n "Creating a ${_s}MB ext2 partition and an OpenBSD partition for rest of $_disk..." 85 fdisk -e $_disk <<__EOT >/dev/null 86re 87e 0 8883 89 901 91$((_s * 2048)) 92e 3 930 94e 3 95A6 96 97$((_s * 2048 + 1)) 98* 99update 100write 101quit 102__EOT 103 echo "done." 104 disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk 105 newfs -qt ext2fs $_o ${_disk}i 106 break ;; 107 [eE]*) 108 # Manually configure the MBR. 109 cat <<__EOT 110 111You will now create one MBR partition to contain your OpenBSD data 112and one MBR partition to contain the program that PMON uses 113to boot OpenBSD. Neither partition will overlap any other partition. 114 115The OpenBSD MBR partition will have an id of 'A6' and the boot MBR 116partition will have an id of '83' (Linux files). The boot partition will be 117at least 1MB and be the first 'Linux files' partition on the disk. 118The installer assumes there is already an ext2 or ext3 filesystem on the 119first 'Linux files' partition. 120 121$(fdisk ${_disk}) 122__EOT 123 fdisk -e $_disk 124 disk_has $_disk mbr linux || 125 { echo "\nNo Linux files (id 83) partition!\n"; continue; } 126 disk_has $_disk mbr openbsd || 127 { echo "\nNo OpenBSD (id A6) partition!\n"; continue; } 128 disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk 129 break ;; 130 [oO]*) 131 [[ $_d == OpenBSD ]] || continue 132 break ;; 133 esac 134 done 135 136} 137 138md_prep_disklabel() { 139 local _disk=$1 _f=/tmp/fstab.$1 140 141 md_prep_fdisk $_disk 142 143 disklabel_autolayout $_disk $_f || return 144 [[ -s $_f ]] && return 145 146 # Edit disklabel manually. 147 # Abandon all hope, ye who enter here. 148 disklabel -F $_f -E $_disk 149} 150 151md_congrats() { 152 cat <<__EOT 153 154Once the machine has rebooted use PMON to boot into OpenBSD, as 155described in the INSTALL.$ARCH document. 156To load the OpenBSD bootloader, use 'boot /dev/fs/ext2@wd0/boot/boot', 157where wd0 is the PMON name of the boot disk. 158 159__EOT 160} 161 162md_consoleinfo() { 163} 164