grub rescue error

Issues related to applications and software problems
Post Reply
knzzz
Posts: 157
Joined: 2017/02/25 12:41:42

grub rescue error

Post by knzzz » 2017/06/21 02:44:12

Hi All,

When was recovering the mbr in grub2 in centos 7.3 i accidently mounted the rhel 7 iso and updated the /boot/grub2/grub.cfg, now its flashing the grub rescue prompt, any suggestion how to proceed further to recover my os.

Regards
Kannappan M

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: grub rescue error

Post by aks » 2017/06/21 16:35:06

How much of the MBR did you write? If it's *really* only the MBR, just restore the MBR from a working machine (assuming on UEFI here).

knzzz
Posts: 157
Joined: 2017/02/25 12:41:42

Re: grub rescue error

Post by knzzz » 2017/06/24 17:31:12

HI It is not EFI machine it is my vm machine, i did mbr

dd if=/dev/zero of=/dev/sdc bs=512 count=1

so from here could u pls give me the further steps

owl102
Posts: 413
Joined: 2014/06/10 19:13:41

Re: grub rescue error

Post by owl102 » 2017/06/24 17:47:00

knzzz wrote:dd if=/dev/zero of=/dev/sdc bs=512 count=1
If you really have done this you have nuked the partition table of /dev/sdc.

I guess it's time for restoring the backup.
German speaking forum for Fedora and CentOS: https://www.fedoraforum.de/

tunk
Posts: 1206
Joined: 2017/02/22 15:08:17

Re: grub rescue error

Post by tunk » 2017/06/24 22:40:32

I seem to remember that there may be some tools that can scan your disk and possibly extract enough info to recreate the mbr/partition table.
Google and see if you find something.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: grub rescue error

Post by aks » 2017/06/25 08:20:52

dd if=/dev/zero of=/dev/sdc bs=512 count=1
That means write zeros over the sdc disk for a length of 512 bytes. What you've done is overwrite the bootrap, the partition tbale and the signature with zeros. The following are the sizes for an MBR ("classic" BIOS):

446: Bootstrap.
64: Partition table.
2: Signature.

If you have a disk with the same partition layout and size (both physical and logical) as the broken (sdc) disk you could do:

dd if=/dev/<disk_that_works> of=<removable_media_mountpoint>/mbr.bak bs=512 count=1
dd if=<removable_media_mountpoint>/mbr.bak of=/dev/sdc bs=512 count=1 # NOTE: 512 bytes will be bootstrap and partiting information, use 446 for only the bootstrap.

Another way of copying a partition table:

sfdisk -d /dev/<disk_that_works> > <removable_media_mountpoint>/<disk_that_works>.partition.table
sfdisk -f /dev/sdc < <removable_media_mountpoint>/<disk_that_works>.partition.table

Otherwise you're looking at something like TestDisk, SystemRescueCD or even gpart to see if repair is possible. Something in the back of my mind tells me that there is a "backup" partition table, maybe there is or maybe there is not, but either way one of the above tools could probably tell you.

owl102
Posts: 413
Joined: 2014/06/10 19:13:41

Re: grub rescue error

Post by owl102 » 2017/06/25 10:03:38

aks wrote:Something in the back of my mind tells me that there is a "backup" partition table, maybe there is or maybe there is not
GPT partitioning has a backup partition table at the end of the disk.
MBR partitioning has not.
German speaking forum for Fedora and CentOS: https://www.fedoraforum.de/

Post Reply