如何定位Grub2中无法读取的hd0设备来源?
I’ve run into this exact issue on a brand-new ThinkServer with CentOS 7 installed—system boots fine, but that annoying error pops up every time I access the Grub menu or run search/ls in the Grub command line. After digging around and testing a few fixes, here’s what worked for me:
Step 1: Grab Your Root Partition UUID
First, log into your system and get the UUID of your root partition. This lets Grub target the correct disk directly instead of scanning all devices (which triggers the error):
blkid | grep /dev/mapper/centos-root # Adjust the path if your root partition uses a different name
Copy the UUID string (looks like xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) for later use.
Step 2: Tweak Grub’s Configuration
Edit the main Grub config file:
vi /etc/default/grub
Make these key changes:
- Add
GRUB_DISABLE_OS_PROBER=trueto turn off automatic scanning of other OSes (this stops Grub from probing the problematichd0device) - Update
GRUB_CMDLINE_LINUXto include your root partition UUID, like this:GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet root=UUID=YOUR_ROOT_UUID_HERE" - Add
GRUB_PRELOAD_MODULES="part_gpt part_msdos"to ensure Grub loads the right partition modules for UEFI mode
Step 3: Regenerate the Grub Config
Apply your changes by rebuilding the Grub EFI configuration:
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
If That Fails: Blacklist Problematic Disk Modules
If the error still shows up, your ThinkServer might have a disk controller module causing misidentification. Add this to GRUB_CMDLINE_LINUX in /etc/default/grub:
rd.blacklist=ahci
Then regenerate the config again with the command from Step 3.
Why This Happens
ThinkServers in UEFI mode often map the remote management controller (like iDRAC) as a virtual hd0 device. This device has no readable sectors, so when Grub scans all disks during boot or command-line operations, it throws the "failure reading sector 0x0" error. By disabling OS probing and targeting your actual root partition directly, Grub skips this invalid virtual disk entirely.
内容的提问来源于stack exchange,提问作者Geoffrey Wiseman

