I have found some related questions but none has solve my problem.
I have a laptop with a hard disk with Windows. I wanted to install Debian in a second hard disk so I attached it with a caddy and removed the Windows hard disk (just in case, you know). I then successfully installed Debian with GRUB installed in the same disk as it was the only one at that moment. Then I put back the Windows hard disk.
Now from the BIOS I can choose which drive I want to boot. The Windows drive boots perfectly, but when I choose to boot from the Debian drive it shows the GRUB menu and then a black screen with a blinking dash.
If I remove the Windows hard disk I can successfully boot Debian, so the problem must be with the GRUB configuration.
Thus, I go for the GRUB console. I detect linux is in the (hd0,5) partion and vmlinuz and initrd are reachable from the root, so I go for the usual:
grub> set root=(hd0,5) grub> linux /vmlinuz root=/dev/sda5 grub> initrd /initrd.img grub> boot
Then I can see a lot of initrd output which then goes for a bunch of
Begin: Running /scripts/local-block ... done. messages and finally fails with a
sda5 doesn't exists. Dropping to a shell like message. But well… you know… it does exist, so I’m blocked.
You have two problems: identifying the drive, and identifying the partition.
Grub counts partitions from 0, Linux counts partitions from 1. So if Grub's
hd0 is Linux's
sda then Grub's
(hd0,5) is Linux's
The partition you choose as “root” in Grub is not necessarily Linux's root partition. In Grub, “root” is just a shortcut for not having to type the partition designation in front of file names. If you have a separate
/boot partition then you'd typically set that as the Grub root, because Grub only cares about what's in
/boot (the kernel image and the initial ramdisk image). Linux doesn't care about what's in
/boot except to upgrade it.
The drive numbering may not match between Grub and Linux. Grub relies on the computer's BIOS to enumerate drives. Linux has its own drivers. When disks are connected through a different interface, it's difficult to predict in which order they'll be enumerated; it can be up to which disk controller replies faster. So Grub's
hd0 is not necessarily Linux's
To make your computer boot reliably no matter how the disks are connected and what the timing of the controller's responses are, use labels or UUIDs instead of a letter/number designation. Once you've booted, run
update-grub — it should normally generate a file
/boot/grub/grub.cfg using UUIDs. Both Grub and Linux will enumerate available partitions when they start up and remember their UUIDs. In
grub.cfg, you should see lines like
search --no-floppy --fs-uuid --set=root 82aecd65-6423-4d95-9319-3034263ee747
linux /vmlinux root=UUID=82aecd65-6423-4d95-9319-3034263ee747 ro
Answered by Gilles 'SO- stop being evil' on January 13, 2021
1 Asked on September 14, 2020 by young_souvlaki
2 Asked on September 14, 2020 by skg
5 Asked on September 13, 2020 by user394
1 Asked on September 10, 2020 by ansgar
1 Asked on September 7, 2020 by tsm
2 Asked on September 4, 2020 by fivedogit
0 Asked on September 3, 2020 by rohit-pillai
0 Asked on September 1, 2020 by hba
1 Asked on August 29, 2020 by paddy
0 Asked on August 28, 2020 by yeremia-danang
2 Asked on August 27, 2020 by roman
2 Asked on August 27, 2020 by indranil
1 Asked on August 24, 2020 by saurav-raj-joshi
2 Asked on August 20, 2020 by myndstream
0 Asked on August 18, 2020 by harriet
1 Asked on August 17, 2020 by fidodido
Get help from others!