PDA

View Full Version : Rebuild the boot partition



astern
12th December 2010, 06:36 PM
Hi All,

I really screwed up and deleted my /boot partition.

My partition setup at this point is:

Device start end size type system flags
/dev/sda1 32kB 161GB 161GB primary ntfs boot*
/dev/sda2 161GB 161GB 300MB primary ext4
/dev/sda4 225GB 308GB 83.4GB extended
/dev/sda5 225GB 308 GB 83.4GB logical lvm

so /dev/sda2 is the new boot partition I have created and formatted ext4. I booted from a live cd, mounted the partion, and did grub-install /mountpoint /dev/sda2. So I think what I need to do now is copy the kernel images to this partition and recreate the menu.lst to boot into fedora or "Other".

What images do I need to copy over and where can I find them on my root partition? And, if these can be found and copied over, what should my menu.lst look like?

I'm such a moron, I can't believe I did this! (don't ask) Any help would be greatly appreciated!!

DBelton
12th December 2010, 06:51 PM
well, the kernel images aren't stored anywhere except in /boot. You also have the initramfs images but they could be rebuilt with dracut once you get the vmlinuz images. There is also the System.map files, and config files.

In /boot/grub you have quite a few files in there as well. I don't know if a booting from a live cd and reinstalling grub would fix those or not. It looks like there are some files for each different type of filesystem in there, too, plus the splash image, device.map, and grub.conf. menu.lst is just a symlink to grub.conf

also under /boot is an efi directory, too.

I'm not so sure you could just recreate /boot. I don't know how much good it would do to boot from a fedora install cd/dvd, and repair the existing install.

This is basically the /boot/grub.conf file that is created on a fresh install:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_tower10-lv_root rhgb quiet
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=1
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title Fedora (2.6.35.6-45.fc14.i686)
root (hd0,0)
kernel /vmlinuz-2.6.35.6-45.fc14.i686 ro root=/dev/mapper/vg_tower10-lv_root rd_LVM_LV=vg_tower10/lv_root rd_LVM_LV=vg_tower10/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet
initrd /initramfs-2.6.35.6-45.fc14.i686.img


You would have to (of course) change the root, and rd_LVM_LV parameters to what your's is named.

jpollard
12th December 2010, 06:54 PM
The best source for a kernel+initramfs (or intird)+system.map files
is the rescue disk (you can get tem from a live CD, but the install DVD
may be a little bit better). These files don't exist elsewhere (unlike the
grub files), unless you made a backup...

Once you can boot the system, you can then get the updated kernels
(though there may be some issues with rpm thinking the kernels are
already installed).

It will at least get you booted.

astern
12th December 2010, 06:59 PM
Ok, so if I wanted to just get the system back up and running, what should I copy over from the live cd? Also, what entries should I put in the menu.lst to be able to boot to either linux or windows?

DBelton
12th December 2010, 07:17 PM
the menu.lst is just a symlink to /boot/grub.conf

but in addition to the grub.conf file I posted above, add the following to the bottom

title Windows XP
rootnoverify (hd0,0)
chainloader +1

(assuming your windows is on the first partition of the first hard drive.)

astern
12th December 2010, 07:30 PM
Well, I may have another problem. I created a basic grub.conf in /boot and soft linked it to menu.lst in the root directory of my boot partition. However, when I boot, I get nothing but a grub prompt. No countdown timer or any menu. Any thoughts?

DBelton
12th December 2010, 07:38 PM
grub.conf file goes in /boot/grub not in /boot
same with the symlink

the path is /boot/grub/grub.conf
the symlink is /boot/grub/menu.lst -->./grub.conf

But it may not work even then due to the other files you have missing. :(

I attached a directory list of the files in /boot and all subdirectories on my system to kinda give you some idea as to what all is in there. (I have 3 kernels installed, you only have to have 1.)

astern
12th December 2010, 07:48 PM
Ok, I moved the grub.conf file to /boot/grub and syminked menu.lst -> grub.conf

still nothing but a grub prompt. However, from the grub prompt I can type

rootnoverify (hd0,0)
chainloader +1
boot

and I get into windows.

I left out the splash image line, because I don't have a splashimage file. Could that be hanging it up?

DBelton
12th December 2010, 08:05 PM
It shouldn't if you left out the splash image line, but if you have the DVD, you have a splashimage file. there is one located in /EFI/BOOT on the DVD.

you could just copy the splash.xpm.gz file from /EFI/BOOT on the DVD to /boot/grub on your hard drive.

I couldn't find any of the other files you could just copy over from the DVD, though. I think it actually builds a lot of them when you install.

I did find that there are the vmlinuz, system map and config files in the kernel rpm on the install dvd. those 3 files could be extracted from the rpm and copied into the /boot folder and then the initramfs built with dracut. The kernel package is in the /packages folder on the DVD.

I don't know what tools you have available, so I don't know if you have anything to extract those 3 files from the rpm or not, though. (You possibly could do it in windows, but never tried it before. The rpm is a regular archive file and can be opened and files extracted with archive manager in linux.)

astern
12th December 2010, 08:18 PM
I'm working in linux from the live cd so I can use any tool that comes in the fedora 14 standard distro. I could install anything nonstandard. Sorry for the confusion, I'm reading and writing to this forum from a windows laptop, hence the stupid widows icon next to all my messages.

I copied the splash.xpm.gz and included the splashimage line. Still nothing but a grub prompt. Did my install of grub not work correctly? Why am I not at least getting a grub menu?

Also, please note. I only care about getting windows back up because at least then I know that grub is working and I can work toward getting my linux side back up which I think is going to be more involved.

DBelton
12th December 2010, 08:31 PM
you can try editing the /boot/grub/grub.conf file and comment out the linux lines like so:


# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_tower10-lv_root rhgb quiet
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=1
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
#title Fedora (2.6.35.6-45.fc14.i686)
#root (hd0,0)
#kernel /vmlinuz-2.6.35.6-45.fc14.i686 ro root=/dev/mapper/vg_tower10-lv_root #rd_LVM_LV=vg_tower10/lv_root rd_LVM_LV=vg_tower10/lv_swap rd_NO_LUKS rd_NO_MD #rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet
#initrd /initramfs-2.6.35.6-45.fc14.i686.img
title Windows XP
rootnoverify (hd0,0)
chainloader +1


This should boot into your windows install.

You could also change the line

default=0

to default=1

(assuming you only had 1 linux kernel option before the windows option)

astern
12th December 2010, 08:37 PM
Thanks for the suggestion but I think there is something else wrong.

Here's what happens. I boot and get just a grub prompt. I can then say splashimage=(hd0,1)/boot/grub/splash.xpm.gz and the splashimage comes up.

Then I can say configfile=(h0,1)/boot/grub/grub.conf and the menu comes up (sortof) and I hit enter and windows boots up.

So what this tells me is that the grub.conf file is file, the partitions are file. What I can't understand is why grub.conf isn't getting loaded.

DBelton
12th December 2010, 09:17 PM
you can configure grub and possibly fix that problem..

boot from (almost) any live cd
# su
# grub
grub> device (hd0) /dev/sda (or whatever your disk is)
grub> root (hd0, 1) (tell it which partition to use)
grub> setup (hd0)
grub> quit
#

also in the grub.conf file, the splashimage line should be

splashimage=(hd0,1)/grub/splash.xpm.gz (change the hd0,0 to hd0,1)
same thing for the root (hd0,0) change to root (hd0,1)

I forgot that in my grub.conf, I didn't have a windows install on that box.

leave the one in the windows section as hd0,0

astern
12th December 2010, 09:26 PM
Well, I think I'm giving up. Probably for the better, I'm wiping the thing clean and just putting 14 on it. I think this will take less time than fixing the destruction my previous mistakes have caused. Thanks for the help!

DBelton
12th December 2010, 09:41 PM
I was going to say the same thing, but there are sometimes good reasons for wanting to salvage a hosed system before doing a reinstall.

One thing is that you learn a lot by trying it. I'm sure you learn a thing or two today! :D The main one being.. THOU SHALT NOT DELETE /boot! lol

Before you wipe it and reinstall, mount the drives and salvage anything you wish to keep.