Grub Command Line. Fixing a Broken MBR

General support questions
Post Reply
dirkxxvi
Posts: 12
Joined: 2014/06/19 05:26:24

Grub Command Line. Fixing a Broken MBR

Post by dirkxxvi » 2014/09/04 04:17:51

I'm currently studying for the RHCSA exam and one of the things thats really freaking me out at the moment is the previous grub bash commands (ie pressing c at the grub boot menu) I learned to fix a broken MBR are no longer working.

On CentOS6 I was able to run the following to get the desired results
grub -> root
grub-> setup (hd0)

However now on CentOS 7 I get
grub -> root
error - can't find command 'root'
grub-> setup (hd0)
error - can't find command 'setup'

The farthest I've gotten is
grub-> ls
(proc) (hd0) (hd0,msdos2) (hd0,msdos1)

I can generate a list of possible commands by pressing tab twice but they're all unfamiliar and I have had little luck finding anything resembling man pages to explain them.

I'd really like to know what to search for to at least research documentation because every search I get on Grub commands seems to point me to the commands that I was originally taught, and that in turn apparently don't work anymore.

User avatar
WhatsHisName
Posts: 1549
Joined: 2005/12/19 20:21:43
Location: /earth/usa/nj

Re: Grub Command Line. Fixing a Broken MBR

Post by WhatsHisName » 2014/09/04 05:26:45

EL7 uses grub2, not legacy grub.

RHEL Grub2

Fedora Grub2

GNU Grub2

Happy reading.

dirkxxvi
Posts: 12
Joined: 2014/06/19 05:26:24

Re: Grub Command Line. Fixing a Broken MBR

Post by dirkxxvi » 2014/09/05 03:25:03

WhatsHisName wrote:EL7 uses grub2, not legacy grub.

RHEL Grub2

Fedora Grub2

GNU Grub2

Happy reading.
Thank you the materials helped a ton. It seemed virtually every command and instruction manual I was finding was written for legacy grub.

I think I now have a pretty good handle on it as since your post I've learned to boot a kernel manually from the materials above (as long as I know the root partition, for example last night since the Grub entry was correct I knew it was root=/dev/mapper/cl-root). So now I know to manually boot a kernel into rw mode, as well as giving myself a chance to reset the root password I do, well I did this:
grub-> set root=(hd0,msdos1)
grub->linux /vmlinuz-3(tab autocomplete) root=/dev/mapper/cl-root rw init=/bin/sh
grub->initrd /initramfs-3(tab autocomplete).img
grub->boot
and sure enough I start with a basic bash shell and with the passwd command I'm able to reset the root password.

Also thanks to the materials above I now know that with set pager=1 I don't have to go insane trying to read text that appears on the screen for less then a fraction of a second.

In fact thats the only thing bothering me right now in relation to grub2 is I'm trying to figure out what to do when I have no access to a live disc and I need to find the root partitions location (also assuming any grub2 entry in the grub.cfg directing me to the root partition is incorrect so in short a worse case scenario). It seems most of the grub2 commands like grub2-install /dev/sda can only be executed in a Linux OS and if I'm in a case where I don't know the correct root partition location I won't get past the boot screen. Closest I've come so far is entering root=/dev/vda2 (even though I know its wrong), and then using blkid to see the partitions like in this case I was able to see that root was suppose to be on /dev/mapper/cl-root.

At this point I'm not sure if all changes related to version 7 are suppose to make life easier or harder lol.

Post Reply