Boot Camp partition broken and can't be repaired in OS X 10.10.4

Suddenly my Boot Camp partition vanished: not visible in Finder, not visible on startup. In Disk Utility I can see the volume, but it's broken (verification log):

Verifying volume "disk0s4"
Verifying file system.
** /dev/rdisk0s4
Invalid BS_jmpBoot in boot block: 2b0601
File system check exit code is 8.
Error: This disk needs to be repaired. Click Repair Disk.

…and cannot be repaired:

Verify and Repair volume “disk0s4”
Repairing file system.
** /dev/rdisk0s4
Invalid BS_jmpBoot in boot block: 2b0601
File system check exit code is 8.
Updating boot support partitions for the volume as required.
Error: Disk Utility can’t repair this disk. 
Back up as many of your files as possible, reformat the disk, 
and restore your backed-up files.

Before there was another message, something about

Mount of disk0s4 blocked by dissenter.

Terminal's diskutil list command:

#:                       TYPE NAME                    SIZE       IDENTIFIER
0:      GUID_partition_scheme                        *1.0 TB     disk0
1:                        EFI EFI                     209.7 MB   disk0s1
2:                  Apple_HFS Macintosh HD            596.5 GB   disk0s2
3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
4:       Microsoft Basic Data                         199.3 GB   disk0s4

and another one:

sudo gpt -vv -r show /dev/disk0

gpt show: /dev/disk0: mediasize=1000204886016; sectorsize=512; blocks=1953525168
gpt show: /dev/disk0: Suspicious MBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: Sec GPT at sector 1953525167
     start        size  index  contents
         0           1         MBR
         1           1         Pri GPT header
         2          32         Pri GPT table
        34           6        
        40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
    409640  1165055256      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1165464896     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
1166734432   397446048        
1564180480   389343232      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
1953523712        1423        
1953525135          32         Sec GPT table
1953525167           1         Sec GPT header

Once, I had as similar problem after partition resizing and had successfully solved it with this guide. But here I see some differences - now naming is not detected and you can't see BOOTCAMP in Finder sidebar. So, I'm not taking chances and won't follow this guide until someone will advise me so.

iMac14,3 (21.5-inch, Late 2013) , OS X Yosemite (10.10.4)

Here is sudo fdisk /dev/disk0

Disk: /dev/disk0    geometry: 121601/255/63 [1953525168 sectors]
Signature: 0xAA55
     Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE    0   0   2 - 1023 254  63 [         1 - 1564180479] <Unknown ID>
*2: 07 1023 254  63 - 1023 254  63 [1564180480 -  389343232] HPFS/QNX/AUX
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused     

Solution 1:

To recover the Boot Camp partition (Source):

Enter:

sudo gpt -vv -r show /dev/disk0

to get some partition informations.

Download and install GPT Fdisk (aka gdisk).

Download and install TestDisk.

Open TestDisk and make a deep search for your Windows partition.

Leave your Testdisk display and start a new Terminal Window. You need to use the following steps. If you see any error messages during the following steps, please stop and post back here with the error message. The following steps have values from your Testdisk output (and you can verify) in Steps 7 and 8. They should be the same as in the gpt output. Please notice the '+' sign in step 8 (this is called offset notation). The text in parentheses is for informational purpose to describe the action being taken. Gdisk has one-character commands except when entering numbers.

Rebuild GPT4 using start/end offsets

  1. sudo gdisk /dev/rdisk0
  2. P (print the full list of parts)
  3. D (delete)
  4. 4 (part 4)
  5. N (new part)
  6. 4 (part 4)
  7. 1564180480 ( - Start offset in blocks or the start point for Bootcamp part)
  8. +389343232 ( - Size offset, as opposed to End offset)
  9. 0700 (Windows part type)
  10. P (print list of all parts just to see what changes will be made)
  11. W (Write the new GPT)
  12. Y (Yes! really write the new GPT)

This will delete and re-write the GPT partition info for /dev/disk0s4.

Rebuild MBR to match the new GPT information thus resetting the Hybrid MBR. Use defaults for other questions (like partition codes). The only values that need modifications are the Boot flags and step 10. Accept all other defaults that Gdisk offers. These steps can be repeated if you make a mistake before you get to Step 12, otherwise start from Step 1 for these steps. Step 6 has numbers which are typed with a space between the numbers.

  1. sudo gdisk /dev/rdisk0
  2. P (Print list of parts)
  3. R (Recover)
  4. O (print current Hybrid MBR)
  5. H (chooses Hybrid)
  6. Partitions numbers to be hybridized: 2 3 4
  7. Y (Good for GRUB question)
  8. N (part 2 boot flag) N (part 3 boot flag)
  9. Y (part 4 boot flag make NTFS bootable partition)
  10. O (print current Hybrid MBR)
  11. W (Write the new MBR)
  12. Y (Yes! write the new MBR)
  13. Reboot

To make Windows bootable again try the following:

Boot from your Windows DVD/USB-Stick

  1. Open command prompt from Windows recovery option menu. Type “diskpart” at the command prompt.

  2. At the DiskPart prompt, type in “list disk”. You will see the list of disk currently attached to your computer.

  3. Now type in “select disk n”, where n is the disk number. In this example, disk 0 is selected.

  4. Now that correct disk is selected, type in “list partition” to get a list of all the partitions on that disk.

  5. To select the partition you want to set as active, type in “select partition n”, where n is the partition number (probably 3).

  6. Now that you have selected the disk and partition, mark it as active by just typing the word “active” and pressing Enter. Now the partition is set active.

  7. Exit from the command prompt and run startup repair.