Skip to content

sfdisk: honor --force for "All space for primary partitions is in use"#4397

Open
lzwind wants to merge 1 commit into
util-linux:masterfrom
lzwind:fix/sfdisk-force-primary-partitions
Open

sfdisk: honor --force for "All space for primary partitions is in use"#4397
lzwind wants to merge 1 commit into
util-linux:masterfrom
lzwind:fix/sfdisk-force-primary-partitions

Conversation

@lzwind
Copy link
Copy Markdown
Contributor

@lzwind lzwind commented Jun 2, 2026

Summary

  • --force is documented as "disable all consistency checking" but sfdisk still refused to create a partition when all four primary slots were occupied
  • Added a force bit to struct fdisk_context with fdisk_enable_force() public API
  • Propagated the sfdisk --force flag to the libfdisk context
  • Made the two "All space for primary partitions" -EINVAL returns in dos_add_partition() conditional on the force flag

Fixes: #4320

Test plan

  • dd if=/dev/zero of=/tmp/part count=1 && echo 1 2 7 - | sfdisk --force /tmp/part should succeed
  • Without --force, the same command should still fail with the existing error
  • Normal partition operations should be unaffected

Co-developed-by: Claude Sonnet 4.6 noreply@anthropic.com

The --force flag is documented as "disable all consistency checking"
but sfdisk still refused to create a partition when all four primary
slots are occupied, even with --force.

Add a force bit to struct fdisk_context with fdisk_enable_force() API,
propagate the sfdisk --force flag to the libfdisk context, and make the
"All space for primary partitions" checks in dos_add_partition()
conditional on the force flag.

Fixes: util-linux#4320

Co-developed-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@lzwind lzwind force-pushed the fix/sfdisk-force-primary-partitions branch from d8902a2 to b4c706f Compare June 3, 2026 02:09
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.

sfdisk ignores --force for "All space for primary partitions is in use." check

1 participant