Skip to content

Fix compressed .vhd.zst image writes#2968

Draft
jaredhagel2 wants to merge 1 commit intopbatard:masterfrom
jaredhagel2:fix/compressed-vhd-zst-write
Draft

Fix compressed .vhd.zst image writes#2968
jaredhagel2 wants to merge 1 commit intopbatard:masterfrom
jaredhagel2:fix/compressed-vhd-zst-write

Conversation

@jaredhagel2
Copy link
Copy Markdown

Summary

Fix failures when writing Windows disk images stored as compressed fixed VHDs such as .vhd.zst.

Problem

When writing a compressed Windows image to a CFast card, Rufus could fail shortly after pressing START with a compressed-image write error.

The immediate write failure was caused by sector-sized writes reaching the physical device from decompressor buffers that were not sector-aligned. Some physical media accept sector-sized writes only when the source buffer is aligned as well, so the write path could fail even though the decompression itself was fine.

There was also a second issue specific to compressed fixed VHD payloads. Rufus could treat a .vhd.zst image like a generic compressed raw image and fall back to the compressed archive size instead of the decompressed disk payload size. That could cause the write path to stop at the archive size instead of the real end of the fixed VHD payload.

Fix

This change:

  • routes unaligned full-sector decompressor output through an aligned bounce buffer before writing to the target device
  • keeps the existing partial-sector buffering behavior for compressed-image writes
  • derives the decompressed content size for zstd-backed fixed VHD payloads and uses that payload size when deciding where the real disk data ends
  • avoids truncating compressed fixed-VHD writes to the compressed archive size

Result

Compressed .vhd.zst images now write correctly to physical media that require aligned raw writes, and fixed-VHD payloads are written to their proper payload length instead of being cut off at the compressed archive size.

@jaredhagel2 jaredhagel2 force-pushed the fix/compressed-vhd-zst-write branch from 080bb32 to f3eb97d Compare May 6, 2026 19:46
@jaredhagel2 jaredhagel2 force-pushed the fix/compressed-vhd-zst-write branch from f3eb97d to 525edb2 Compare May 6, 2026 19:53
@jaredhagel2 jaredhagel2 marked this pull request as draft May 6, 2026 21:43
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.

1 participant