Skip to content

feat: relocate macOS recovery when resizing raw disks - #1336

Open
cocoa-xu wants to merge 2 commits into
openai:mainfrom
cocoa-xu:feat/relocate-macos-recovery
Open

cocoa-xu wants to merge 2 commits into
openai:mainfrom
cocoa-xu:feat/relocate-macos-recovery

Conversation

@cocoa-xu

Copy link
Copy Markdown

Hi, this PR adds --relocate-recovery to tart set --disk-size for standalone raw macOS disks. It preserves the Recovery partition while moving it to the end of the disk, making room for APFS expansion.

Previously, tho tart set --disk-size can enlarge the raw disk image, but it won't relocate Recovery. With Recovery sitting after the system APFS partition, macOS couldn’t use the added space for APFS expansion.

Validate both GPT copies and preserve Recovery in a staged disk image before replacing the original. Leave APFS growth to the guest on its next boot.
Remove unrelated display and config-write changes while retaining disk safety checks. Name the GPT and MBR layout constants and the Recovery copy buffer size.
@edi-oai
edi-oai self-requested a review October 13, 2026 16:56

@edi-oai edi-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can already achieve this with Packer builder for Tart VMs, see recovery_partition setting for more details.

@cocoa-xu

Copy link
Copy Markdown
Author

I think you can already achieve this with Packer builder for Tart VMs, see recovery_partition setting for more details.

Hi @edi-oai thanks for pointing that out. It's true that Packer already supports preserving and relocating Recovery.

The motivation for this PR is to expose that operation directly through tart's existing disk-resize command. For tools that already manage Tart VMs directly, resizing an existing VM would then be a single Tart operation, without introducing Packer and a separate build configuration.

There is also a difference in failure handling. Packer's implementation saves the Recovery contents, updates the original disk's partition table, and then restores the contents at the new location. This PR performs the changes on a staging copy, validates both GPT copies, and replaces the original disk only after that completes. A failure before the final replacement therefore leaves the original disk intact.

The scope is deliberately limited to stopped VMs with standalone raw macOS disks. APFS filesystem expansion remains a separate step, handled by the guest agent or inside the guest. I think the native CLI integration and staged disk replacement make this useful alongside the existing Packer implementation.

This branch has not been deployed

No deployments
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