LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
Search this Thread
Old 03-11-2005, 12:50 AM   #1
Comatose51
Member
 
Registered: Jan 2003
Location: New Haven, CT
Distribution: RedHat 8.0
Posts: 54

Rep: Reputation: 15
Using Linux's fdisk to erase or fix a MBR?


My friend somehow managed to write a MBR to his new IDE hard drive. Now his OS won't boot whenever it's plugged in because his compute reads the IDE drive first while his OS is on a SATA drive. He's tried changing order but doesn't seem to work.

I suggested using Knoppix to boot and use fdisk to erase the MBR. However, is fdisk capable of this?

Thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-11-2005, 01:06 AM   #2
tsphan
Member
 
Registered: Jan 2005
Location: Clackamas, Oregon, US
Distribution: Slackware 10.2
Posts: 154

Rep: Reputation: 30
i do not know whethere fdisk can or not, but you friend could try and use the "dd" command to perfectly erase the entire mbr. I accidently did this on my computer and i lost my partition tables and everything on the MBR a month ago or so.
 
Old 03-11-2005, 01:29 AM   #3
Comatose51
Member
 
Registered: Jan 2003
Location: New Haven, CT
Distribution: RedHat 8.0
Posts: 54

Original Poster
Rep: Reputation: 15
How would you do that with dd?

I don't understand the command very well and have only really seen it used a few times before.
 
Old 03-11-2005, 04:30 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,430

Rep: Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055
Re: Using Linux's fdisk to erase or fix a MBR?

Quote:
Originally posted by Comatose51
My friend somehow managed to write a MBR to his new IDE hard drive. Now his OS won't boot whenever it's plugged in because his compute reads the IDE drive first while his OS is on a SATA drive. He's tried changing order but doesn't seem to work.
This doesn't sound right.
Sounds like the BIOS isn't recognising the SATA as a primary disk if an IDE is present. The BIOS boots the primary disk - no ifs, no buts.
It doesn't cycle through to other disks.
Sounds like you mate needs a BIOS update - or a new motherboard.
Quote:
I suggested using Knoppix to boot and use fdisk to erase the MBR. However, is fdisk capable of this?
Won't help - not a function of fdisk, and see comment above.
 
Old 03-11-2005, 01:34 PM   #5
camelrider
Member
 
Registered: Apr 2003
Location: Juneau, Alaska
Posts: 245

Rep: Reputation: 31
Or how about using the Knoppix CD to install LILO to the MBR of the IDE drive?
 
Old 03-11-2005, 10:01 PM   #6
Comatose51
Member
 
Registered: Jan 2003
Location: New Haven, CT
Distribution: RedHat 8.0
Posts: 54

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by camelrider
Or how about using the Knoppix CD to install LILO to the MBR of the IDE drive?
Friend is afraid of Linux. Wanted to use the opportunity to show him how useful Linux is and then go from there... Alas, the lack of a quick answer persuaded him to install Windows XP on the hard drive and just migrate OS hard drives....
 
Old 03-12-2005, 06:34 PM   #7
tsphan
Member
 
Registered: Jan 2005
Location: Clackamas, Oregon, US
Distribution: Slackware 10.2
Posts: 154

Rep: Reputation: 30
you probably don't need the dd command anymore, but if the mbr does mess up for no reason,

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

HD is your hard drive letter

though, i'm guessing you're not going to need that anymore, and it's best not to, it ruined my partition tables
 
Old 03-12-2005, 07:03 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,430

Rep: Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055
Quote:
Originally posted by tsphan
you probably don't need the dd command anymore, but if the mbr does mess up for no reason,
dd if=/dev/zero of=/dev/HD count=1 bs=512
HD is your hard drive letter

though, i'm guessing you're not going to need that anymore, and it's best not to, it ruined my partition tables
The reason it ruined your partition table is because you told it to.
The first sector is conventionally referred to as the MBR; as we all know - the MBR is *NOT* just the executable code we like to refer to as the boot-loader.
That executable code must be contained within the first 446 bytes. The description for (up to) 4 partitions follows - that is your "partition table".

All contained within that 512 byte sector - which the above command zeroes out as requested.
 
2 members found this post helpful.
Old 03-12-2005, 08:55 PM   #9
tsphan
Member
 
Registered: Jan 2005
Location: Clackamas, Oregon, US
Distribution: Slackware 10.2
Posts: 154

Rep: Reputation: 30
Quote:
Originally posted by syg00
The reason it ruined your partition table is because you told it to.
The first sector is conventionally referred to as the MBR; as we all know - the MBR is *NOT* just the executable code we like to refer to as the boot-loader.
That executable code must be contained within the first 446 bytes. The description for (up to) 4 partitions follows - that is your "partition table".

All contained within that 512 byte sector - which the above command zeroes out as requested.
I found that out after I reformatted and some people told me that the MBR contained the partition tables . Believe me, I learned a valuable lesson about the MBR that day.
 
Old 03-12-2005, 09:05 PM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,430

Rep: Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055
Quote:
Originally posted by tsphan
Believe me, I learned a valuable lesson about the MBR that day.
Would (probably) work with say BS=440.
Should be o.k., but I've never tried it - must set up that test machine and give it a go one day.
 
Old 03-12-2005, 09:18 PM   #11
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
Quote:
you probably don't need the dd command anymore, but if the mbr does mess up for no reason,
NO NO NO!!!

This will wipe out partition table.

To use dd to clear the boot code from a standard DOS MBR, do it this way:

Code:
dd if=/dev/zero of=/dev/hda/ bs=446 count=1
This will wipe out the first 446 bytes, and stop just short of the beginning of the partition table.

Last edited by jiml8; 03-13-2005 at 10:39 PM.
 
2 members found this post helpful.
Old 03-13-2005, 12:34 AM   #12
Comatose51
Member
 
Registered: Jan 2003
Location: New Haven, CT
Distribution: RedHat 8.0
Posts: 54

Original Poster
Rep: Reputation: 15
Damn.

New respect for *nix. dd is just too cool... too powerful to contemplate, yet so simple. That's what I love about *nix. I can do whatever hell I want with my computer, as long as it works in concept. Linux is free as in freedom AND beer!
 
Old 03-13-2005, 09:46 PM   #13
tsphan
Member
 
Registered: Jan 2005
Location: Clackamas, Oregon, US
Distribution: Slackware 10.2
Posts: 154

Rep: Reputation: 30
bs=446 eh?

Maybe i should try that out again! Just joking, I'm afraid to even touch that dd command now.
 
Old 03-13-2005, 10:41 PM   #14
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
Quote:
bs=446 eh?
Yup. Partition table starts at the next byte.
 
Old 07-29-2007, 10:45 AM   #15
DeeVoc
LQ Newbie
 
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0
bump, this thread is probably ancient, but just helped me out.

Apparently grub does not like letting go of your mbr if/when you decide to go back to windows
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Fdisk /MBR Eugney Slackware 39 08-23-2011 10:30 AM
Grub - fdisk /MBR lucho707 Linux - Software 1 12-01-2005 12:07 AM
by tring to fix the MBR i damage the MBR that was help... AKAKAK Fedora 4 03-21-2005 09:18 AM
fdisk /mbr rharvey@cox Linux - Software 2 02-16-2004 01:19 PM
why won't my mbr fdisk /mbr? jamessp007 Mandriva 13 01-03-2004 02:41 AM


All times are GMT -5. The time now is 12:24 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration