Skip to content

perf(convert): reduce rootfs copies from 3 to 1 - #110

Closed
imlk0 wants to merge 63 commits into
masterfrom
fde-convert-slow
Closed

imlk0 wants to merge 63 commits into
masterfrom
fde-convert-slow

Conversation

@imlk0

@imlk0 imlk0 commented Apr 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the intermediate rootfs.img file and final qemu-img convert step with a qcow2 overlay/snapshot architecture, reducing full rootfs copies from 3 → 1
  • Source image is modified through a writable overlay (source-mod), then forked into two independent snapshots (source-read for verity hash, source-write for dracut initrd generation)
  • Eliminates two full rootfs copies (~17s dd + ~32s qemu-img convert ≈ ~49s savings)
  • Remove --device / operate_on_device support: deprecate in-place device conversion in favor of file-based (--in/--out) only
  • Fix RPM version detection: rpm -q outputs error to stdout on uninstalled packages, which was captured as the version string
  • Fix unbound boot_part variable when source has no separate boot partition
  • Remove --wipe-freed-space option (no longer needed with qcow2 overlay architecture)
  • Update docs: quick-start.md, quick-start_zh.md — replace --device examples with --in/--out

Test plan

  • Run conversion on aliyun_3_x64 image — all 11 steps complete successfully
  • Verify output qcow2 has correct partition layout (BIOS boot, EFI, boot ext4, rootfs LUKS2)
  • Verify verity hash is computed correctly
  • Verify dracut generates initrd successfully
  • Timing: ~5m24s total

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@imlk0
imlk0 force-pushed the fde-convert-slow branch from aa6ba77 to ec85e19 Compare April 29, 2026 12:12
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@imlk0
imlk0 force-pushed the fde-convert-slow branch from ec85e19 to 07fc888 Compare April 29, 2026 12:17
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@imlk0
imlk0 force-pushed the fde-convert-slow branch from 9ef0a95 to 0c97e2d Compare April 29, 2026 13:09
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@imlk0
imlk0 force-pushed the fde-convert-slow branch from 0c97e2d to 8a094cc Compare April 29, 2026 13:13
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

In UKI mode with an existing BOOT partition, the partition was being
moved to a new location in step 5 (to make room for expanded EFI), but
the boot partition content was never copied because copy_partitions()
skipped boot partition handling entirely in UKI mode.

Now copy the boot partition from source-read in UKI mode when
boot_part_exist=true, just like in GRUB mode.
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

…ce.sh

- SC2086/SC1012: dpkg-query format string uses ${dpkg-Package} and \n
  which are intentionally not expanded by shell (interpreted by dpkg-query)
- SC2016: add_run_cmd argument is a script to be executed later, variables
  should not be expanded at definition time
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

…ainers

os-prober scans all devices and fails with 'Device or resource busy' errors
when running inside Docker containers with NBD devices. This causes
grub2-mkconfig to fail to find kernel images, resulting in grub.cfg without
menuentry sections.

Disable os-prober by setting GRUB_DISABLE_OS_PROBER=true before running
grub2-mkconfig, similar to how DEB workflow handles it.
@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。

imlk0 added a commit that referenced this pull request Oct 30, 2026
Step 9 now chroots the source-write snapshot with /boot and /boot/efi
mounted from the output partitions, so the generated initrd and UKI land
directly on the output image while the rootfs, already verity-formatted
from source-read, stays untouched. The read-only compat flag set during
shrink is cleared on the snapshot before mounting it rw.
setup_chroot_mounts gains optional boot/EFI override arguments because
the boot_part and efi_part globals still point at the source-mod NBD,
which is disconnected in step 5.

Step 10 tears down dm targets under the output device (the LVs now live
there), flushes buffers on the output, source-read and source-write
devices, then disconnects all three NBDs with nbd_disconnect_and_wait so
the build file lock is released before any image operation. The same
retarget applies to the dm-remove hooks and the step 8 teardown, which
referenced the stale source device. Step 11 renames the build qcow2 into
place for qcow2 output and converts it to vpc for VHD output, restoring
the VHD path PR #110 dropped, and a guard fails the run when no output
file was produced.

Assisted-by: Claude Code:qwen3.8-flash[1M]
Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
@imlk0 imlk0 mentioned this pull request Oct 30, 2026
5 of 6 tasks
@imlk0

imlk0 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded: the performance rework landed via #164, and the Ubuntu cloud image support is being redone cleanly on current master (see #166). Closing this PR to avoid its CI jobs and image builds colliding with the new work.

@imlk0 imlk0 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants