LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 11-23-2009, 12:38 PM   #1
k0mdk
LQ Newbie
 
Registered: Aug 2009
Posts: 5

Rep: Reputation: 0
Fedora: Need help removing GRUB from the mbr from within Linux


I have a dual-boot system with XP and Fedora, and recently applied updates to WinXP, which caused XP to give the BSOD on startup. I would like to wipe XP and reload from scratch, but the reload image is on a separate partition that I cannot access with GRUB installed. I don't have a DOS startup disk, and cannot get far enough into windows to use the fdisk /mbr option. I found a suggestion to use:

$ dd if=/dev/null of=/dev/hda bs=446 count=1

but when I use it, I get 0 Bytes copied, and no joy on reboot. I just need to disable GRUB long enough to get access to my restore partition and re-install windows. I'm a rank newbie with linux (and just switched over to Fedora from Mandriva), and would really appreciate as much detail as possible.

Thank You

Mike
 
Old 11-23-2009, 12:45 PM   #2
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
I'm not sure removing/disabling grub will help you at all, if you don't replace it with something else.

What is it that you want to do? Do you want to boot into xp? Or do you want to access a partition different from your linux one where your restore image file is?
 
Old 11-23-2009, 12:48 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Several points:
  1. If there is no boot code in the MBR, you cannot get into any other partition---only to a different physical drive (by changing BIOS settings)
  2. fixmbr should be accessible by simply booting from the Windows CD--rescue mode.
  3. Perhaps you need sda instead of hda in the dd command----run "fdisk -l" (as root) to see how your drives are seen by the system
 
Old 11-23-2009, 01:08 PM   #4
k0mdk
LQ Newbie
 
Registered: Aug 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by tom4everitt View Post
I'm not sure removing/disabling grub will help you at all, if you don't replace it with something else.

What is it that you want to do? Do you want to boot into xp? Or do you want to access a partition different from your linux one where your restore image file is?
I'm trying to get access to the partition where my restore image is located (it's bootable), but GRUB doesn't seem to recognize it as a partition, and the utility I have to set it as the primary boot partition gets bypassed when GRUB loads. What I'd like to do is set my mbr the way it was before GRUB was installed so that partition will boot
 
Old 11-23-2009, 01:11 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by k0mdk View Post
I'm trying to get access to the partition where my restore image is located (it's bootable), but GRUB doesn't seem to recognize it as a partition, and the utility I have to set it as the primary boot partition gets bypassed when GRUB loads. What I'd like to do is set my mbr the way it was before GRUB was installed so that partition will boot
fixmbr from the Windows CD
 
Old 11-23-2009, 01:18 PM   #6
k0mdk
LQ Newbie
 
Registered: Aug 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany View Post
Several points:
  1. If there is no boot code in the MBR, you cannot get into any other partition---only to a different physical drive (by changing BIOS settings)
  2. fixmbr should be accessible by simply booting from the Windows CD--rescue mode.
  3. Perhaps you need sda instead of hda in the dd command----run "fdisk -l" (as root) to see how your drives are seen by the system

Unfortunately, I don't have a Windows CD. This system came with a ghost image stored on a hidden partition for restoring it (it's a Dell Inspiron).

I tried using the fdisk command as root, but got back that it's an unrecognized command. I tried the sda instead of hda, and the system created a backup file, but would not reset the mbr.
 
Old 11-23-2009, 01:28 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by k0mdk View Post
the reload image is on a separate partition that I cannot access with GRUB installed.
Assuming you still have a valid reload image, it is pretty easy to chainload to it from grub.

You just need to edit the correct entry into the /boot/grub/menu.lst file to offer that choice during boot.

If you post the output from fdisk -l as root, I think someone will be able to tell you what to put into menu.lst

It also might help to post your current menu.lst

Quote:
Originally Posted by k0mdk View Post
I found a suggestion to use:

$ dd if=/dev/null of=/dev/hda bs=446 count=1

but when I use it, I get 0 Bytes copied,
Where did you get an insane idea like that?
I don't recall dd syntax well enough to understand why trying that didn't destroy the portion of grub in the MBR. You're lucky it didn't. That would have made your task significantly harder.

Quote:
I just need to disable GRUB long enough to
Disabling GRUB would do you no good and significant harm.

The Microsoft MBR code was overwritten by installing GRUB, but breaking GRUB won't bring back the Microsoft MBR code.

If you could easily bring back the Microsoft MBR code, that would be an alternate path to booting your recovery partition, but not necessarily the easiest path and certainly not the only path.

Quote:
Originally Posted by pixellany View Post
Perhaps you need sda instead of hda in the dd command
Do you really want to help someone fix whatever lucky incorrect detail stopped a really wrong and destructive plan from doing any harm?

Quote:
Originally Posted by k0mdk View Post
I tried using the fdisk command as root, but got back that it's an unrecognized command.
I hope that just means /sbin wasn't in your path. In that case you can use
Code:
/sbin/fdisk -l
Otherwise it means fdisk isn't installed. I don't know Fedora well enough to know whether fdisk is optional. In Centos, fdisk is part of a package named util-linux that appears to be installed by default.

Last edited by johnsfine; 11-23-2009 at 01:48 PM.
 
Old 11-23-2009, 01:51 PM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by johnsfine

Quote:
Originally Posted by pixellany
Perhaps you need sda instead of hda in the dd command
Do you really want to help someone fix whatever lucky incorrect detail stopped a really wrong and destructive plan from doing any harm?
If someone wants to install Windows, this is a very common way to clear the MBR so the Windows installer will work.

My first point was that removing the code in the MBR would not allow getting into ANY partitions.

GRUB can be re-installed from any Linux LiveCD
Quote:
Where did you get an insane idea like that?
Would you believe right here at LQ? As I said, a very common fix.

Last edited by pixellany; 11-23-2009 at 01:53 PM.
 
Old 11-23-2009, 01:59 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by k0mdk View Post
I tried using the fdisk command as root, but got back that it's an unrecognized command. I tried the sda instead of hda, and the system created a backup file, but would not reset the mbr.
On some systems (eg Fedora) root has a different PATH. Use "su -" to switch to root---then things like fdisk will be in the PATH.

Last edited by pixellany; 11-23-2009 at 02:11 PM. Reason: typo
 
Old 11-23-2009, 02:19 PM   #10
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by pixellany View Post
If someone wants to install Windows, this is a very common way to clear the MBR so the Windows installer will work.
What Windows installer needs you to remove GRUB first? None I've ever tried.
It is common when something unrelated goes wrong with a Windows installer after Linux was present, the confused user asks for help getting rid of GRUB or Linux or whatever. After they get rid of GRUB, whatever was originally wrong with the Windows installer is still wrong. Using dd might well be a common correct way to clear the MBR, and thinking you need to clear the MBR might also be correct. By actually needing to clear the MBR is certainly not common.

Quote:
My first point was that removing the code in the MBR would not allow getting into ANY partitions.
I saw. I just didn't think it was enough of a warning under these conditions.

Quote:
GRUB can be re-installed from any Linux LiveCD
I know it can and next time I need to do that, I hope I can quickly find out how. But most of the time I prefer to not break grub in the first place. My guess was the OP would have a slightly harder time figuring out how to fix GRUB than I would and thus a better reason to not break it.

After this long side track, I think I need to repeat: The OP should post the current contents of /boot/grub/menu.lst as well as the ouput of fdisk -l (gotten using either Pixellany's suggestion for using root with the right path or my suggestion of directly specifying /sbin or whatever works).

Last edited by johnsfine; 11-23-2009 at 02:22 PM.
 
Old 11-23-2009, 05:05 PM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
@johnsfine;
I'm going to avoid a lengthy debate--mostly because we're already at the limits of my competence......

For Windows to refuse to install when it sees something "alien" on the disk is (or was) quite common. My last experience was with Windows 2K. I don't remember all the tricks I used, but clearing the MBR was certainly one of them. I seem to recall reading all manner of solutions, including clearing the MBR all the way to erasing the whole disk.

I just read the Microsoft article on installing Windows over Linux. They talk about deleting partitions (which will not be done by OP's command). I have always just zeroed the whole MBR using bs=512 in the dd command.
 
Old 11-25-2009, 05:19 PM   #12
k0mdk
LQ Newbie
 
Registered: Aug 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Sorry about the delay between posts. Work always seems to get in the way of the important things :-)

Anyway, thank you for clarifying what that command would have done. I was under the impression that GRUB was an add-on in the mbr, and that the command listed would just clear out GRUB and leave the rest of the MBR intact. That would have made for a few more hours of frustration.

I did find the fdisk command, although even after using su, I had to list the entire path to use it. Here is the output from it:

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd0f4738c

Device Boot Start End Blocks Id System
/dev/sda1 1 6 48163+ de Dell Utility
/dev/sda2 * 7 6888 55279665 7 HPFS/NTFS
/dev/sda3 6889 9270 19133415 5 Extended
/dev/sda4 9271 9729 3686917+ db CP/M / CTOS / ...
/dev/sda5 8171 9270 8835718+ 7 HPFS/NTFS
/dev/sda6 6889 6914 208782 83 Linux
/dev/sda7 6915 8170 10088788+ 8e Linux LVM

Partition table entries are not in disk order

Disk /dev/dm-0: 8187 MB, 8187281408 bytes
255 heads, 63 sectors/track, 995 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x30307800

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/sdb: 2063 MB, 2063597056 bytes
255 heads, 63 sectors/track, 250 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x91f72d24

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 251 2015200 b W95 FAT32
Partition 1 has different physical/logical endings:
phys=(249, 254, 63) logical=(250, 225, 38)

On the hard drive, I know that there is a partition that contains Dell utilities for testing the hardware, the partition that holds the restore image, and a partition for data back up (that I created when I installed Linux), in addition to the main NTFS partition and Linux partitions.

Quote:
Originally Posted by johnsfine View Post
It also might help to post your current menu.lst
I'm afraid I'm not familiar enough with the command line to open up menu.lst and display it (or for that matter edit it), although it does seem like it would be a lot easier route to access that partition from GRUB.

I appreciate everyone getting me on the right track!
 
Old 11-26-2009, 02:11 PM   #13
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
Your menu.lst is actually just a text file (containing preferences for grub). Its path is /boot/grub/menu.lst.

You can open it just as you open any text file, simply:

Code:
gedit /boot/grub/menu.lst
If you want to be able to edit it you need to do it as root, i.e add sudo before.


You will find all your current grub entries in this file, i.e the alternatives you get when you boot. Among these you can add the following to get an option for your Dell Utility partition:

Code:
# Manually added entry for restore partition
title Dell Utility
root        (hd0,0)
makeactive
chainloader +1
This should give you a "Dell Utility" option at startup. Although I think chances are pretty good this will work, I want to mention that there's a slight chance of booting into the restore partition will mess up your grub. If that would happen you can restore it quite easily with a live cd, so don't panic if it happens. Either get back here or read this for an excellent grub guide:

http://www.dedoimedo.com/computers/grub.html

Last edited by tom4everitt; 11-26-2009 at 02:16 PM.
 
Old 11-26-2009, 02:14 PM   #14
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
Also, I think it should be quite clear where to add the entry I posted. If not, just post your current menu.lst and I'll tell you the exact position.
 
Old 11-29-2009, 01:08 PM   #15
k0mdk
LQ Newbie
 
Registered: Aug 2009
Posts: 5

Original Poster
Rep: Reputation: 0
The info from everyone was a great help! Thank you. I'm starting the reload process on it now, and from everything everyone's told me, I'd suspect GRUB will be overwritten by Microsoft's MBR, but I have a live cd, so that shouldn't be a big deal, and I've learned a bit more about working with the command prompt. Thanks again!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing grub from MBR alek66 Linux - General 5 04-20-2007 10:32 AM
Removing Linux/Lilo from MBR hsimah Slackware 6 09-01-2006 07:21 PM
removing GRUB from MBR gomez6211 Linux - Newbie 1 07-25-2005 10:09 AM
problems with formatting second disc after removing grub from mbr aabeeikora Linux - Newbie 2 08-02-2003 02:05 PM
Removing GRUB and restorung MBR TotalNoob Linux - Newbie 1 04-04-2003 09:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 07:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration