Skip to content

Check ESP size in bytes not sectors - #953

Open
ryonakano wants to merge 7 commits into
mainfrom
fix-sector-size
Open

Check ESP size in bytes not sectors#953
ryonakano wants to merge 7 commits into
mainfrom
fix-sector-size

Conversation

@ryonakano

Copy link
Copy Markdown
Member

Fixes #448
Fixes #620
Fixes #952
(partly fixes these issues in the scope of GUI)

Closes #621
Closes #911
(continuation of these PRs)

Changes Summary

This PR fixes an ESP partition in 256 MiB is warned as "EFI partition is too small" when 4k sector size. Note that this PR does NOT fix installation fails with that partition setup / sector size; see "Notes" below.

Before

There is an alert icon in the partition bar and hovering on it shows "EFI partition is too small" tooltip.

Screenshot_ubuntu24 04_2026-09-06_12:02:15

After

The alert icon is not shown.

Screenshot_ubuntu24 04_2026-09-06_13:00:56

How to Test This

  1. Build the .deb file with debuild -us -uc on your host computer
  2. Create a VM that uses 4k sector size for its VHD. You can achieve this by adding the following line to the XML of VirtIO disk in case of virt-manager (QEMU/KVM)
  <blockio logical_block_size='4096' physical_block_size='4096'/>
  1. Boot from the ISO on a VM and go to the demo mode
  2. Install openssh-server on the VM
  3. Scp the built .deb file (io.elementary.installer-session_8.1.3_all.deb and io.elementary.installer_8.1.3_amd64.deb) to the VM
  4. install the .deb files on the VM with sudo apt install ./*.deb
  5. Log out to go to the installer session

Changes Per File

We already store sector size in InstallerDaemon.Disk so what we need to do is to pass it to where we compare ESP size in PartitioningView.set_mount ().

  • common/DBusStructures.vala
    • Add a member variable to store sector size in InstallerDaemon.Mount to keep consistency with Installer.Mount
  • src/Objects/Mount.vala
    • Make it possible to pass sector size from PartitioningView
  • src/Views/PartitioningView.vala
    • Change required ESP size unit from sectors to MiB. Note that the actual size doesn't change
      • Before: 524288 = 256 MiB in sectors, but this assumes 512 sector size
        • In case of 512 sector size: 524288 sectors * 512 sector size / 1024 / 1024 = 256 MiB (expected)
        • In case of 4k sector size: 524288 sectors * 4096 sector size / 1024 / 1024 = 2048 MiB (unexpected)
      • After: 256 * 1024 * 1024 = 256 MiB in bytes, sector size independent
    • Pass sector size from InstallerDaemon.Disk to PartitionMenu (step 1)
    • Compare ESP size in bytes, not sectors
      • Here we use the sector size in Installer.Mount
  • src/Views/ProgressView.vala
    • Pass sector size from Installer.Mount to InstallerDaemon.Mount to keep consistency with Installer.Mount
  • src/Widgets/PartitionBlock.vala
    • Fix fencepost error when getting partition size in sectors to prevent exactly 256 MiB ESP partition is warned as "EFI partition is too small"
    • For example, get_partition_size_in_sectors () returns 65535 instead of 65536 when partition.end_sector = 65791 and partition.start_sector = 256, resulting 65535 sectors * 4096 sector size / 1024 / 1024 = 255.99609375 < 256 MiB
  • src/Widgets/PartitionMenu.vala
    • Pass sector size from PartitioningView to Installer.Mount (step 2)

Notes

Custom installation with this branch still fails with the following error:

Details

INFO: getting device at /dev/vda
INFO: obtaining disk information from /dev/vda
INFO: obtaining serial model from /dev/vda
INFO: opening disk at /dev/vda
INFO: obtaining partition information from /dev/vda1
INFO: obtaining partition information from /dev/vda2
DEBUG: get block size for "/sys/class/block/vda"
ERROR: libdistinst: pointer in FFI is null
ERROR: libdistinst: pointer in FFI is null
ERROR: libdistinst: pointer in FFI is null
ERROR: errored while installing system: partition validation: the ESP partition must be at least 256 MiB in size
INFO: Install error: partition validation: the ESP partition must be at least 256 MiB in size

This is because Distinst assumes 512 sector size as reported at pop-os/distinst#177. That's out of scope of this PR and you can use a workaround to make sure the ESP partition size is larger than 2048 MiB (= 524288 sectors when 4096 sector size).

@ryonakano
ryonakano requested review from a team and vjr September 6, 2026 07:00
@ryonakano ryonakano added this to OS 9 Sep 6, 2026
@ryonakano ryonakano moved this to Needs Review in OS 9 Sep 6, 2026

@vjr vjr 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.

I'm unable to test at the moment but code does LGTM so this can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Installer shows incorrect partition sizes, cannot install due to perceived ESP partition size Installer support for non-512-byte sector sizes

3 participants