Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-06-2009, 06:28 PM
|
#1
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Rep:
|
I've deleted GRUB and can't reinstall it
EDIT:
I've forgotten to add/make clear, as I have said this is a single OS system, if there is a less complicated fix that will leave me without grub (but with a bootable system) that would be fine. Something like but I understand that command is only for DOS, correct?
Hello,
I've managed to delete/screw up my installation of GRUB. My hardware RAID controller had gone on the fritz and I was getting an operating system not found message during boot. Turns out I needed to reload the firmware for the card. I now believe the card is working fine however in trying to troubleshoot the problem (which I initially thought might have been related to GRUB) I have managed to hose GRUB, and I now see
Code:
Loading GRUB..
Error 15
at startup. I am running Ubuntu 8.0.4 LTS. I have been using an 8.10 desktop live cd for troubleshooting. grub-install does not work when using the live cd. I have tried to follow directions given on this page: http://ubuntuforums.org/showthread.php?t=224351 However if I chroot to where my OS partition is mounted on the live cd:
it does not recognize the grub command.
If I simply try:
Code:
sudo grub
find /boot/grub/stage1
it does not find them. If I try:
Code:
sudo grub
root (hd0,0)
setup (hd0)
it checks for stage1 and does not find it. (This may be related to the fact that I am not chroot'ed to the correct OS partition when trying to run these commands, since, as I have mentioned before, I can't get the grub command to run after I chroot to my OS partition.)
When I initially started fooling around with grub I did not even have a boot partition, so I am not even sure that I had GRUB installed in the first place (this was simply a clean install of 8.0.4, not a dual boot system) but since then I must have screwed up the MBR by trying to reinstall/fix what I thought was a broken GRUB.
I could not find the GRUB files on my computer, so I have downloaded GNU Grub 0.97 and unzipped it, and moved the entire contents into a /boot folder which I created, so I now have the proper /boot/grub/stage1 directory. (However I never ran any installation after downloading grub, I simply moved the files, perhaps this is the issue).
Anyways, sorry for the long-winded question, I have tried all I can think of and just wanted to give the full details of the situation. If anyone can offer any help I would greatly appreciate it.
Last edited by ceruleance; 02-06-2009 at 06:36 PM.
|
|
|
02-06-2009, 07:24 PM
|
#2
|
LQ Guru
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 11,385
|
The above command works to fix windows mbr xp and earlier if you cannot boot your windows OS. Since you indicate you have only Ubuntu OS, that would not be of much help to you?
Error 15 is file not found so Grub is not being pointed to the right place to find necessary file or, for some reason, the file is gone! The latter seems more likely based on Grub being unable to give positive responses to the find commands.
Quote:
When I initially started fooling around with grub I did not even have a boot partition, so I am not even sure that I had GRUB installed in the first place (this was simply a clean install of 8.0.4,
|
What?? Were you ever able to actually boot Ubuntu? You don't need a /boot partition. You do need a /boot directory. Also, there is no /boot/grub stage1 directory but there should be a stage1 file in your /boot/grub/ directory. stage1 is a 512 byte file which goes in to your mbr.
Downloading Grub files and putting them in a /boot directory won't help. The commands you used:
sudo grub
root (hd0,0)
setup (hd0)
should work using them from a terminal in your install CD, assuming that Ubuntu is on sda1??
It would be helpful if you could go to the grub prompt and enter the command: geometry (hd0), post the output or post the output from terminal as root of "fdisk -l", not from grub.
|
|
|
02-06-2009, 07:52 PM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,379
|
Does "find /grub/stage1" work better ?
Edit: go get and run this sript. Can be done from a liveCD - save the output file to a USBkey in need. Post that RESULTS.txt file here.
Last edited by syg00; 02-06-2009 at 08:00 PM.
|
|
|
02-06-2009, 08:01 PM
|
#4
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Original Poster
Rep:
|
Yancek:
First of all, thank you for your speedy reply.
Correct, I am not running Windows so I would not expect fdisk /MBR to be of much help to me. I was hoping there was an equivalent linux cmd.
I was indeed able to boot to this system at one point, and, as far as I can recall there was no GRUB screen asking me what kernel to use, etc., so I am not sure what that means in terms of what boot loader was being used. Whatever is the default that is installed with Ubuntu (GRUB?)
Your advice made me attempt to install the grub files that I downloaded instead of just copying them to a /boot directory (sorry, earlier I mistakenly said boot partition when I meant directory). From the readme file I ran
Code:
configure
make
make install
in the grub directory. This seems to have done more harm than good as now when I try to get to a grub prompt I get :
Code:
ubuntu@ubuntu:~$ sudo grub
Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version /boot/grub/default (-1214616480K lower / -1214284104K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
Segmentation fault (core dumped)
I imagine this may have something to do with trying to install grub while running from the livecd and not pointing to the appropriate OS partition. Are there flags that will allow me to point to the appropriate directory during the configure process/command? Since I cannot get to the grub prompt (I'll try again after reboot) here is the result of fdisk -l instead:
Code:
ubuntu@ubuntu:~$ sudo fdisk -l
Disk /dev/sda: 1999.9 GB, 1999943761920 bytes
255 heads, 63 sectors/track, 243145 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00066392
Device Boot Start End Blocks Id System
/dev/sda1 * 1 9726 78124063+ 83 Linux
/dev/sda2 9727 243145 1874938117+ 5 Extended
/dev/sda5 9727 10699 7815591 82 Linux swap / Solaris
/dev/sda6 10700 243145 1867122463+ 83 Linux
Disk /dev/sdb: 1599.9 GB, 1599955009536 bytes
255 heads, 63 sectors/track, 194516 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009dd54
Device Boot Start End Blocks Id System
/dev/sdb1 1 194516 1562449738+ 5 Extended
/dev/sdb5 1 194516 1562449707 83 Linux
sda1 is the location of the 80gb OS partition on my first raid array. sda6 is the rest of the first array containing my data. sdb5 is a second array also containing data.
Thanks again for all your help, let me know how to proceed
|
|
|
02-06-2009, 10:36 PM
|
#5
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Original Poster
Rep:
|
Quote:
Originally Posted by syg00
Does "find /grub/stage1" work better ?
Edit: go get and run this sript. Can be done from a liveCD - save the output file to a USBkey in need. Post that RESULTS.txt file here.
|
find /grub/stage1 also returns file not found.
Attached is the results from the bootinfo script: results.txt. It seems like everything is in order to me, it says grub is installed and looking in the right place.. maybe you guys can see something out of order?
Here is geometry (hd0) from the grub prompt. By the way, once the livecd rebooted the grub command/prompt went back to normal, as expected. It makes me think my previous attempts at reinstalling grub were obviously unsuccessful as they were trying to install it on the livecd and not on the OS partition.
Code:
grub> geometry (hd0)
drive 0x80: C/H/S = 243145/255/63, The number of sectors = -388827136, /dev/sda
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 4, Filesystem type unknown, partition type 0x82
Partition num: 5, Filesystem type is ext2fs, partition type 0x83
|
|
|
02-06-2009, 11:26 PM
|
#6
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,379
|
My reading of that says grub hasn't been installed - as in "grub-install" or "setup (hd0)". One of the (partition) boot sector records (/dev/sda1 in your case) should specify something like
Code:
Boot sector type: Grub
Boot sector info: Grub0.97 is installed in the boot sector of sda9 and
looks at sector 192716752 of the same hard drive for
the stage2 file. A stage2 file is at this location on
/dev/sda. Stage2 looks on partition #9 for
/boot/grub/menu.lst.
|
|
|
02-06-2009, 11:39 PM
|
#7
|
Senior Member
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,410
Rep: 
|
If you don't want to become a grub expert and just want your system to boot, then download Super Grub Disk and let it do the job for you. It's bailed me out several times.
|
|
|
02-07-2009, 12:20 AM
|
#8
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Original Poster
Rep:
|
Quote:
Originally Posted by syg00
My reading of that says grub hasn't been installed -
|
Ahh, I was thinking from the initial message that it was OK, but you are right that it is odd that there is no boot sector type or info in sda1.
Quote:
Originally Posted by Quakeboy02
If you don't want to become a grub expert and just want your system to boot, then download Super Grub Disk and let it do the job for you. It's bailed me out several times.
|
Thanks. I'll give this a shot and post the result
|
|
|
02-07-2009, 08:56 AM
|
#10
|
Member
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247
Rep:
|
From the results of the Boot Info Script, it looks like the source of your problems is you don't have a /boot directory with any of Ubuntu's boot files (kernels, initrd images, etc) nor a /boot/grub directory in your sda1 partition. How about posting the output of:
Code:
sudo mount /dev/sda1 /mnt && ls -l /mnt /mnt/boot /mnt/boot/grub
Last edited by CJS; 02-11-2009 at 05:40 PM.
|
|
|
02-11-2009, 04:30 PM
|
#11
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Original Poster
Rep:
|
Hi Everyone, sorry for the delay.
I ran the Super Grub Disk and tried to have it auto repair the MBR for my GNU/Linux but it returned error 15 and said it was unsuccessful.
Quote:
Originally Posted by CJS
From the results of the Boot Info Script, it looks like the source of your problems is you don't have a /boot directory with any of Ubuntu's boot files (kernels, initrd images, etc) nor a /boot/grub directory in your sda1 partition. How about posting the output of:
Code:
sudo mount /dev/sda1 /mnt && ls -l / /boot /boot/grub
|
I think you are right that this is the issue. I am running the live cd so the command you gave me does not return what I think you intended it to return (it just finds the /boot partition from the livecd)
However, I have no boot directory in / on the actual system, and thus obviously no /boot/grub and no kernels or initrd images.
What's the best way to restore these?
|
|
|
02-11-2009, 05:51 PM
|
#12
|
Member
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247
Rep:
|
OK, how about doing the following from your Live CD:
Code:
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt
mkdir -p /boot/grub
apt-get install grub
apt-get remove linux-headers-2.6.24-22-generic linux-image-2.6.24-22-generic linux-restricted-modules-2.6.24-22-generic linux-ubuntu-modules-2.6.24-22-generic
apt-get install linux-headers-2.6.24-22-generic linux-image-2.6.24-22-generic linux-restricted-modules-2.6.24-22-generic linux-ubuntu-modules-2.6.24-22-generic
grub-install /dev/sda
update-grub
exit
Please post the output of all the above commands.
|
|
|
02-11-2009, 10:49 PM
|
#13
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Original Poster
Rep:
|
Thanks for the post. I gave it a shot, note I used /media/disk instead of /mnt. I run into a problem with the apt-get commands not working.
Thoughts?
Code:
mount --bind /dev /media/disk/dev
mount --bind /proc /media/disk/proc
root@ubuntu:/media/disk/dev# cp /etc/resolv.conf /media/disk/etc/resolv.conf
root@ubuntu:/media/disk/dev# chroot /media/disk
root@ubuntu:/# mkdir -p /boot/grub
root@ubuntu:/# apt-get install grub
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
root@ubuntu:/# dpkg --configure -a
Setting up initramfs-tools (0.85eubuntu36) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-2.6.24-19-server
Cannot find /lib/modules/2.6.24-19-server
update-initramfs: failed for /boot/initrd.img-2.6.24-19-server
dpkg: subprocess post-installation script returned error exit status 1
Last edited by ceruleance; 02-11-2009 at 10:50 PM.
|
|
|
02-12-2009, 12:43 AM
|
#14
|
LQ Newbie
Registered: Feb 2009
Posts: 7
Original Poster
Rep:
|
Gentlemen (and Ladies?),
Thank you very much for your invaluable help. After much trial and tribulation it appears that somehow GRUB was corrupted on my operating system, and possibly other files as well, as all attempts to reinstall or fix grub failed.
I finally gave up and decided to wipe the partition and reinstall. All my data was backed up and I also made a backup of important system files and folders (/etc, etc.) to assist in restoring my configuration. I then used my Ubuntu 8.0.4 LTS system CD and used the Install Base OS option in the Rescue a Broken System utility. After flagging my original 80gb OS partition as the new mount point for / and instructing it to format this partition (but leave the other partitions with my data on them intact) I was able to reinstall the OS and it is now booting properly.
For anyone who reads this in the future and is having severe issues with GRUB as I was having I'm sorry I couldn't help more but this is the solution that worked for me.
Thanks to everyone for their advice and help!
|
|
|
02-12-2009, 07:39 AM
|
#15
|
Member
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247
Rep:
|
Sorry to hear you couldn't salvage your Ubuntu install, but it looks like you made the right choice with reinstalling. Cheers, hope your new installation runs smoother and you don't run into any major problems. 
|
|
|
All times are GMT -5. The time now is 06:51 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|