Skip to content

Commit

Permalink
Make amd64 img bootable
Browse files Browse the repository at this point in the history
  • Loading branch information
sonertari committed Apr 29, 2023
1 parent f7d1b73 commit 11b47db
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions meta/createimg
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 47,16 @@ echo "Creating image: $IMG_FILE"
cd $ROOT_PATH/$CD_PATH

# All sizes are in sectors
MSDOSSTART=32768
MSDOSSIZE=16384
FFSSTART=$(($MSDOSSTART $MSDOSSIZE))
if [ "$ARCH" = arm64 ]; then
MSDOSSTART=32768
MSDOSSIZE=16384
FFSSTART=$(($MSDOSSTART $MSDOSSIZE))
fi
if [ "$ARCH" = amd64 ]; then
FFSSTART=0
fi

# Size of cd/arm64, trim trailing white spaces by adding 0
# Size of cd/{arm64,amd64}, trim trailing white spaces by adding 0
CD_SIZE=$(($(du -L -s . | cut -d . -f 1) 0))
echo "CD size $CD_SIZE sectors"

Expand All @@ -67,7 72,9 @@ cd $ROOT_PATH
rm $IMG_FILE

doas umount ./img_ffs
doas umount ./img_msdos
if [ "$ARCH" = arm64 ]; then
doas umount ./img_msdos
fi
doas vnconfig -u vnd0

# 1 sector = 512 bytes
Expand All @@ -77,29 84,43 @@ dd if=/dev/zero of=$IMG_FILE bs=512 count=$IMG_SIZE

doas vnconfig vnd0 $IMG_FILE

echo "reinit\ne 0\nC\nn\n$MSDOSSTART\n$MSDOSSIZE\nf 0\ne 3\nA6\nn\n$FFSSTART\n*\nw\nq\n" | doas fdisk -e vnd0 >/dev/null
if [ "$ARCH" = arm64 ]; then
echo "reinit\ne 0\nC\nn\n$MSDOSSTART\n$MSDOSSIZE\nf 0\ne 3\nA6\nn\n$FFSSTART\n*\nw\nq\n" | doas fdisk -e vnd0 >/dev/null
fi
if [ "$ARCH" = amd64 ]; then
echo "y\n" | doas fdisk -i vnd0 >/dev/null
fi
doas fdisk vnd0

echo "a a\n\n\n\nw\nq\n" | doas disklabel -E vnd0 >/dev/null
doas disklabel vnd0

doas newfs -O 1 -m 0 -o space -i $FS_SIZE -c $CD_SIZE /dev/rvnd0a

doas newfs_msdos -L boot -c 1 -F 16 /dev/rvnd0i
if [ "$ARCH" = arm64 ]; then
doas newfs_msdos -L boot -c 1 -F 16 /dev/rvnd0i
fi

mkdir ./img_ffs
doas mount /dev/vnd0a ./img_ffs

mkdir ./img_msdos
doas mount -o-l /dev/vnd0i ./img_msdos
if [ "$ARCH" = arm64 ]; then
mkdir ./img_msdos
doas mount -o-l /dev/vnd0i ./img_msdos
fi

doas cp -R -L -v $ROOT_PATH/$CD_PATH/* ./img_ffs/

if [ "$ARCH" = arm64 ]; then
doas cp -R -v openbsd/$INSTALL_SETS_PATH/BOOT/* ./img_msdos
echo "$VOL_ID\n$SYS_ID\n$APP_ID\n$PUBLISH_ID\n$PREP_ID" > ./img_msdos/README.txt
fi
if [ "$ARCH" = amd64 ]; then
doas installboot -r ./img_ffs vnd0 /usr/mdec/biosboot /usr/mdec/boot
fi
echo "$VOL_ID\n$SYS_ID\n$APP_ID\n$PUBLISH_ID\n$PREP_ID" > ./img_msdos/README.txt

doas umount ./img_ffs
doas umount ./img_msdos
if [ "$ARCH" = arm64 ]; then
doas umount ./img_msdos
fi
doas vnconfig -u vnd0

0 comments on commit 11b47db

Please sign in to comment.