aboutsummaryrefslogtreecommitdiff
path: root/release/tools/vmimage.subr
diff options
context:
space:
mode:
authorGlen Barber <gjb@FreeBSD.org>2015-04-20 19:54:54 +0000
committerGlen Barber <gjb@FreeBSD.org>2015-04-20 19:54:54 +0000
commit4b8175ee8f196b4d52d3bf0aea4af8de77955449 (patch)
treea2cea7ba9fcc24ae36319ec29ddc65603add7b64 /release/tools/vmimage.subr
parentfdd86701e50ae84a87da304cf841f86b9d58774b (diff)
downloadsrc-4b8175ee8f196b4d52d3bf0aea4af8de77955449.tar.gz
src-4b8175ee8f196b4d52d3bf0aea4af8de77955449.zip
When building VM disk images, vm_copy_base() uses tar(1) to
copy the userland from one md(4)-mounted filesystem to a clean filesystem to prevent remnants of files that were added and removed from resulting in an unclean filesystem. When newfs(8) creates the first filesystem with journaled soft-updates enabled, the /.sujournal file in the new filesystem cannot be overwritten by the /.sujournal in the original filesystem. To avoid this particular error case, do not enable journaled soft-updates when creating the md(4)-backed filesystems, and instead use tunefs(8) to enable journaled soft-updates after the new filesystem is populated in vm_copy_base(). While here, fix a long standing bug where the build environment /boot files were used by mkimg(1) when creating the VM disk images by using the files in .OBJDIR. MFC after: 3 days Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=281783
Diffstat (limited to 'release/tools/vmimage.subr')
-rw-r--r--release/tools/vmimage.subr20
1 files changed, 14 insertions, 6 deletions
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 8eafceeb75f3..4fd500bbb6f0 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -14,17 +14,24 @@ write_partition_layout() {
SWAPOPT="-p freebsd-swap/swapfs::1G"
fi
+ _OBJDIR="$(make -C ${WORLDDIR} -V .OBJDIR)"
+ if [ -d "${_OBJDIR%%/usr/src}/${TARGET}.${TARGET_ARCH}" ]; then
+ BOOTFILES="${_OBJDIR%%/usr/src}/${TARGET}.${TARGET_ARCH}/usr/src/sys/boot"
+ else
+ BOOTFILES="${_OBJDIR}/usr/src/sys/boot"
+ fi
+
case "${TARGET}:${TARGET_ARCH}" in
amd64:amd64 | i386:i386)
- mkimg -s gpt -b /boot/pmbr \
- -p freebsd-boot/bootfs:=/boot/gptboot \
+ mkimg -s gpt -b ${BOOTFILES}/i386/pmbr/pmbr \
+ -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \
${SWAPOPT} \
-p freebsd-ufs/rootfs:=${VMBASE} \
-o ${VMIMAGE}
;;
powerpc:powerpc*)
mkimg -s apm \
- -p apple-boot/bootfs:=/boot/boot1.hfs \
+ -p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \
${SWAPOPT} \
-p freebsd-ufs/rootfs:=${VMBASE} \
-o ${VMIMAGE}
@@ -63,7 +70,7 @@ vm_create_base() {
mkdir -p ${DESTDIR}
truncate -s ${VMSIZE} ${VMBASE}
mddev=$(mdconfig -f ${VMBASE})
- newfs -j /dev/${mddev}
+ newfs /dev/${mddev}
mount /dev/${mddev} ${DESTDIR}
return 0
@@ -83,10 +90,10 @@ vm_copy_base() {
truncate -s ${VMSIZE} ${VMBASE}.tmp
mkdir -p ${DESTDIR}/new
mdnew=$(mdconfig -f ${VMBASE}.tmp)
- newfs -j /dev/${mdnew}
+ newfs /dev/${mdnew}
mount /dev/${mdnew} ${DESTDIR}/new
- tar -cf- -C ${DESTDIR}/old . | tar -xf- -C ${DESTDIR}/new
+ tar -cf- -C ${DESTDIR}/old . | tar -xUf- -C ${DESTDIR}/new
umount_loop /dev/${mdold}
rmdir ${DESTDIR}/old
@@ -94,6 +101,7 @@ vm_copy_base() {
umount_loop /dev/${mdnew}
rmdir ${DESTDIR}/new
+ tunefs -j enable /dev/${mdnew}
mdconfig -d -u ${mdnew}
mv ${VMBASE}.tmp ${VMBASE}
}