Replace fdisk -l with sysfs-based disk enumeration (2tb+ drive support) #2035
Open
tlaurion wants to merge 1 commit intolinuxboot:masterfrom
Open
Replace fdisk -l with sysfs-based disk enumeration (2tb+ drive support) #2035tlaurion wants to merge 1 commit intolinuxboot:masterfrom
tlaurion wants to merge 1 commit intolinuxboot:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces fdisk -l commands with sysfs-based disk enumeration to overcome fdisk's 2TB drive size limitation and improve busybox compatibility. The changes enable proper detection and display of large storage devices (e.g., 8TB drives).
Key changes:
- Introduces
list_block_devices()function that reads from/sys/block/*instead of parsingfdisk -loutput - Replaces fdisk-based disk information gathering with sysfs-based size calculation
- Updates partition detection logic to use sysfs directory structure
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| initrd/etc/gui_functions | Adds list_block_devices() function and updates show_system_info() to read disk sizes from sysfs |
| initrd/etc/functions | Adds list_block_devices() function, updates device_has_partitions() to check sysfs for partitions, updates is_gpt_bios_grub() to read partition types from sysfs, and updates detect_boot_device() to use new function |
| initrd/bin/root-hashes-gui.sh | Updates detect_root_device() to use list_block_devices() instead of fdisk |
| initrd/bin/oem-system-info-xx30 | Updates disk information gathering to read from sysfs instead of fdisk |
| initrd/bin/config-gui.sh | Updates device listing to use list_block_devices() instead of fdisk |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b0bdb67 to
879fb3c
Compare
925c14e to
b3c8e82
Compare
… compatibility fdisk -l is unreliable in busybox environments due to 2TB max size based on max sector assumption. Changes: - Add list_block_devices() helper function to initrd/etc/functions and initrd/etc/gui_functions that uses sysfs to enumerate all block devices (SATA, NVMe, VirtIO, IDE) - Update show_system_info() in initrd/etc/gui_functions to use sysfs for disk size reporting instead of parsing fdisk output - Update show_system_info() in initrd/bin/oem-system-info-xx30 to use sysfs for disk size reporting - Replace device_has_partitions() in initrd/etc/functions to check for partition entries in sysfs instead of parsing fdisk output - Replace is_gpt_bios_grub() in initrd/etc/functions to use sysfs partition attributes (PARTTYPENAME) instead of fdisk parsing. Improves reliability for GPT disk detection while maintaining backward compatibility. - Update detect_boot_device() in initrd/etc/functions to use list_block_devices() - Update boot device selection in initrd/bin/config-gui.sh to use list_block_devices() - Update root device selection in initrd/bin/config-gui.sh to use list_block_devices() - Update root device detection in initrd/bin/root-hashes-gui.sh to use list_block_devices() Benefits: - Fixes disk detection failures with virtio block devices (qcow2 disks) - Works reliably in busybox environments - More robust than fdisk output parsing - Supports all block device types (sd*, nvme*, vd*, hd*) - Improves debuggability with explicit logging Note: Interactive partitioning in initrd/etc/luks-functions still uses fdisk for actually writing partition tables, which is its legitimate use case. Signed-off-by: Thierry Laurion <insurgo@riseup.net>
b3c8e82 to
d296082
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fdisk -l can deal with 2TB max size drives. Use linux sysfs instead.
Tested:
Fixes #2034 (should have been the fix for #1884)