Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partitions are 1 sector smaller than expected and not aligned to 1 MiB boundaries #305

Open
acodegazer opened this issue Aug 8, 2022 · 0 comments

Comments

@acodegazer
Copy link

acodegazer commented Aug 8, 2022

Distribution:
Pop!_OS 22.04 LTS

Related Application and/or Package Version:
The Pop!_OS 22.04 LTS installer.

Issue/Bug Description:
Each partition's end sector is 1 sector less than expected. For example, a 498 MiB Boot EFI partition starting at 4096 should end at 1023999 with a size of 1019904 sectors. However, it ends at 1023998 with a size of 1019903 sectors. The next partition starts at 1024000 as expected. This happens when doing a custom install or a clean install. There seems to be an off-by-one bug somewhere.

For a clean install, I noticed that the end of the root partition and start of the swap partition were not aligned at 1 MiB boundary. It seems the root partition is sized at whatever fits between fixed recovery and swap partitions.

Steps to reproduce (if you know):
Perform either a clean install or custom install.

Expected behavior:
Partitions should be fully sized and aligned to 1 MiB boundaries.

Other Notes:
I tested installations to a USB drive and to an SSD.

Here is an installer log excerpt. Note the incorrect partition sizes; I think it's calculated with end - start when it should be end - start + 1:

[INFO distinst:crates/disk-ops/src/ops.rs:221] creating partition (PartitionCreate { path: "/dev/sdb", start_sector: 4096, end_sector: 1023999, format: true, file_system: Some(Fat32), kind: Primary, flags: [PED_PARTITION_ESP], label: None }) on /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:20] opening device at /dev/sdb
[INFO distinst:crates/disk-ops/src/mkpart.rs:81] creating new partition with 1019903 sectors: 4096 - 1023999
[INFO distinst:crates/disk-ops/src/parted.rs:31] opening disk at /dev/sdb
[INFO distinst:crates/disk-ops/src/mkpart.rs:124] committing new partition (4096:1023999) on /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:62] committing changes to /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:78] syncing device at /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:8] getting device at /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:31] opening disk at /dev/sdb
[INFO distinst:crates/disk-ops/src/ops.rs:221] creating partition (PartitionCreate { path: "/dev/sdb", start_sector: 1024000, end_sector: 15693823, format: true, file_system: Some(Ext4), kind: Primary, flags: [], label: None }) on /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:20] opening device at /dev/sdb
[INFO distinst:crates/disk-ops/src/mkpart.rs:81] creating new partition with 14669823 sectors: 1024000 - 15693823
[INFO distinst:crates/disk-ops/src/parted.rs:31] opening disk at /dev/sdb
[INFO distinst:crates/disk-ops/src/mkpart.rs:124] committing new partition (1024000:15693823) on /dev/sdb
[INFO distinst:crates/disk-ops/src/parted.rs:62] committing changes to /dev/sdb

Looking at https://github.com/pop-os/distinst/blob/master/crates/disk-ops/src/mkpart.rs
I think line 67 should be
let length = partition.get_sector_end() - partition.get_sector_start() + 1;
and line 79 should be
let (start, end) = (geometry.start(), geometry.start() + geometry.length() - 1);

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

No branches or pull requests

1 participant