From c022d4370927b7410c4c4a3df85cf0dbfc0520b0 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 1 Jul 2025 15:55:11 +0200 Subject: [PATCH] build_library/vm_image_util: Fix squashfs creation for pxe The pxe disk is a cpio file that, among other things, contains a squashfs image. The image has contents of `/usr` directory, so the image's toplevel directories are `lib`, `lib64`, `share` and so on. The first fix was to change the `/usr/share/flatcar/update.conf` path in pseudofile listing to `/share/flatcar/update.conf`. Otherwise mksquashfs started complaining that `usr` directory does not exists in the image, so some of the pseudofiles won't be installed. Second fix is still related to the same file. It already exists in the image, so the pseudofile wanting to be installed there won't be, because mksquashfs stopped liking overwriting the files already present in the image. I added `-e share/flatcar/update.conf` to avoid adding the file into the image, so that pseudofile can be created there. It was actually a suggestion printed by mksquashfs. --- build_library/vm_image_util.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 1a6950ea2f..cdb169b984 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -714,13 +714,23 @@ _write_cpio_common() { echo "/.noupdate f 444 root root echo -n" >"${VM_TMP_DIR}/extra" # Set correct group for PXE/ISO, which has no writeable /etc - echo /usr/share/flatcar/update.conf f 644 root root \ + echo /share/flatcar/update.conf f 644 root root \ "sed -e 's/GROUP=.*$/GROUP=${VM_GROUP}/' ${base_dir}/share/flatcar/update.conf" \ >> "${VM_TMP_DIR}/extra" + local -a mksquashfs_opts=( + -pf "${VM_TMP_DIR}/extra" + -xattrs-exclude '^btrfs.' + # mksquashfs doesn't like overwriting existing files with + # pseudo-files, so tell it to ignore the existing file instead + # + # also, this must be the last option + -e share/flatcar/update.conf + ) + # Build the squashfs, embed squashfs into a gzipped cpio pushd "${cpio_target}" >/dev/null - sudo mksquashfs "${base_dir}" "./usr.squashfs" -pf "${VM_TMP_DIR}/extra" -xattrs-exclude '^btrfs.' + sudo mksquashfs "${base_dir}" "./usr.squashfs" "${mksquashfs_opts[@]}" find . | cpio -o -H newc | gzip > "$2" popd >/dev/null