Jump to content
Conti

How to fix a corrupt boot sector.

Recommended Posts

This is one of the most common issues myself and other chameleon developers have been running into lately.

 

Note: As of myHack 2.0 RC2 you should not need to do this unless your system fails to boot to chameleon, but I have seen a few users who's systems are too badly damaged for the attempted auto-repair method in myHack to repair on it's own so some users may still need this.

 

The issue is poorly written or hacked up stolen software from other sources - like "unofficial chameleon installers", "multifail", or even a bad tutorial on how to install chameleon manually results in corruption of the boot sector on usb sticks, external/internal hard drives, etc.

 

This will cause myHack and *correct* manual chameleon installation to fail or behave in an unpredictable manner. If you have used any of the methods I have just mentioned at any point in the past it is important that you do the following prior to attempting a new installation of myHack or a proper installation of chameleon manually.

 

Before continuing please understand one thing, even though the commands I have listed usually work as expected - whenever you are playing with boot sectors and partition tables there is a risk of something going wrong and data loss. If there is anything on the device you are about to run these commands on worth saving, ensure that you have made a backup to a separate device of that data prior to running any of these commands!

 

Before we begin let me explain how to get your device ID of the device you want to target... It seems to have caused some confusion when I initially posted this.

 

Suppose you want to fix the boot sector on a device that is mounted on /Volumes/my_stick

 

Open up a terminal and type "mount" without the quotes. Then look for the line that contains /Volumes/my_stick - for example:

 

/dev/disk5s1 on /Volumes/my_stick (hfs, local, nodev, nosuid)

 

The device id is "5" in this example, and the partition is "s1" (which stands for slice 1) so when running the following commands you will instead of typing /dev/disk5s1 type /dev/rdisk5 - so you are now targeting the raw device (this is what the r stands for) and the device id - but not the partition.

 

If you are going to repartition the entire disk and do not care about the partition table being destroyed do the following from a terminal:

 

WARNING THIS WILL DESTROY THE PARTITION TABLE AND ALL DATA ON THE TARGETED DEVICE!

 

sudo dd if=/dev/zero of=/dev/rdiskX bs=512 count=1

 

Replacing "X" with the device ID of the device you want to wipe.

 

After this use disk utility to create a new partition.

 

If you only want to flush out the boot sector without damaging the partition table (useful if this is not a USB stick but your internal drive and you would rather not lose your partition table) do the following from a terminal:

 

sudo dd if=/dev/zero of=/dev/rdiskX bs=446 count=1

 

Replacing "X" with the device ID of the device you want to clean the MBR of.

 

After this you can use myHack or manual methods to install chameleon to the device successfully.

 

If you get an error when trying to run either of these commands that says "Resource Busy" then ensure that you have closed all terminals/finder windows/apps/etc that may be accessing the drive in any way, and unmount (not eject) the device using disk utility prior to running the commands. If it fails to unmount there may be a process attempting to write to it in the background, you can either kill that process (a rather advanced task, if you don't know how to do it already then it is simpler to just reboot) or reboot and try again.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×