diff --git a/build_library/base_image_util.sh b/build_library/base_image_util.sh index dd9a6ecb3d..2704810dec 100755 --- a/build_library/base_image_util.sh +++ b/build_library/base_image_util.sh @@ -23,6 +23,7 @@ cleanup_mounts() { safe_umount_tree "${root_fs_dir}" safe_umount_tree "${stateful_fs_dir}" safe_umount_tree "${esp_fs_dir}" + safe_umount_tree "${oem_fs_dir}" # Turn die on error back on. set -e @@ -240,7 +241,8 @@ create_base_image() { build_gpt "${BUILD_DIR}/${image_name}" \ "${root_fs_img}" \ "${stateful_fs_img}" \ - "${esp_fs_img}" + "${esp_fs_img}" \ + "${oem_fs_img}" # Clean up temporary files. rm -f "${root_fs_img}" "${stateful_fs_img}" "${esp_fs_img}" "{oem_fs_img}" diff --git a/build_library/disk_layout_util.sh b/build_library/disk_layout_util.sh index 29f51ebc79..719a4093b7 100644 --- a/build_library/disk_layout_util.sh +++ b/build_library/disk_layout_util.sh @@ -172,6 +172,7 @@ build_gpt() { local rootfs_img="$2" local stateful_img="$3" local esp_img="$4" + local oem_img="$5" get_disk_layout_type run_partition_script "${outdev}" "${rootfs_img}" @@ -195,6 +196,10 @@ build_gpt() { $sudo dd if="$esp_img" of="$outdev" conv=notrunc bs=512 \ seek=$(partoffset ${outdev} 12) + info "Copying OEM partition..." + $sudo dd if="$oem_img" of="$outdev" conv=notrunc bs=512 \ + seek=$(partoffset ${outdev} 8) + # Pre-set "sucessful" bit in gpt, so we will never mark-for-death # a partition on an SDCard/USB stick. cgpt add -i 2 -S 1 "$outdev" diff --git a/image_to_vm.sh b/image_to_vm.sh index 5c27c87708..44fad16d35 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -117,6 +117,7 @@ popd >/dev/null # Fix the kernel command line TEMP_ESP="${TEMP_DIR}"/part_12 +TEMP_OEM="${TEMP_DIR}"/part_8 TEMP_ROOTFS="${TEMP_DIR}"/part_3 TEMP_STATE="${TEMP_DIR}"/part_1 TEMP_KERN="${TEMP_DIR}"/part_2 @@ -175,6 +176,8 @@ dd if="${TEMP_KERN}" of="${TEMP_IMG}" conv=notrunc bs=512 \ seek=$(partoffset ${TEMP_IMG} 2) dd if="${TEMP_ESP}" of="${TEMP_IMG}" conv=notrunc bs=512 \ seek=$(partoffset ${TEMP_IMG} 12) +dd if="${TEMP_OEM}" of="${TEMP_IMG}" conv=notrunc bs=512 \ + seek=$(partoffset ${TEMP_IMG} 8) # Make the built-image bootable and ensure that the legacy default usb boot # uses /dev/sda instead of /dev/sdb3.