build_image_util.sh: delete vmlinuz file from /usr partition

The vmlinuz kernel image gets installed to /usr/boot/ but isn't usable
for dm-verity until it gets copied over to /boot/flatcar/ and the hash
gets embedded at a particular offset. The file in /usr/boot/ uses space
while it's not having a real purpose as long as dm-verity is used.

Delete the vmlinuz file under /usr/boot/ to free up space. When
generating the ISO image we use the vmlinuz file from /boot/flatcar/
which also has the advantage that we only distribute a single vmlinuz
file with one particular checksum.
This commit is contained in:
Kai Lüke 2021-07-28 14:01:12 +02:00
parent b892315775
commit c1b2d88aa2
2 changed files with 5 additions and 2 deletions

View File

@ -597,10 +597,13 @@ finish_image() {
*) disable_read_write=${FLAGS_FALSE} ;;
esac
# Copy kernel to support dm-verity boots
# Copy kernel to the /boot partition to support dm-verity boots by embedding
# the hash of the /usr partition into the kernel.
# Remove the kernel from the /usr partition to save space.
sudo mkdir -p "${root_fs_dir}/boot/flatcar"
sudo cp "${root_fs_dir}/usr/boot/vmlinuz" \
"${root_fs_dir}/boot/flatcar/vmlinuz-a"
sudo rm "${root_fs_dir}/usr/boot/vmlinuz"*
# Record directories installed to the state partition.
# Explicitly ignore entries covered by existing configs.

View File

@ -661,7 +661,7 @@ _write_iso_disk() {
pushd "${iso_target}" >/dev/null
mkdir isolinux syslinux flatcar
_write_cpio_common "$1" "${iso_target}/flatcar/cpio.gz"
cp "${base_dir}"/boot/vmlinuz "${iso_target}/flatcar/vmlinuz"
cp "${VM_TMP_ROOT}"/boot/flatcar/vmlinuz-a "${iso_target}/flatcar/vmlinuz"
cp -R /usr/share/syslinux/* isolinux/
cat<<EOF > isolinux/isolinux.cfg
INCLUDE /syslinux/syslinux.cfg