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