Use fdisk's -b to create boot partitions instead of -e scripts.
authorkrw <krw@openbsd.org>
Thu, 10 Feb 2022 20:07:47 +0000 (20:07 +0000)
committerkrw <krw@openbsd.org>
Thu, 10 Feb 2022 20:07:47 +0000 (20:07 +0000)
Build, boot and install tested by bluhm@

ok bluhm@

distrib/arm64/iso/Makefile
distrib/arm64/ramdisk/Makefile
distrib/arm64/ramdisk/install.md

index 68c3039..c944cd5 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.2 2021/04/17 21:19:41 sthen Exp $
+#      $OpenBSD: Makefile,v 1.3 2022/02/10 20:07:47 krw Exp $
 
 FS=            install${OSrev}.img
 FSSIZE=                1032192
@@ -19,7 +19,6 @@ XBASE=                ${RELXDIR}/xbase${OSrev}.tgz ${RELXDIR}/xfont${OSrev}.tgz \
 # this offset is required by Rockchip
 MSDOSSTART=    32768
 MSDOSSIZE=     16384
-FFSSTART!=     expr ${MSDOSSTART} + ${MSDOSSIZE}
 
 NEWFS_ARGS_msdos=-L boot -c1 -F16
 MOUNT_ARGS_msdos=-o-l
@@ -50,8 +49,7 @@ all: ${FS}
 ${FS}: ${BASE} ${XBASE}
        dd if=/dev/zero of=${FS} bs=512 count=${FSSIZE}
        vnconfig -v ${FS} > vnd
-       echo 'u\ne 0\nc\nn\n${MSDOSSTART}\n${MSDOSSIZE}\ne 3\nA6\nn\n${FFSSTART}\n*\nf 0\nw\nq\n' \
-           | fdisk -e `cat vnd` >/dev/null
+       fdisk -iy -b "${MSDOSSIZE}@${MSDOSSTART}:c" `cat vnd` >/dev/null
        echo 'a a\n\n\n\nw\nq\n' | disklabel -E `cat vnd` >/dev/null
        newfs -t msdos ${NEWFS_ARGS_msdos} /dev/r`cat vnd`i
        mount ${MOUNT_ARGS_msdos} /dev/`cat vnd`i ${MOUNT_POINT}
index 5dda462..8ef480f 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.23 2021/07/26 12:47:45 kn Exp $
+#      $OpenBSD: Makefile,v 1.24 2022/02/10 20:07:47 krw Exp $
 
 FS=            miniroot${OSrev}.img
 FSSIZE=                88064
@@ -9,7 +9,6 @@ RAMDISK=        RAMDISK
 # this offset is required by Rockchip
 MSDOSSTART=    32768
 MSDOSSIZE=     16384
-FFSSTART!=     expr ${MSDOSSTART} + ${MSDOSSIZE}
 
 NEWFS_ARGS_msdos=-L boot -c1 -F16
 MOUNT_ARGS_msdos=-o-l
@@ -46,8 +45,7 @@ all: ${FS}
 ${FS}: bsd.rd
        dd if=/dev/zero of=${FS} bs=512 count=${FSSIZE}
        vnconfig -v ${FS} > vnd
-       echo 'u\ne 0\nc\nn\n${MSDOSSTART}\n${MSDOSSIZE}\ne 3\nA6\nn\n${FFSSTART}\n*\nf 0\nw\nq\n' \
-           | fdisk -e `cat vnd` >/dev/null
+       fdisk -iy -b "${MSDOSSIZE}@${MSDOSSTART}:c" `cat vnd` >/dev/null
        echo 'a a\n\n\n\nw\nq\n' | disklabel -E `cat vnd` >/dev/null
        newfs -t msdos ${NEWFS_ARGS_msdos} /dev/r`cat vnd`i
        mount ${MOUNT_ARGS_msdos} /dev/`cat vnd`i ${MOUNT_POINT}
index fae0f4e..b169d48 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: install.md,v 1.24 2022/02/04 16:08:39 kettenis Exp $
+#      $OpenBSD: install.md,v 1.25 2022/02/10 20:07:47 krw Exp $
 #
 #
 # Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -79,17 +79,14 @@ md_installboot() {
 md_prep_fdisk() {
        local _disk=$1 _d _type=MBR
 
-       local bootpart=
        local bootparttype="C"
        local bootsectorstart="32768"
        local bootsectorsize="32768"
-       local bootsectorend=$(($bootsectorstart + $bootsectorsize))
        local bootfstype="msdos"
 
        while :; do
                _d=whole
                if disk_has $_disk gpt; then
-                       [[ $_disk == $ROOTDISK ]] && bootpart="-b ${bootsectorsize}"
                        _type=GPT
                        fdisk $_disk
                elif disk_has $_disk mbr; then
@@ -102,26 +99,19 @@ md_prep_fdisk() {
                [wW]*)
                        echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..."
                        if disk_has $_disk gpt apfsisc; then
-                               fdisk -Ay ${bootpart} ${_disk} >/dev/null
+                               if [[ $_disk == $ROOTDISK ]]; then
+                                       fdisk -Ay -b "${bootsectorsize}" ${_disk} >/dev/null
+                               else
+                                       fdisk -Ay ${_disk} >/dev/null
+                               fi
                        elif disk_has $_disk gpt; then
-                               fdisk -gy ${bootpart} ${_disk} >/dev/null
+                               if [[ $_disk == $ROOTDISK ]]; then
+                                       fdisk -gy -b "${bootsectorsize}" ${_disk} >/dev/null
+                               else
+                                       fdisk -gy ${_disk} >/dev/null
+                               fi
                        else
-                               fdisk -e ${_disk} <<__EOT >/dev/null
-reinit
-e 0
-${bootparttype}
-n
-${bootsectorstart}
-${bootsectorsize}
-f 0
-e 3
-A6
-n
-${bootsectorend}
-
-write
-quit
-__EOT
+                               fdisk -iy -b "${bootsectorsize}@${bootsectorstart}:${bootparttype}" ${_disk} >/dev/null
                        fi
                        echo "done."
                        installboot -p $_disk