Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Alright here's how I got to this point.

I tried to partition my external drive so that I could install multiple OS's on it, 3 linux distros, 1 being ubuntu, and a partition for windows.

So I used Gparted and the drives came out fine according to it, but when I booted into windows to check from their it showed most of them as raw, so thinking something went wrong I decided to boot into Gparted again and just create a new partition table and start making new partitions again. Now after I created the new partition table all things just started going to hell and I finally realized I somehow screwed up the MBR.

Now the drive isn't recognized by Gparted half the time and it is unable to do anything to it.

So one person recommended I use MBR Repair to repair the MBR so I said sure, downloaded it and booted into it, and it recognized all my drives but the one with the corrupt mbr.

I've read you can manually repair the MBR and there are a few other tools that may be slightly better than MBR Repair but I figured I'd come here for a sound opinion.

I also read something about somebody using the same make drive to copy it's mbr and just replace the corrupted drives mbr, which makes me wonder, since I have ; Seagate 500 Gig Goflex (Corrupted MBR), Seagate 500 Gig desktop FreeAgent (Fine) and a Seagate 250 Gig Portable Expansion drive (Fine).

share|improve this question
    
Was that last paragraph a question? I can't know for sure that it's ok to use the MBR from one drive on another, The vendor could tell you if there's anything special needed for their equipment. If you want to try it you could use the unix dd command to copy the first sector of the source drive to the first sector of the drive where you want to put the copy. –  John S Gruber May 20 '12 at 20:19
add comment

3 Answers

I don't think anything was wrong with your MBR or your drive when the newly created partitions showed up as raw. I'm afraid I don't know why it sometimes can't be selected by the drop down menu in gparted. Some background may help you understand what should be happening, however.

First: the MBR. For an external drive the MBR is only a container for the primary partition table. That table takes up most of the last 64 bytes of the MBR, which is itself the first 512 bytes of data on the drive.

For a bootable drive the MBR contains code to load the beginning of grub, or to load the beginning of the first bootable partition (e.g. Windows or DOS). The latter is usually pretty interchangeable and you can use the Windows utilities to replace a vanilla one for that matter. If the drive needs something special there, however, it could use a special manufacturer provided MBR. For recent drives that's probably pretty unusual.

When you used gparted you specified a type for each partition. You should make sure that those are correct.

The partitions are raw until you create file systems on them. They can be Ext 3, for Unix, or NTFS or a version of FAT for Windows. For Ubuntu this is usually done by the Ubuntu installer. gparted wrote a new primary partition table at the end of the external disks MBR, and maybe wrote some other partition information elsewhere if you defined any external partitions. The Ubuntu installer will fill the partitions you tell it to with the file systems you tell it to create, wiping out any data there. Then they will no longer be raw (though the swap one will be).

When installing Ubuntu the system will also want to install GRUB2 to produce a boot window to select what system to boot. By default this goes on the primary disk (the one the system boots from). This changes the code in the first part of the MBR on that drive and installs Grub2 on some (usually) free space between the MBR and the end of the first track. (The MBR is the first sector of the first track of a drive).

Grub could also be installed on the MBR on secondary disk if you can tell your BIOS to boot from there.

It can also be installed into partitions on the secondary disk. If you do that you need to be sure the code in the MBR is good, the one installed by Windows would work fine. The partition with Grub installed would have to be marked as the bootable one.

When you are booting Windows, Grub finds the partition it is on and then loads the first sector of its partition, just like the original MBR did. When booting a Linux kernel Grub actually loads the whole kernel and starts it up.

Since the primary partition table takes up most of the last 64 of the last 66 bytes of the MBR you can't simply use a sector copy to replace it without wiping out your partition table. If you've done that, however, you should be able to use gparted to recreate it. gparted shouldn't wipe out the code part of the MBR in any case.

share|improve this answer
    
Ok here's the thing I just want to get the drive usable again. I don't mind wiping out the partition table I know that can be replaced. So if I was somehow able to copy and replace the corrupt MBR with the one from the other drive I could at least make it usable again correct? Remember the drive isn't even recognized on MBR repair and only half the time on gparted so I'm not even sure how I would go about doing that, I will test out other software to see if I can with it. Any more advice would be very helpful. –  William May 19 '12 at 20:49
    
When you are able to access the drive with gparted what does it list as the device name (e.g. /dev/sdb)? –  John S Gruber May 20 '12 at 5:21
    
I'm not convinced that there is a problem with your MBR. gparted shouldn't care about the MBR except to write to part of it. The first (MBR) sector is there for it to write into no matter what that sector contains. If you can give me the name from the device I may be able to give you a command to enter so we can take a look at your MBR. By the way, what message do you get with gparted when you try to change the partition table? –  John S Gruber May 20 '12 at 5:26
    
Please read what I said again. –  William May 20 '12 at 17:32
    
I read it several times. I just reread it. I've looked at MBR's and unassembled MBRs many times over almost 20 years. It doesn't bother me that some MBR recovery program doesn't see your external drive since I don't know anything about the recovery program. It did and does bother me to hear that gparted sees the drive some of the time and doesn't some of the time. By definition the MBR is the first sector of the drive, it may be mis-formatted but it always exists. You asked for some sound opinions and you have my opinion, sound or not. –  John S Gruber May 20 '12 at 17:52
show 3 more comments

Copying an MBR from One Drive to Another

This will wipe out the partition information, and therfore all of the information, on the target drive. If, by chance, the whole target drive contains a file system (the target drive is unpartitioned but formatted) it will wipe out that file system. Don't do this if you have any doubts and even then be sure you specify the drive names correctly.

If you want to try to copy an MBR from one drive to another, say from /dev/hda to /dev/sga here's one way:

  1. Make sure the drive itself, and any partitions on it, are unmounted. You can use the file folder right below the Window Dash button to see what is mounted and unmount anything that is mounted. It's in the sidebar under Devices on the top left. Click on the little eject button to unmount. If anything is mounted on the target drive I wouldn't expect to be able to write to the MBR using the method below, with an MBR recovery tool, or with gparted. This might be a good time to see if gparted can access the drive reliably.
  2. Open a terminal window. Enter the mount command without arguments to display everything mounted to be doubly sure nothing is mounted on the target drive.
  3. Enter a command similar to sudo dd if=/dev/sda of=/dev/sga bs=512 count=1, substituting /dev/sda with the source drive and /dev/sga with the target drive. This should copy the first sector of of the first drive to the first sector of the second. if= specifies the source and of= specifies the output.
share|improve this answer
add comment

The MBR is not the problem since you created a fresh one with gparted already, and even if it were wrong, would not make the whole drive not show up. Either there is a problem with the drive itself or the connection to it. Open the disk utility and run the SMART diagnostics on the drive.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.