Assuming you have a dual boot system, a desktop with multiple drives. GRUB is setup to dual boot wither into Windows or into your Linux distribution. Now, one day, you change the drive configuration. You add or remove a drive or re-partition a disk. GRUB still comes up, but it fails to boot into your Linux distro. What can you do?
In GRUB press `c` to enter the console. Then search for the linux partition. Tab completion works very well.
grub> ls
(hd0) (hd0,gpt1) (hd1) (hd1,gpt1) (hd1,gpt2) (hd2)...
This displays the drives and their partitions. Iterate through the drives and show their contents with ls until you identify the drive which has the vmlinuz*
and initrd*
files. Again, the Tab completion is super helpful.
grub> ls (hd3,gpt2)/boot/
Your drive configuration and partitions will likely look different. Once you identified the Linux partition boot into it by setting the root partition, linux kernel and init ramdisk followed by the boot command. Make sure you add the correct devicename as parameter for the linux kernel. Drive names are commonly /dev/sd??
(e.g. /dev/sda1
, /dev/sdb1
, /dev/sdb2
, etc) or /dev/nvme?n?p?
(e.g. /dev/nvme0n1p2
). If you got the device wrong, you probably end up on the console and you can list the devicenames under /dev
. Below is the example for my drive configuration.
grub> set root=(hd3,gpt2)
grub> linux /boot/vmlinuz-5.14.0-kali2-amd64 root=/dev/nvme1n1p2
grub> initrd /boot/initrd.img-5.14.0-kali2-amd64
grub> boot
Once booted into your linux distribution, you may want to update grub to detect your boot partitions and to rebuild your boot menu configuration.
# update-grub