Can you change grub.config?

Hello. Is it possible to change the disk in grub.config?

For example if in grub.config it specifies hd0 can I change that to hd3?

Can I do that from the grub prompt that you get when a system doesn't start because the disk is different now and it doesn't know where root is?

If I can not do that from grub prompt, then when setting the root in grub prompt is there a way in the grub prompt to get the device name of hd3 because it does not logically correspond to /dev/sdd so if I set to that I get the array error things and then device does not exist.

Ok for example, grub knows it is on hd3. So it should just search hd3 for root. But in grub.config it is directly saying hd0. I get that is very nice if I have the efi on a different disk than root. But is there a way to get grub to know to make a fuzzy "I'll just search the disk I'm on for root" instead?

You might try enabling searching for root with boot:

sudo nano /etc/default/grub

GRUB_DISABLE_LINUX_UUID=false
ctrl+o, enter, ctrl+x

sudo update-grub

If that does not yield a return and get you booting up,

If from Grub Prompt:
Use the List command to list what you have

ls

see if HD3 is listed, then repeat the list command for HD3 to ensure it has a target grub file.

ls (hd3,1)/

The above assumes partition 1. Change the partition number if needed.
If it does show boot files (replace sdXn with the actual device ID and partition number):

set root=(hd3,1)
linux /boot/vmlinuz root=/dev/sdXn ro
initrd /boot/initrd.img
boot

Once you are booted, you can set grub install to designate your new HD location
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

sudo update-grub

1 Like

Thank you I'll try what you said about setting that to false.

I did do all the ls and set root and linux initrd boot things. The problem is I have no idea what to put for root=/dev/sdXn ro. I tried sdd like the page said because a search through ls (hd3,2) showed it was the system and (hd3,1) was the esp. But the article said hd3 would be sdd and it was not. So I searched and those results said that there was no logical way to know what /dev/sdXn would be from ls and seeing (hd3). So I tried searching what command to run, from grub> like

grub> show me what hd3 is called in device name
grub> hd3 is called /nvme0p12fkjanf in device name

or whatever. Ugh Anyway that search yeilded nothing but a lot of times it thinks I'm talking about something else completely.

1 Like

This is true. You would need to know that already...
Grub does not list the Device ID's.
Grub can list the UUID's of the devices, which you can then reference to find the device ID, but only after booting up.
Or if you can boot into the Zorin Recovery Menu and use the Root Prompt, there.

Still poking around in here. Pretty cool file you linked me too. I even see a grub background line and a disable os prober.

About to reboot and see what happents.

Ok this is on a temporary hold. I had done what you said here:

and quite possibly it would have worked too. At least, instead of booting to the grub> prompt it got me to the real menu.

However. I had also added a few things and messed around a bit while I was in that interesting file.

So anyhoo I killed that machine somehow. So luckily I have a backup, pre-my-messing-around and can try again later. Right now, after witnessing a rather ugly kernel panic where I could only stand by helplessly and watch in horror, I am just going to chill out to some swarf tv and see how the 32 bit install went.

Today you learned new things.

  • How to set grub to search for root dynamically instead of hard coding where to look.
  • How to reinstall grub on an existing install
  • How to let curiosity kill the computer cat and sit back and cry.

Two out of three is not bad. All in all, I call it a win.

1 Like

Yeh it was a pretty good win I'm glad it was in a VM though. The funny thing is I don't even need my backup because it's working again. I think it's because when I made my changes and went to reboot it and it started panicking, I tried to send the shutdown signal, then shut it down forcefully but it wasn't turning off and VirtualBox didn't seem to know what to do with it. I had to go into the terminal and kill the process. So I don't think it actually saved any of my changes, apparently. So tonight when I get home I can try it again with the original not the backup.

EDIT:
I tried again and this time I left out my inspired creativity and just stuck to your instructions. Everything seems to be fine. It boots up to a regular menu and when I select the os it boots into it now.

:grin:

We can make a new topic about inspired creativity in Grub - safely -

I have configured mine and I use my own made custom Grub menu and my own made custom plymouth, too.

There is a lot a person can do when they get inspired.

1 Like