Grub doesn load. Missing partition?

Issues related to applications and software problems
Post Reply
swesque
Posts: 3
Joined: 2015/09/13 01:10:18

Grub doesn load. Missing partition?

Post by swesque » 2015/09/13 01:59:16

Centos version: Installed 6.4, updated to 6.5

I deleted a partition by mistake - thought gparted was reverencing a thumb drive. It was the CentOS hard drive.
Dumb.

Root partition directories and files are intact. I can browse the file system using "rescue installed system" from the CentOS installation disk menu.

I created a new partition in place of the one I deleted. Tried to follow online examples but I keep getting errors like "broken superblock" and "does not have any corresponding BIOS drive."

I really need some help getting the partition restored properly and grub hooked up to existing system files.

Thanks in advance.

-gt

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

Re: Grub doesn load. Missing partition?

Post by TrevorH » 2015/09/13 10:38:37

There is a utility called 'gpart' that can crawl the contents of your hard disk looking for the signatures used by the start of partitions and list out their locations. When you recreate your partition it must start on the exact same starting sector that it used to be on or all the filesystem structures within it will not be in the correct offsets/locations and it will not be recognised. I'd download something called sysrescuecd since I believe that contains gpart (though it might be worth checking their web site contents list to make sure before you download a CD's worth of data).

Also, you can use e.g file -s /dev/sda1 to list what it thinks the partition contains.

And while I'm on "also"s, you should not run 6.4 or 6.5. 6.7 is current and all previous releases are unsupported. You should run a complete yum update ASAP as soon as you have fixed this.
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

swesque
Posts: 3
Joined: 2015/09/13 01:10:18

Re: Grub doesn load. Missing partition?

Post by swesque » 2015/09/13 16:52:58

Trevor,

Thanks for the suggestions as I am over my head. I've worked with CentOS for 1 - 2 years but mostly as a user.

Will the utilities you mention still work now that I've already used cfdisk, mkfs.ext4 and e2label to replace the sda1 partition I deleted?

I was able to mount the partition once ext4 was in place.

This allowed me to run: grub-install --root-directory=/media/sda1 /dev/sda1. "No errors reported" but reboot fails after removing CentOS DVD. It lands me on the grub> command line. The file /media/sda1/boot/grub/device.map only has one line, hd0. (The full message after grub-install said I may need to tinker with device.map)

I have to go out of town for 3-5 days on an unplanned business trip. I will log on to the forum but I won't have the server with me.

Stick with me. I'll let you know when I'm back from the trip.

Thanks again.

-gt

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

Re: Grub doesn load. Missing partition?

Post by TrevorH » 2015/09/13 17:42:58

Once you mkfs it, it's dead and all data is gone beyond reasonable attempts to get it back. If you just use fdisk then that does not write to the data portion of the disk, only to the partition table of the device and no data is overwritten. You couldn't mount it before because you recreated the partition in the wrong place - if it had been in the right location then you could have just mounted it and it would have been back.

Since this sounds like it is your /boot partition that's involved, you will of course need to reinstall all the kernels that are present on the system to get the files back. Running e.g. yum reinstall kernel-2.6.32-573.3.1.el6.x86_64 (substitute whatever values you get from rpm -q kernel in that) should reinstall the kernels in question and recreate the initramfs files for each of them. There may be other steps to get grub working that I haven't thought of.
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

swesque
Posts: 3
Joined: 2015/09/13 01:10:18

Re: Grub doesn load. Missing partition?

Post by swesque » 2015/09/23 18:47:21

I'm back. My trip took longer than expected but I'm ready to resume efforts to recover my server.

To recap:
1. System was built with CentOS 6.4. Yum updated to 6.5.
2. I deleted my sda1 partition by mistake. I assume this was my boot partition that contained Grub.
3. Server wouldn't boot after restart. Instead I get the Grub prompt (grub>).
4. System and user files are intact on sda2. I need to preserve the user files.
5. I used cfdisk to create a replacement sda1 partition.
6. I used mkfs.ext4 /dev/sda1 to format the recreated partition - so couldn't use gpart.
7. file -s /dev/sda1 returns..
/etc/magic, 0: Warning: using regular magic file '/usr/share/misc/magic'
file: could not find any magic files

Booting from CentOS 6.4 disk | Rescue Installed System, I ran rpm -q kernel. This results in..

kernel-2.6.32-431.17.1.el6.x86_64
kernel-2.6.32-431.29.2.el6.x86_64
kernel-2.6.32-504.el6.x86_64
kernel-2.6.32-504.1.3.el6.x86_64
kernel-2.6.32-573.3.1.el6.x86_64

Do I run yum reinstall for each?
How do I know this will write to the sda1 partition? How does yum know where to put the reinstalled files?

Thanks.

I'm off to WalMart for a large thumb drive to save off important user files.

-gt

Post Reply