vmimage.subr (7263c8c0998402e9860a0865013fbec4ece98cd4) | vmimage.subr (08a75d1f0e7d885f5a891e0e3e64a540daf15689) |
---|---|
1#!/bin/sh 2# 3# $FreeBSD$ 4# 5# 6# Common functions for virtual machine image build scripts. 7# 8 --- 16 unchanged lines hidden (view full) --- 25 amd64:amd64 | i386:i386) 26 mkimg -s gpt -b ${BOOTFILES}/i386/pmbr/pmbr \ 27 -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \ 28 ${SWAPOPT} \ 29 -p freebsd-ufs/rootfs:=${VMBASE} \ 30 -o ${VMIMAGE} 31 ;; 32 arm64:aarch64) | 1#!/bin/sh 2# 3# $FreeBSD$ 4# 5# 6# Common functions for virtual machine image build scripts. 7# 8 --- 16 unchanged lines hidden (view full) --- 25 amd64:amd64 | i386:i386) 26 mkimg -s gpt -b ${BOOTFILES}/i386/pmbr/pmbr \ 27 -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \ 28 ${SWAPOPT} \ 29 -p freebsd-ufs/rootfs:=${VMBASE} \ 30 -o ${VMIMAGE} 31 ;; 32 arm64:aarch64) |
33 mkimg -s gpt \ 34 -p efi/efiboot:=${BOOTFILES}/efi/boot1/boot1.efifat \ 35 ${SWAPOPT} \ 36 -p freebsd-ufs/rootfs:=${VMBASE} \ | 33 mkimg -s mbr \ 34 -p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \ 35 -p freebsd:=${VMBASE} \ |
37 -o ${VMIMAGE} 38 ;; 39 powerpc:powerpc*) 40 mkimg -s apm \ 41 -p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \ 42 ${SWAPOPT} \ 43 -p freebsd-ufs/rootfs:=${VMBASE} \ 44 -o ${VMIMAGE} --- 27 unchanged lines hidden (view full) --- 72 73vm_create_base() { 74 # Creates the UFS root filesystem for the virtual machine disk, 75 # written to the formatted disk image with mkimg(1). 76 77 mkdir -p ${DESTDIR} 78 truncate -s ${VMSIZE} ${VMBASE} 79 mddev=$(mdconfig -f ${VMBASE}) | 36 -o ${VMIMAGE} 37 ;; 38 powerpc:powerpc*) 39 mkimg -s apm \ 40 -p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \ 41 ${SWAPOPT} \ 42 -p freebsd-ufs/rootfs:=${VMBASE} \ 43 -o ${VMIMAGE} --- 27 unchanged lines hidden (view full) --- 71 72vm_create_base() { 73 # Creates the UFS root filesystem for the virtual machine disk, 74 # written to the formatted disk image with mkimg(1). 75 76 mkdir -p ${DESTDIR} 77 truncate -s ${VMSIZE} ${VMBASE} 78 mddev=$(mdconfig -f ${VMBASE}) |
80 newfs /dev/${mddev} | 79 newfs -L rootfs /dev/${mddev} |
81 mount /dev/${mddev} ${DESTDIR} 82 83 return 0 84} 85 86vm_copy_base() { 87 # Creates a new UFS root filesystem and copies the contents of the 88 # current root filesystem into it. This produces a "clean" disk 89 # image without any remnants of files which were created temporarily 90 # during image-creation and have since been deleted (e.g., downloaded 91 # package archives). 92 93 mkdir -p ${DESTDIR}/old 94 mdold=$(mdconfig -f ${VMBASE}) 95 mount /dev/${mdold} ${DESTDIR}/old 96 97 truncate -s ${VMSIZE} ${VMBASE}.tmp 98 mkdir -p ${DESTDIR}/new 99 mdnew=$(mdconfig -f ${VMBASE}.tmp) | 80 mount /dev/${mddev} ${DESTDIR} 81 82 return 0 83} 84 85vm_copy_base() { 86 # Creates a new UFS root filesystem and copies the contents of the 87 # current root filesystem into it. This produces a "clean" disk 88 # image without any remnants of files which were created temporarily 89 # during image-creation and have since been deleted (e.g., downloaded 90 # package archives). 91 92 mkdir -p ${DESTDIR}/old 93 mdold=$(mdconfig -f ${VMBASE}) 94 mount /dev/${mdold} ${DESTDIR}/old 95 96 truncate -s ${VMSIZE} ${VMBASE}.tmp 97 mkdir -p ${DESTDIR}/new 98 mdnew=$(mdconfig -f ${VMBASE}.tmp) |
100 newfs /dev/${mdnew} | 99 newfs -L rootfs /dev/${mdnew} |
101 mount /dev/${mdnew} ${DESTDIR}/new 102 103 tar -cf- -C ${DESTDIR}/old . | tar -xUf- -C ${DESTDIR}/new 104 105 umount_loop /dev/${mdold} 106 rmdir ${DESTDIR}/old 107 mdconfig -d -u ${mdold} 108 --- 9 unchanged lines hidden (view full) --- 118 119 cd ${WORLDDIR} && \ 120 make DESTDIR=${DESTDIR} \ 121 installworld installkernel distribution || \ 122 err "\n\nCannot install the base system to ${DESTDIR}." 123 124 echo '# Custom /etc/fstab for FreeBSD VM images' \ 125 > ${DESTDIR}/etc/fstab | 100 mount /dev/${mdnew} ${DESTDIR}/new 101 102 tar -cf- -C ${DESTDIR}/old . | tar -xUf- -C ${DESTDIR}/new 103 104 umount_loop /dev/${mdold} 105 rmdir ${DESTDIR}/old 106 mdconfig -d -u ${mdold} 107 --- 9 unchanged lines hidden (view full) --- 117 118 cd ${WORLDDIR} && \ 119 make DESTDIR=${DESTDIR} \ 120 installworld installkernel distribution || \ 121 err "\n\nCannot install the base system to ${DESTDIR}." 122 123 echo '# Custom /etc/fstab for FreeBSD VM images' \ 124 > ${DESTDIR}/etc/fstab |
126 echo '/dev/gpt/rootfs / ufs rw 1 1' \ | 125 echo "/dev/${ROOTLABEL}/rootfs / ufs rw 1 1" \ |
127 >> ${DESTDIR}/etc/fstab 128 if [ -z "${NOSWAP}" ]; then 129 echo '/dev/gpt/swapfs none swap sw 0 0' \ 130 >> ${DESTDIR}/etc/fstab 131 fi 132 133 mkdir -p ${DESTDIR}/dev 134 mount -t devfs devfs ${DESTDIR}/dev --- 98 unchanged lines hidden --- | 126 >> ${DESTDIR}/etc/fstab 127 if [ -z "${NOSWAP}" ]; then 128 echo '/dev/gpt/swapfs none swap sw 0 0' \ 129 >> ${DESTDIR}/etc/fstab 130 fi 131 132 mkdir -p ${DESTDIR}/dev 133 mount -t devfs devfs ${DESTDIR}/dev --- 98 unchanged lines hidden --- |