AnswerBun.com

Booting from GRUB command line, says partion doesn't exist

Unix & Linux Asked by Hidden on January 13, 2021

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.

One Answer

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

and

linux /vmlinux root=UUID=82aecd65-6423-4d95-9319-3034263ee747 ro

Answered by Gilles 'SO- stop being evil' on January 13, 2021

Add your own answers!

Related Questions

Win-Kex Screen Resolution

0  Asked on September 20, 2020

       

How to call .bashrc function in script

1  Asked on September 14, 2020 by young_souvlaki

       

recursive statistics on file types in directory?

5  Asked on September 13, 2020 by user394

   

clamd randomly stops

1  Asked on September 13, 2020 by walter

   

Authentication fails though the password is correct

0  Asked on September 3, 2020 by rohit-pillai

     

Cant’t load Windows 10 anymore

1  Asked on August 31, 2020 by j-doe

       

Change order a icons in system tray widget in KDE?

1  Asked on August 29, 2020 by paddy

 

rts5139/rtsx_usb borked in 3.15+

2  Asked on August 27, 2020 by roman

     

ETH0 no address ip with ifconfig

1  Asked on August 24, 2020 by akame14

     

Kali Linux 2020.2 Wifi Not Working (Realtek)

0  Asked on August 18, 2020 by harriet

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir