Booting into Linux from the Grub Prompt with an NVME Drive

- 3 mins

For the first time since my foray into Linux 4/5 years ago, I ran into the dreaded grub prompt at boot.

It looks a lot like this:

This basically means that the grub install is corrupted and GRUB doesn’t know how to boot.

There are quite a few tutorials on recovering from grub rescue mode, infact the image above includes most of the neccesary steps to booting into grub. But here’s my experience recovering from this prompt with an NVME Pcie SSD. In my first attempt to follow the steps below I had a kernel panic and had to start from scractch because I followed the steps to a regular recovery.

Steps to Recover from the Grub Prompt

Here’s a step by step method to how I recovered from the grub prompt, fixed grub, and rebooted to write this post.

Part 1: Getting Out of the Grub Prompt

  1. Type ls to see which drives are mounted
  2. Type ls (hd0,1)/ and repeat this until you find the drive (hdX, Y)/ with your boot disk
  3. Once you've found your boot disk type: set root=(hdX,X) where X is your drive/partition number
  4. The next part depends on your version of Linux (but if you're after version 12 you're good so keep reading)
  5. Type linux /vmlinuz root=/dev/nvme0nXpY where X is the X from hdX which is your boot drive, and Y which is the partition number on that drive that the boot partition.
  6. initrd /initrd.img
  7. boot

Part 2: Booting into Linux and Repairing GRUB

After beginnning the boot process from the prompt I noticed a flickering TTY screen at boot due probably to my Nvidia drivers or some other permissions error. I knew to basically type Ctrl + F1 until I got get a TTY screen (which would disappear within 3 seconds due to the nature of this flickering bug, and could be brought back by pressing Ctrl + F1)

So while fighting with the flickering TTY screen I had to enter my username, password, and the command sudo service GDM stop. This command may be: sudo service lightdm stop if you have a different display manager.

Basically my display manager was in a corrupted loop because the .Xauthority file’s permissions are altered either during the grub prompt boot. The permissions change to root effectively. As a result upon stopping the display manager I am able to access the TTY and preform the following steps:

  1. Type the command update-grub in the tty
  2. You should see a series of images to add to the grub menu, next enter grub-install /dev/nvme0nXpY as per your prior boot drive and partition
  3. Now to check .Xauthority permissions, type sudo ls -lah in your home directory to see what the permissions settings are for .Xauthority file. In my case this was "root:root"
  4. To repair .Xauthority type the following replacing username with your username chown username:username .Xauthority in my case I typed shantanu:shantanu
  5. Type sudo reboot and hope for the best

After this I waited for the grub screen and indeed it worked. The NVME0nXpY thing was neccesary for me to boot and subsequently type this post.

rss facebook twitter github youtube mail spotify instagram linkedin google pinterest medium vimeo