Skip to content

fix(#4807): don't write past the end of small partitions when wiping - #4809

Open
edu-ap wants to merge 1 commit into
archlinux:masterfrom
edu-ap:fix-wipe-small-partitions
Open

edu-ap wants to merge 1 commit into
archlinux:masterfrom
edu-ap:fix-wipe-small-partitions

Conversation

@edu-ap

@edu-ap edu-ap commented Sep 29, 2026

Copy link
Copy Markdown

Fixes #4807.

DeviceHandler._wipe() writes a fixed 1024 bytes to every partition. ChromeOS GPT layouts contain 512-byte partitions (KERN-C, ROOT-C, reserved; see the ChromiumOS disk format reference: "Each minimal-size partition (including the C kernel and C rootfs) is only 512 bytes"). So wiping a disk that previously ran ChromeOS or ChromeOS Flex raises OSError: [Errno 28] No space left on device and aborts the installation. It has been hit on a Lenovo ThinkPad and on two MacBook Airs via the Omarchy installer (omacom/omarchy#9246).

This change writes min(1024, device size) bytes, taking the size from seeking to the end of the block device.

Tested on loop-device partitions (block devices, Linux 6.8), each pre-filled with 0xFF:

Partition Before After
512 bytes OSError: [Errno 28] No space left on device ok, all 512 bytes zeroed
63 MiB ok, 1024 bytes zeroed ok, 1024 bytes zeroed (unchanged)

ruff check, ruff format --check and flake8 pass. I couldn't run mypy locally because my Python was older than the syntax the codebase uses, so I'm relying on CI for that.

🤖 Generated with Claude Code

…n wiping

DeviceHandler._wipe() wrote a fixed 1024 bytes to every partition. ChromeOS
GPT layouts contain 512-byte partitions (KERN-C, ROOT-C, reserved), so
wiping a disk that previously ran ChromeOS or ChromeOS Flex failed with
OSError: [Errno 28] No space left on device and aborted the installation.

Write min(1024, device size) bytes instead. Normal partitions are wiped
exactly as before; 512-byte partitions are zeroed completely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@h8d13

h8d13 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

This looks legit to me. And well-scoped.

Whether the code is good, is another question maybe @codefiles can answer.

@Torxed Torxed left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch!
Now sure why that merge conflict happened, feels like it should have been able to deal with it. Once you've resolved it I'd be happy to merge this PR.

@h8d13

h8d13 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@codefiles

Copy link
Copy Markdown
Contributor

I will likely end up replacing this device wiping code in the future anyway. As I've stated elsewhere, I am prioritizing enabling linting rules before making any other changes.

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.

wipe_dev() fails with ENOSPC on partitions smaller than 1024 bytes (ChromeOS GPT layouts)

4 participants