grub gone again - trying to recover

General support questions
Post Reply
john2018
Posts: 43
Joined: 2018/02/17 19:09:47

grub gone again - trying to recover

Post by john2018 » 2018/03/22 14:50:52

Now booting into grub rescue
all the grub files were in a folder called /bo (it did boot from there initially somehow )
and I thought a filename corruption - but /boot was still there and empty.
I stupidly moved the files back into /boot and rebooted without checking grub.cfg etc.

Anyway -

Is there a simple way to get at my root drive to edit the grub.cfg or just look around.
I cant find a way to get the drive mounted.
initially I thought I could start the live USB disk but I cant persuade it to mount the hard drive.
I tried running parted and that fails:-

parted -l
Failure to communicate with kernel device-mapper driver.
Incompatible libdevmapper 1.02.140-RHEL7 (2017-05-03) and kernel driver (unknown version).

Thats all off the live .iso so I dont know why that should fail.

When I boot normally
grub rescue does list the drives (2) on my system ok but I cant work out how to get it
to do anything more. The suggestions I found elsewhere online dont work for me.
I'm hoping to find a way to look at/edit grub.cfg but I'm running round in circles now.

any ideas?

desertcat
Posts: 843
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: grub gone again - trying to recover

Post by desertcat » 2018/03/23 07:27:33

john2018 wrote:Now booting into grub rescue
all the grub files were in a folder called /bo (it did boot from there initially somehow )
and I thought a filename corruption - but /boot was still there and empty.
I stupidly moved the files back into /boot and rebooted without checking grub.cfg etc.

Anyway -

Is there a simple way to get at my root drive to edit the grub.cfg or just look around.
I cant find a way to get the drive mounted.
initially I thought I could start the live USB disk but I cant persuade it to mount the hard drive.
I tried running parted and that fails:-

parted -l
Failure to communicate with kernel device-mapper driver.
Incompatible libdevmapper 1.02.140-RHEL7 (2017-05-03) and kernel driver (unknown version).

Thats all off the live .iso so I dont know why that should fail.

When I boot normally
grub rescue does list the drives (2) on my system ok but I cant work out how to get it
to do anything more. The suggestions I found elsewhere online dont work for me.


I'm hoping to find a way to look at/edit grub.cfg but I'm running round in circles now.

any ideas?
I'm trying to understand the question. Are you trying to boot the system, or trying to boot another system?? The answer is it depends. If you can't boot the system the best thing to do is to get out a copy of Knoppix then mount the system under Knoppix. Depending upon if the disk is set up in LVM or as separate partition you want to mount /boot and either /root or /etc ( you want to be able to look at the sub-directories in /etc). Now there are 3 Directories that are important to recover from a whacked system you should check: 1) /boot/grub2 (under which you find grub.cfg); 2) /etc/default (under which you find grub); and 3) /etc/grub.d (which contains the files (?) used by grub.cfg). Open any text editor such as mc (found in Knoppix) and look at /etc/grub.d, and you *should* see something like this:

*00_header
*00_tuned
*01_users
*10_linux
*20_linux_xen
*20_ppc_terminfo
*30_os-prober
*40_custom
*41_custom

That is the order in which they should appear. If they don't you are severely whacked. What I've done is sometimes is to simply rename the various out of whack files back to the above list ie if I have a file called *20_os-prober, and I know that it should be *30_os-prober I simply rename it back to its original file name. Once I am satisfied I have the list back in order I run:

grub2-mkconfig -o /boot/grub2/grub.cfg

Now if you are trying to run a different OS you need to set that up *40_custom. Indeed if you really get desperate you could simply copy the contents of grub.conf starting on the line that reads #### BEGIN /etc/grub.d/10_linux ### into /etc/grub.d/40_custom, safe the file and run

grub2-mkconfig -o /boot/grub2/grub.cfg

and it will add the contents of 40_custom to the menu entry list. It can be done but it a messy process (ask me how I know), alternately simply add the latest kernel to 40_custom and that should at least provide you an emergency launch. One note the grub2-mkconfig -o /boot/grub2/grub.cfg works only if you are running a legacy BIOS if you are running UEFI the command is slightly different:

grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

Here is a reference you should keep on hand:

https://access.redhat.com/documentation ... ation_file

Once you have saved the file and run the grub2-mkconfig... command exit Knoppix, shut down the target machine then re-boot, with lucj you should be rewarded with a menu that will then start your system. Once you have the system up and running can I suggest that you download Grub Customizer that can get you out of a lot of jams.

Hope this helps

john2018
Posts: 43
Joined: 2018/02/17 19:09:47

Re: grub gone again - trying to recover

Post by john2018 » 2018/03/23 12:10:50

thanks for the detailled reply desertcat...

Sorry I did seem to waffle a bit in my post - In my defence I'd
been running round in circles trying to work out how to simply
edit a partition.
The noise you could hear was my hair being pulled out.

I'm shocked at how difficult it is to just boot into bash
from a USB and mount the hard drive.
Clearly I'm going to have to do something about that.

I did think the live Centos release would let me do that
but it doesnt even seem to let me run as root. again - amazed.
I could get it to mount but only ro mode which doesnt help.

I'll look into your suggestions - I did look at a few things but
nothing I found would work. I havn't heard of knoppix for many
years - I think it was free on a disc about 20 years ago?
One of many. Its funny what survives.

What I need really is:
Boot into bash from a USB stick
Mount the internal hard drive as rw
Move/rename some files
Load a sensible text editor to edit some configs.
Maybe search for files
thats about all.
It doesnt even need to be linux based if it can read the file system.

User avatar
TrevorH
Site Admin
Posts: 33221
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: grub gone again - trying to recover

Post by TrevorH » 2018/03/23 12:44:00

Boot the install DVD in rescue mode. It's an option off the troubleshooting menu you see when you first boot.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

desertcat
Posts: 843
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: grub gone again - trying to recover

Post by desertcat » 2018/03/23 15:21:54

john2018 wrote:thanks for the detailled reply desertcat...

Sorry I did seem to waffle a bit in my post - In my defence I'd
been running round in circles trying to work out how to simply
edit a partition.
The noise you could hear was my hair being pulled out.

I'm shocked at how difficult it is to just boot into bash
from a USB and mount the hard drive.
Clearly I'm going to have to do something about that.

I did think the live Centos release would let me do that
but it doesnt even seem to let me run as root. again - amazed.
I could get it to mount but only ro mode which doesnt help.

I'll look into your suggestions - I did look at a few things but
nothing I found would work. I havn't heard of knoppix for many
years - I think it was free on a disc about 20 years ago?
One of many. Its funny what survives.

What I need really is:
Boot into bash from a USB stick
Mount the internal hard drive as rw
Move/rename some files
Load a sensible text editor to edit some configs.
Maybe search for files
thats about all.
It doesnt even need to be linux based if it can read the file system.
Knoppix is still around. Knoppix 8.1 is now out, still free to download. Which I am now downloading even as I type. This is a must have utility disk. I don't know where I would be without my Knoppix disk.

Another extremely useful swiss army knife utility is Midnight Commander (mc) -- File Browser, text editor and more. Based upon the OLD DOS Norton Commander and improved. I probably use mc more than any other program. After updating a fresh install it is the first program I install. To install run yum install mc.

For a straight Text editor I have found Sublime to be great, similar to vim, but on steroids.

Given that I *hate* Grub2 (having blown up my machine once or twice) do install Grub Customizer ( yum install grub-customizer ) as it will bail you out if you somehow mangle your /boot directory.

Listen to TrevorH he is 'the man".

As to tearing out ones hair, and bashing ones head on the wall, I've done it more than once. Hope this helps. Cheers!

Post Reply