1# $OpenBSD: install.md,v 1.6 2011/04/17 20:57:10 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 if mount -t ext2fs /dev/${_disk}i /mnt2 ; then 39 if mkdir -p /mnt2/boot && cp /usr/mdec/boot /mnt2/boot && 40 [[ $(sysctl -n hw.product) != Gdium ]] || 41 cp /mnt/bsd /mnt2/boot/bsd; then 42 umount /mnt2 43 return 44 fi 45 fi 46 47 echo "Failed to install bootblocks." 48 echo "You will not be able to boot OpenBSD from $_disk." 49 exit 50} 51 52md_prep_fdisk() { 53 local _disk=$1 _q _d _s _o 54 55 while :; do 56 _d=whole 57 if fdisk $_disk | grep -q 'Signature: 0xAA55'; then 58 fdisk $_disk 59 if fdisk $_disk | grep -q '^..: A6 '; then 60 _q=", use the (O)penBSD area," 61 _d=OpenBSD 62 fi 63 else 64 echo "MBR has invalid signature; not showing it." 65 fi 66 ask "Use (W)hole disk$_q or (E)dit the MBR?" "$_d" 67 case $resp in 68 w*|W*) 69 if [ $(sysctl -n hw.product) = Gdium ]; then 70 _s=32 71 _o="-O 1 -b 4096" 72 else 73 _s=1 74 _o="" 75 fi 76 echo -n "Creating a ${_s}MB ext2 partition and an OpenBSD partition for rest of $_disk..." 77 fdisk -e $_disk <<__EOT >/dev/null 78re 79e 0 80 81 821 83$(expr $_s \* 2048) 84e 3 850 86e 3 87A6 88 89$(expr $_s \* 2048 + 1) 90* 91update 92write 93quit 94__EOT 95 echo "done." 96 disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk 97 newfs -qt ext2fs $_o ${_disk}i 98 break ;; 99 e*|E*) 100 # Manually configure the MBR. 101 cat <<__EOT 102 103You will now create one MBR partition to contain your OpenBSD data 104and one MBR partition to contain the program that PMON uses 105to boot OpenBSD. Neither partition will overlap any other partition. 106 107The OpenBSD MBR partition will have an id of 'A6' and the boot MBR 108partition will have an id of '83' (Linux files). The boot partition will be 109at least 1MB and be the first 'Linux files' partition on the disk. 110The installer assumes there is already an ext2 or ext3 filesystem on the 111first 'Linux files' partition. 112 113$(fdisk ${_disk}) 114__EOT 115 fdisk -e $_disk 116 fdisk $_disk | grep -q '^..: 83 ' || \ 117 { echo "\nNo Linux files (id 83) partition!\n" ; continue ; } 118 fdisk $_disk | grep -q "^..: A6 " || \ 119 { echo "\nNo OpenBSD (id A6) partition!\n" ; continue ; } 120 disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk 121 break ;; 122 o*|O*) break ;; 123 esac 124 done 125 126} 127 128md_prep_disklabel() { 129 local _disk=$1 _f _op 130 131 md_prep_fdisk $_disk 132 133 disklabel -W $_disk >/dev/null 2>&1 134 _f=/tmp/fstab.$_disk 135 if [[ $_disk == $ROOTDISK ]]; then 136 while :; do 137 echo "The auto-allocated layout for $_disk is:" 138 disklabel -h -A $_disk | egrep "^# |^ [a-p]:" 139 ask "Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout?" a 140 case $resp in 141 a*|A*) _op=-w ; AUTOROOT=y ;; 142 e*|E*) _op=-E ;; 143 c*|C*) break ;; 144 *) continue ;; 145 esac 146 disklabel $FSTABFLAG $_f $_op -A $_disk 147 return 148 done 149 fi 150 151 cat <<__EOT 152 153You will now create an OpenBSD disklabel inside the OpenBSD MBR 154partition. The disklabel defines how OpenBSD splits up the MBR partition 155into OpenBSD partitions in which filesystems and swap space are created. 156You must provide each filesystem's mountpoint in this program. 157 158The offsets used in the disklabel are ABSOLUTE, i.e. relative to the 159start of the disk, NOT the start of the OpenBSD MBR partition. 160 161__EOT 162 163 disklabel $FSTABFLAG $_f -E $_disk 164} 165 166md_congrats() { 167 cat <<__EOT 168 169Once the machine has rebooted use PMON to boot into OpenBSD, as 170described in the INSTALL.$ARCH document. 171To load the OpenBSD bootloader, use 'boot /dev/fs/ext2@wd0/boot/boot', 172where wd0 is the PMON name of the boot disk. 173 174__EOT 175} 176 177md_consoleinfo() { 178} 179