Skip to content

Replace sgdisk with sfdisk in kiwi and dracut GPT partition flows - #3006

Draft
schaefi with Copilot wants to merge 6 commits into
mainfrom
copilot/replace-sgdisk-with-sfdisk
Draft

Replace sgdisk with sfdisk in kiwi and dracut GPT partition flows#3006
schaefi with Copilot wants to merge 6 commits into
mainfrom
copilot/replace-sgdisk-with-sfdisk

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown

This updates GPT partition handling under kiwi/ and dracut/ to use sfdisk instead of sgdisk. The change covers partition creation, type updates, GPT/MBR transitions, and image/disk initialization paths that previously depended on sgdisk.

  • GPT partitioner migration

    • Reworked kiwi/partitioner/gpt.py to drive GPT operations through sfdisk.
    • Switched partition creation to scripted sfdisk input, including explicit partition numbers, names, sizes, and optional start sectors.
    • Replaced GPT type updates with sfdisk --part-type.
    • Replaced GPT table resizing with sfdisk --dump + table-length: rewrite.
  • Disk/table rewrite paths

    • Replaced GPT wipe/reinitialize logic in kiwi/storage/disk.py with sfdisk --wipe always and explicit label recreation.
    • Reworked GPT→MBR and hybrid GPT/MBR generation to emit sfdisk layouts instead of sgdisk transforms.
  • Bootloader image creation

    • Updated the embedded EFI FAT image setup in kiwi/bootloader/config/systemd_boot.py to create its GPT partition via sfdisk.
  • Dracut runtime changes

    • Replaced GPT partition delete/create/type operations in dracut/modules.d/59kiwi-lib/kiwi-partitions-lib.sh with sfdisk.
    • Reworked hybrid GPT creation in dracut to build the nested MBR with sfdisk --label-nested=mbr.
    • Dropped sgdisk from the dracut module runtime dependency list.
  • Packaging/test alignment

    • Updated unit tests to assert the new sfdisk command shapes and scripted input flow.

Example of the new GPT partition creation pattern:

printf 'start=4096, size=100MiB, name="p.lxroot"\n' \
  | sfdisk --force -N 1 /dev/loop0

sfdisk --part-type /dev/loop0 1 0FC63DAF-8483-4772-8E79-3D69D8477DE4

@schaefi
schaefi force-pushed the copilot/replace-sgdisk-with-sfdisk branch 2 times, most recently from a662499 to b3a7578 Compare June 17, 2026 17:14
Copilot AI and others added 4 commits June 17, 2026 21:49
drop gdisk/gptfdisk packages from requirements
This Fixes #2804
Fix resize_table, invalid and unneeded lba header
Fix exception handling, use KIWIGeometryError instead of RuntimeError
Fix tests, all code must be covered by tests
@schaefi
schaefi force-pushed the copilot/replace-sgdisk-with-sfdisk branch from b3a7578 to d698efd Compare June 17, 2026 19:50
@schaefi

schaefi commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

This change cannot be made because sfdisk does not support to create partition entries with custom partition IDs. For example see:

 efipart_id="55"
 rootpart_id="1"
 bootpart_id="101"

Something like this cannot be represented by sfdisk as it creates new partitions with auto ID assignment according to their location in the table. That actually makes sense but we cannot afford to lose this feature in kiwi.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed as part of the community meeting.

@github-actions github-actions Bot added the stale label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants