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
This commit is contained in:
Glen Barber 2015-04-23 01:04:14 +00:00
parent e54379826c
commit 08a75d1f0e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=281876
2 changed files with 16 additions and 7 deletions

View file

@ -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

View file

@ -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' \