From 08a75d1f0e7d885f5a891e0e3e64a540daf15689 Mon Sep 17 00:00:00 2001 From: Glen Barber Date: Thu, 23 Apr 2015 01:04:14 +0000 Subject: [PATCH] Create the arm64/aarch64 VM disk image as MBR instead of GPT scheme. UEFI needs to know the unique partition GUID with GPT, which changes each time. Specifically, the QEMU EFI BIOS file has this hard-coded.[1] Since the GPT labels are now unavailable, unconditionally label the root filesystem as 'rootfs' with newfs(8), since it does not hurt anything anywhere else. For the arm64 case, '/' is mounted from /dev/ufs/rootfs; for all other VM images, '/' is mounted from /dev/gpt/rootfs. Unfortunately, since the /dev/gpt/swapfs label is also lost, set NOSWAP=1 for the arm64/aarch64 images. This is temporary, until I figure out a scalable solution to this. But, a certain piece of softare was written "very fast", and ended up living for 15 years. We can deal with this for a week or so. Information from: andrew, emaste [1] Sponsored by: The FreeBSD Foundation --- release/scripts/mk-vmimage.sh | 10 ++++++++++ release/tools/vmimage.subr | 13 ++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/release/scripts/mk-vmimage.sh b/release/scripts/mk-vmimage.sh index d5985ceb0d25..fd84216a99fe 100755 --- a/release/scripts/mk-vmimage.sh +++ b/release/scripts/mk-vmimage.sh @@ -93,6 +93,16 @@ main() { . "${VMCONFIG}" fi + case ${TARGET}:${TARGET_ARCH} in + arm64:aarch64) + ROOTLABEL="ufs" + NOSWAP=1 + ;; + *) + ROOTLABEL="gpt" + ;; + esac + vm_create_base vm_install_base vm_extra_install_base diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 1a295e55519b..fa6db41d61c6 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -30,10 +30,9 @@ write_partition_layout() { -o ${VMIMAGE} ;; arm64:aarch64) - mkimg -s gpt \ - -p efi/efiboot:=${BOOTFILES}/efi/boot1/boot1.efifat \ - ${SWAPOPT} \ - -p freebsd-ufs/rootfs:=${VMBASE} \ + mkimg -s mbr \ + -p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \ + -p freebsd:=${VMBASE} \ -o ${VMIMAGE} ;; powerpc:powerpc*) @@ -77,7 +76,7 @@ vm_create_base() { mkdir -p ${DESTDIR} truncate -s ${VMSIZE} ${VMBASE} mddev=$(mdconfig -f ${VMBASE}) - newfs /dev/${mddev} + newfs -L rootfs /dev/${mddev} mount /dev/${mddev} ${DESTDIR} return 0 @@ -97,7 +96,7 @@ vm_copy_base() { truncate -s ${VMSIZE} ${VMBASE}.tmp mkdir -p ${DESTDIR}/new mdnew=$(mdconfig -f ${VMBASE}.tmp) - newfs /dev/${mdnew} + newfs -L rootfs /dev/${mdnew} mount /dev/${mdnew} ${DESTDIR}/new tar -cf- -C ${DESTDIR}/old . | tar -xUf- -C ${DESTDIR}/new @@ -123,7 +122,7 @@ vm_install_base() { echo '# Custom /etc/fstab for FreeBSD VM images' \ > ${DESTDIR}/etc/fstab - echo '/dev/gpt/rootfs / ufs rw 1 1' \ + echo "/dev/${ROOTLABEL}/rootfs / ufs rw 1 1" \ >> ${DESTDIR}/etc/fstab if [ -z "${NOSWAP}" ]; then echo '/dev/gpt/swapfs none swap sw 0 0' \