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.

  • I think your linux disk will become /dev/sdb and the Windows disk is /dev/sda. The device order in the BIOS or in GRUB does not necessarily reflect the device naming in Linux. So best would be to go for the UUIDs in GRUB and in /etc/fstab. You also can check with root=/dev/sdb5, maybe the /etc/fstab is using UUIDs already... – Thomas Apr 1 '17 at 12:02
  • @Thomas You made my day. Going for sdb solved the problem. If you can make an answer from your comment I will choose it. I could also use some help on how to make that change permanent so I don't have to use the GRUB console every time. I mean in which file should I change sda to sdb? – Hidden Apr 1 '17 at 13:13

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 sda6.

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 sda.

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
  • Based on what I have read trying to solve this I think the counting from 0 vs counting from 1 isn't true anymore and applies only to grub-legacy. Also, in my case, hd0 didn't map to sda but to sdb, which was what confussed me and led me to ask here in first place. Actual mapping in my case is (hd0,5) -> sdb5. Finally I was afraid of overwriting the Windows MBR if using the grub commands as I don't have a deep understanding of how they work, so I manually replaced every sda5 with sdb5 in /boot/grub/grub.cfg and now everything seems to be working properly. – Hidden Apr 1 '17 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.