diff options
| -rw-r--r-- | distrib/amd64/common/install.md | 30 | ||||
| -rw-r--r-- | distrib/armish/ramdisk/install.md | 8 | ||||
| -rw-r--r-- | distrib/armv7/ramdisk/install.md | 6 | ||||
| -rw-r--r-- | distrib/i386/common/install.md | 8 | ||||
| -rw-r--r-- | distrib/landisk/ramdisk/install.md | 8 | ||||
| -rw-r--r-- | distrib/loongson/ramdisk/install.md | 10 | ||||
| -rw-r--r-- | distrib/macppc/ramdisk/install.md | 40 | ||||
| -rw-r--r-- | distrib/miniroot/install.sub | 42 | ||||
| -rw-r--r-- | distrib/octeon/ramdisk/install.md | 8 | ||||
| -rw-r--r-- | distrib/socppc/ramdisk/install.md | 8 | ||||
| -rw-r--r-- | distrib/zaurus/ramdisk/install.md | 8 |
11 files changed, 98 insertions, 78 deletions
diff --git a/distrib/amd64/common/install.md b/distrib/amd64/common/install.md index 15a01a62c98..5ffccde57a4 100644 --- a/distrib/amd64/common/install.md +++ b/distrib/amd64/common/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.47 2015/12/02 21:17:16 krw Exp $ +# $OpenBSD: install.md,v 1.48 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -59,20 +59,13 @@ md_prep_fdisk() { [[ $MDEFI == y ]] && _d=gpt - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr openbsd || disk_has $_disk gpt openbsd; then + _q="$_q, (O)penBSD area" + _d=OpenBSD fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then - _d=OpenBSD - fi - elif fdisk $_disk | grep -q "First usable LBA:"; then - fdisk $_disk - if fdisk $_disk | grep -q "^ OpenBSD "; then - _d=OpenBSD - fi else echo "No valid MBR or GPT." fi - [[ $_d == OpenBSD ]] && _q="$_q, (O)penBSD area" ask "$_q or (E)dit?" "$_d" case $resp in @@ -92,7 +85,7 @@ md_prep_fdisk() { echo "done." return ;; e*|E*) - if fdisk $_disk | grep -q "First usable LBA:"; then + if disk_has $_disk gpt; then # Manually configure the GPT. cat <<__EOT @@ -106,11 +99,10 @@ commands in detail. $(fdisk $_disk) __EOT fdisk -e $_disk - _d=$(fdisk $_disk | grep "^ OpenBSD ") - _q=$(fdisk $_disk | grep "^ EFI Sys ") - if [[ -z $_d ]]; then + + if ! disk_has $_disk gpt openbsd; then echo -n "No OpenBSD partition in GPT," - elif [[ -z $_q ]]; then + elif ! disk_has $_disk gpt efisys; then echo -n "No EFI Sys partition in GPT," else return @@ -127,15 +119,13 @@ must be marked as the only active partition. Inside the fdisk command, the $(fdisk $_disk) __EOT fdisk -e $_disk - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo -n "No OpenBSD partition in MBR," fi echo "try again." ;; o*|O*) [[ $_d == OpenBSD ]] || continue - _d=$(fdisk $_disk | grep "First usable LBA:") - _q=$(fdisk $_disk | grep "^ EFI Sys ") - if [[ -n $_d && -z $_q ]]; then + if disk_has $_disk gpt && ! disk_has $_disk gpt efisys; then echo "No EFI Sys partition in GPT, try again." continue fi diff --git a/distrib/armish/ramdisk/install.md b/distrib/armish/ramdisk/install.md index ca438a9dd70..556fefe7c0d 100644 --- a/distrib/armish/ramdisk/install.md +++ b/distrib/armish/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.23 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.24 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -40,9 +40,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -68,7 +68,7 @@ must be marked as the only active partition. Inside the fdisk command, the $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; o*|O*) [[ $_d == OpenBSD ]] || continue diff --git a/distrib/armv7/ramdisk/install.md b/distrib/armv7/ramdisk/install.md index 926ac855e3d..98b15791ace 100644 --- a/distrib/armv7/ramdisk/install.md +++ b/distrib/armv7/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.20 2015/12/02 21:57:50 krw Exp $ +# $OpenBSD: install.md,v 1.21 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -166,7 +166,7 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk else echo "MBR has invalid signature; not showing it." @@ -210,7 +210,7 @@ at least 16MB and be the first 'MSDOS' partition on the disk. $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; esac done diff --git a/distrib/i386/common/install.md b/distrib/i386/common/install.md index be572ae0e41..d351d2cecf4 100644 --- a/distrib/i386/common/install.md +++ b/distrib/i386/common/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.67 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.68 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -51,9 +51,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -79,7 +79,7 @@ must be marked as the only active partition. Inside the fdisk command, the $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; o*|O*) [[ $_d == OpenBSD ]] || continue diff --git a/distrib/landisk/ramdisk/install.md b/distrib/landisk/ramdisk/install.md index 3fd3ee4893a..9e9a74d0372 100644 --- a/distrib/landisk/ramdisk/install.md +++ b/distrib/landisk/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.38 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.39 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -45,9 +45,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -73,7 +73,7 @@ must be marked as the only active partition. Inside the fdisk command, the $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; o*|O*) [[ $_d == OpenBSD ]] || continue diff --git a/distrib/loongson/ramdisk/install.md b/distrib/loongson/ramdisk/install.md index 8b3e710d72c..457e48032a8 100644 --- a/distrib/loongson/ramdisk/install.md +++ b/distrib/loongson/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.22 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.23 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -55,9 +55,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -121,9 +121,9 @@ first 'Linux files' partition. $(fdisk ${_disk}) __EOT fdisk -e $_disk - fdisk $_disk | grep -q '^..: 83 ' || \ + disk_has $_disk mbr linux || { echo "\nNo Linux files (id 83) partition!\n"; continue; } - fdisk $_disk | grep -q "^..: A6 " || \ + disk_has $_disk mbr openbsd || { echo "\nNo OpenBSD (id A6) partition!\n"; continue; } disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk break ;; diff --git a/distrib/macppc/ramdisk/install.md b/distrib/macppc/ramdisk/install.md index 37616957f95..9bf321eeede 100644 --- a/distrib/macppc/ramdisk/install.md +++ b/distrib/macppc/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.64 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.65 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -43,29 +43,19 @@ md_installboot() { # If there is an MSDOS partition on the boot disk, copy ofwboot # into it. - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then - if fdisk $_disk | grep -q '^..: 06 '; then - if mount /dev/${_disk}i /mnt2 >/dev/null 2>&1; then - # Use cat to avoid holes created by cp(1) - cat /mnt/usr/mdec/ofwboot > /mnt2/ofwboot - umount /mnt2 - fi + if disk_has $_disk mbr openbsd; then + if mount /dev/${_disk}i /mnt2 >/dev/null 2>&1; then + # Use cat to avoid holes created by cp(1) + cat /mnt/usr/mdec/ofwboot > /mnt2/ofwboot + umount /mnt2 fi fi } -md_has_hfs () { - pdisk -l /dev/${1}c 2>&1 | grep -q '^Partition map ' -} - -md_has_hfs_openbsd () { - pdisk -l /dev/${1}c 2>&1 | grep -q ' OpenBSD OpenBSD ' -} - md_prep_MBR() { local _disk=$1 _q _d - if md_has_hfs $_disk; then + if disk_has $_disk hfs; then cat <<__EOT WARNING: Putting an MBR partition table on $_disk will DESTROY the existing HFS @@ -80,9 +70,9 @@ __EOT while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -112,11 +102,11 @@ at least 1MB and be marked as the *only* active partition. $(fdisk $_disk) __EOT fdisk -e $_disk - fdisk $_disk | grep -q '^..: 06 ' || + disk_has $_disk mbr dos || { echo "\nNo DOS (id 06) partition!\n"; continue; } - fdisk $_disk | grep -q '^\*.: 06 ' || + disk_has $_disk mbr dos_active || { echo "\nNo active DOS partition!\n"; continue; } - fdisk $_disk | grep -q "^..: A6 " || + disk_has $_disk mbr openbsd || { echo "\nNo OpenBSD (id A6) partition!\n"; continue; } break ;; o*|O*) @@ -135,7 +125,7 @@ md_prep_HFS() { while :; do _q= _d=Modify - md_has_hfs_openbsd $_disk && + disk_has $_disk hfs openbsd && { _q="Use the (O)penBSD partition, "; _d=OpenBSD; } pdisk -l /dev/${_disk}c ask "$_q(M)odify a partition or (A)bort?" "$_d" @@ -143,7 +133,7 @@ md_prep_HFS() { [aA]*) return 1 ;; [oO]*) return 0 ;; [mM]*) pdisk /dev/${_disk}c - md_has_hfs_openbsd $_disk && break + disk_has $_disk hfs openbsd && break echo "\nNo 'OpenBSD'-type partition named 'OpenBSD'!" esac done @@ -157,7 +147,7 @@ md_prep_disklabel() { PARTTABLE= while [[ -z $PARTTABLE ]]; do resp=MBR - md_has_hfs $_disk && ask "Use HFS or MBR partition table?" HFS + disk_has $_disk hfs && ask "Use HFS or MBR partition table?" HFS case $resp in [mM]*) md_prep_MBR $_disk && PARTTABLE=MBR ;; [hH]*) md_prep_HFS $_disk && PARTTABLE=HFS ;; diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 9b48a1cc322..4a8b30f481b 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.861 2015/12/06 20:29:07 rpe Exp $ +# $OpenBSD: install.sub,v 1.862 2015/12/18 16:20:58 rpe Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org> @@ -268,6 +268,46 @@ getdevname() { fi } +# Inspect disk $1 if it has a partition-table of type $2 and optionally +# if it has a partition of type $3. +disk_has() { + local _disk=$1 _pttype=$2 _part=$3 _cmd _p_pttype _p_part + + [[ -n $_disk && -n $_pttype ]] || exit + + # Commands to inspect disk. Default: "fdisk $_disk" + local _c_hfs="pdisk -l /dev/${_disk}c" + local _c_sr="bioctl -q $_disk" + + # Patterns for partition-table-types and partition-types. + local _p_gpt='First usable LBA:' + local _p_gpt_openbsd='^[ ]+OpenBSD[ ]+OpenBSD Area' + local _p_gpt_efisys='^[ ]+EFI Sys[ ]+EFI System Area' + local _p_hfs='^Partition map ' + local _p_hfs_openbsd=' OpenBSD OpenBSD ' + local _p_mbr='Signature: 0xAA55' + local _p_mbr_openbsd='^..: A6 ' + local _p_mbr_dos='^..: 06 ' + local _p_mbr_dos_active='^\*.: 06 ' + local _p_mbr_linux='^..: 83 ' + local _p_sr='OPENBSD, SR' + local _p_sr_crypto='OPENBSD, SR CRYPTO' + + eval "_cmd=\"\$_c_${_pttype}\"" + eval "_p_pttype=\"\$_p_${_pttype}\"" + eval "_p_part=\"\$_p_${_pttype}_${_part}\"" + _cmd=${_cmd:-fdisk $_disk} + + [[ -z $_p_pttype ]] && exit + [[ -n $_part && -z $_p_part ]] && exit + + if [[ -z $_p_part ]]; then + $_cmd | grep -Eq "$_p_pttype" + else + $_cmd | grep -Eq "$_p_pttype" && $_cmd | grep -Eq "$_p_part" + fi +} + # Handle disklabel auto-layout during interactive installation and # autopartitioning during unattended installation for the root disk. # In the latter case, ask for and download autopartitioning template. diff --git a/distrib/octeon/ramdisk/install.md b/distrib/octeon/ramdisk/install.md index 32d51279e82..01cd350a421 100644 --- a/distrib/octeon/ramdisk/install.md +++ b/distrib/octeon/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.12 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.13 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -53,9 +53,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -101,7 +101,7 @@ at least 16MB and be the first 'MSDOS' partition on the disk. $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; o*|O*) [[ $_d == OpenBSD ]] || continue diff --git a/distrib/socppc/ramdisk/install.md b/distrib/socppc/ramdisk/install.md index 95228d14366..4f7df51980a 100644 --- a/distrib/socppc/ramdisk/install.md +++ b/distrib/socppc/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.25 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.26 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -48,9 +48,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -76,7 +76,7 @@ must be marked as the only active partition. Inside the fdisk command, the $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; o*|O*) [[ $_d == OpenBSD ]] || continue diff --git a/distrib/zaurus/ramdisk/install.md b/distrib/zaurus/ramdisk/install.md index 9a6152ad2bd..b353afdfea1 100644 --- a/distrib/zaurus/ramdisk/install.md +++ b/distrib/zaurus/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.38 2015/12/02 21:17:17 krw Exp $ +# $OpenBSD: install.md,v 1.39 2015/12/18 16:20:58 rpe Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -42,9 +42,9 @@ md_prep_fdisk() { while :; do _d=whole - if fdisk $_disk | grep -q 'Signature: 0xAA55'; then + if disk_has $_disk mbr; then fdisk $_disk - if fdisk $_disk | grep -q '^..: A6 '; then + if disk_has $_disk mbr openbsd; then _q=", use the (O)penBSD area" _d=OpenBSD fi @@ -70,7 +70,7 @@ must be marked as the only active partition. Inside the fdisk command, the $(fdisk ${_disk}) __EOT fdisk -e ${_disk} - fdisk $_disk | grep -q ' A6 ' && return + disk_has $_disk mbr openbsd && return echo No OpenBSD partition in MBR, try again. ;; o*|O*) [[ $_d == OpenBSD ]] || continue |
