-
-
Notifications
You must be signed in to change notification settings - Fork 205
Replace fdisk -l with sysfs-based disk enumeration (2tb+ drive support) #2035
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
fdisk -l can deal with 2TB max size drives. Use linux sysfs instead.
Tested:
Fixes #2034 (should have been the fix for #1884)