Disk shows invalid code

After trying to resize my bootcamp partition, I am having problems with Bootcamp. I can boot into Bootcamp but it no longer shows in finder. This is what gdisk shows:


MBR

Disk size is 1875385008 sectors (894.3 GiB)

MBR disk identifier: 0xC77FC0B5

MBR partitions:

Number Boot Start Sector End Sector Status Code

1 1 409639 primary 0xEE

2 409640 1811615967 primary 0xAC

3 1811615968 1812885503 primary 0xAB

4 * 1812885504 1875384319 primary 0x07


GUID

Disk /dev/disk0: 1875385008 sectors, 894.3 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): 581992C7-3743-44D8-9945-2616020AAAE9

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 1875384974

Partitions will be aligned on 8-sector boundaries

Total free space is 62499477 sectors (29.8 GiB)

Number Start (sector) End (sector) Size Code Name

1 40 409639 200.0 MiB EF00 EFI System Partition

2 409640 1811615967 863.7 GiB AF05 iMac OSX

3 1811615968 1812885503 619.9 MiB AB00 Recovery HD

4 1812885504 1875384319 29.8 GiB FFFF BOOTCAMP


Note that the GUID code for partition 4 is FFFF. It should be 0700.


When I try to delete partition 4, I can't. The d command only lets me delete partitions 1 - 3. All other commands that operate on a partition show only partitions 1-3. I suppose this is because of the invalid code FFFF.


How do I change it?

iMac, OS X El Capitan (10.11.6)

Posted on Sep 5, 2016 7:47 PM

Reply
17 replies

Sep 5, 2016 7:56 PM in response to clarkfromtopeka

Do not further re-partition or modify the disk in any way, otherwise you will lose information. You have a corrupted GPT and possible a corrupted MBR.


Post the output of


sudo gpt -vv -r show /dev/disk0

sudo fdisk /dev/disk0

sudo dd if=/dev/rdisk0s4 count=1 2>/dev/null | hexdump -C


Bootcamp resizing is not supported by Apple. Please describe in a bit more detail the exact steps you used to try and resize the partitions.


Do you have backups of OS X and Windows and your original GPT and MBR?

Sep 5, 2016 8:37 PM in response to Loner T

Thanks for offering to help. Here is the info you requested:


clarks-imac:~ clark$ sudo gpt -vv -r show /dev/disk0

Password:

gpt show: /dev/disk0: mediasize=960197124096; sectorsize=512; blocks=1875385008

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 1875385007

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 1811206328 2 GPT part - 53746F72-6167-11AA-AA11-00306543ECAC

1811615968 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

1812885504 62498816 4 MBR part 7

1875384320 655

1875384975 32 Sec GPT table

1875385007 1 Sec GPT header

clarks-imac:~ clark$ sudo fdisk /dev/disk0

Disk: /dev/disk0 geometry: 116737/255/63 [1875385008 sectors]

Signature: 0xAA55

Starting Ending

#: id cyl hd sec - cyl hd sec [ start - size]

------------------------------------------------------------------------

1: EE 1023 254 63 - 1023 254 63 [ 1 - 409639] <Unknown ID>

2: AC 1023 254 63 - 1023 254 63 [ 409640 - 1811206328] <Unknown ID>

3: AB 1023 254 63 - 1023 254 63 [1811615968 - 1269536] Darwin Boot

*4: 07 1023 254 63 - 1023 254 63 [1812885504 - 62498816] HPFS/QNX/AUX

clarks-imac:~ clark$ sudo dd if=/dev/rdisk0s4 count=1 2>/dev/null | hexdump -C

[The dd command returned nothing. ]


It all started when I tried to increase the size of Bootcamp using DU. I expanded the Bootcamp partition by 50GB. At that point Bootcamp was no longer visible when I restarted the iMac. After that I've tried all kinds of things using gpt and gdisk. I eventually got Bootcamp to be bootable but I know I still have problems.


I have backups of OS X. I have the important Windows files backed up but I only use it for gaming so they are not important. It would be fine with me if you felt the best thing is to delete the Windows partition and start over. If so, I would like advise on now to best delete the partition.


I do not have backups of the MBR or GPT.


Thanks again for your help.

Sep 6, 2016 7:04 AM in response to Loner T

Here is the additional info you requested:

clarks-imac:~ clark$ diskutil list

/dev/disk0 (internal, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *960.2 GB disk0

1: EFI EFI 209.7 MB disk0s1

2: Apple_CoreStorage iMac OSX 927.3 GB disk0s2

3: Apple_Boot Recovery HD 650.0 MB disk0s3

/dev/disk1 (internal, virtual):

#: TYPE NAME SIZE IDENTIFIER

0: Apple_HFS iMac OSX +927.0 GB disk1

Logical Volume on disk0s2

1E336067-9D1F-420E-BEA8-8627B08D99D3

Unlocked Encrypted

clarks-imac:~ clark$ diskutil cs list

CoreStorage logical volume groups (1 found)

|

+-- Logical Volume Group A448A397-80E2-4372-940B-4E0DEC7846A3

=========================================================

Name: iMac OSX

Status: Online

Size: 927337639936 B (927.3 GB)

Free Space: 12546048 B (12.5 MB)

|

+-< Physical Volume 714A4831-3FB4-4AC1-8EA5-CACEED76C8CE

| ----------------------------------------------------

| Index: 0

| Disk: disk0s2

| Status: Online

| Size: 927337639936 B (927.3 GB)

|

+-> Logical Volume Family 5E055ADE-DC25-4330-8F12-0AB1B9BED049

----------------------------------------------------------

Encryption Type: AES-XTS

Encryption Status: Unlocked

Conversion Status: Complete

High Level Queries: Fully Secure

| Passphrase Required

| Accepts New Users

| Has Visible Users

| Has Volume Key

|

+-> Logical Volume 1E336067-9D1F-420E-BEA8-8627B08D99D3

---------------------------------------------------

Disk: disk1

Status: Online

Size (Total): 926968578048 B (927.0 GB)

Revertible: Yes (unlock and decryption required)

LV Name: iMac OSX

Volume Name: iMac OSX

Content Hint: Apple_HFS

==========================================================

I first tried this:

sudo fdisk -e /dev/disk0

p

setpid 4

07

flag 4

p

write

y


I was unable to write so I booted from an external drive. At that point I think those commands were successful.


Then I tried to synchronize them using gdisk after reading this: http://sidecar.twocanoes.com/forums/index.php?p=/discussion/770/bootcamp-partiti on-not-shown-in-startup-pane-after-maver…


Throughout all my misadventure, I was never able to change the results of fdisk and gpt. I printed out their contents when I started and they haven't changed.


Thinking back, I wonder if I was actually able to change the partition size. When I went into DU, I dragged the bootcamp partition from something like 30GB to around 80GB. DU worked on it for a while, but when it was done the size had not changed.


I am unsure now at what point I was able to boot from the Bootcamp drive. I'm sorry I am so vague. I worked on this for hours yesterday and I don't have good notes. My browser history shows the dozens and dozens of web sites I visited. ARGGG!


I never used Windows Disk Management.


Neither the gdisk 't' command nor the gdisk 'd' command work. They only allow me to change the first 3 partitions, not the 4th which is Bootcamp. See below:


Command (? for help): p

Disk /dev/disk0: 1875385008 sectors, 894.3 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): 581992C7-3743-44D8-9945-2616020AAAE9

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 1875384974

Partitions will be aligned on 8-sector boundaries

Total free space is 62499477 sectors (29.8 GiB)


Number Start (sector) End (sector) Size Code Name

1 40 409639 200.0 MiB EF00 EFI System Partition

2 409640 1811615967 863.7 GiB AF05 iMac OSX

3 1811615968 1812885503 619.9 MiB AB00 Recovery HD

4 1812885504 1875384319 29.8 GiB FFFF BOOTCAMP


Command (? for help): t

Partition number (1-3):

==============================================================


Do you think it would be best to just delete the bootcamp partition. I can have a new Win 7 loaded back in an hour. And I have a complete backup of my files there. If so, what would be the best way to do this? I should note that Bootcamp Assistant no longer knows there is a bootcamp partition, so deleting it with BA is not an option. The only way I know to delete it is using DU. Note, I just checked and it does not appear that DU is working either. It no longer shows the bootcamp drive either! ARGGGG.


I have a complete Time Machine backup. And I have backups of my critical data folders, but I am going to do a complete using Carbon Copy Cloner. I think I see a fresh install in my very near future.


Thanks again for all your help!


One other thing. Three months ago I replaced the HD in my early 2009 iMac with a SSD. Since then my computer locks up for 20 or 30 seconds when it is first booted or woken after sleep. You have any idea what causes this? If I am going to have to reinstall, I might as well try to fix this problem too.

Sep 6, 2016 7:26 AM in response to Loner T

clarks-imac:~ clark$ sudo gpt -vv -r show /dev/disk0

Password:

gpt show: /dev/disk0: mediasize=960197124096; sectorsize=512; blocks=1875385008

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 1875385007

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 1811206328 2 GPT part - 53746F72-6167-11AA-AA11-00306543ECAC

1811615968 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

1812885504 62498816 4 MBR part 7

1875384320 655

1875384975 32 Sec GPT table

1875385007 1 Sec GPT header


I just compared this with what I printed before I started. No changes found.


Here is the system report for SATA:


NVidia MCP79 AHCI:


Vendor: NVidia

Product: MCP79 AHCI

Link Speed: 3 Gigabit

Negotiated Link Speed: 1.5 Gigabit

Physical Interconnect: SATA

Description: AHCI Version 1.20 Supported


OWC Mercury Electra 3G SSD:


Capacity: 960.2 GB (960,197,124,096 bytes)

Model: OWC Mercury Electra 3G SSD

Revision: N1007C

Serial Number: OW1603041001A526E

Native Command Queuing: Yes

Queue Depth: 32

Removable Media: No

Detachable Drive: No

BSD Name: disk0

Medium Type: Solid State

TRIM Support: No

Partition Map Type: GPT (GUID Partition Table)

S.M.A.R.T. status: Verified

Volumes:

EFI:

Capacity: 209.7 MB (209,715,200 bytes)

BSD Name: disk0s1

Content: EFI

Volume UUID: 0E239BC6-F960-3107-89CF-1C97F78BB46B

disk0s2:

Capacity: 927.34 GB (927,337,639,936 bytes)

BSD Name: disk0s2

Content: Apple_CoreStorage

Recovery HD:

Capacity: 650 MB (650,002,432 bytes)

BSD Name: disk0s3

Content: Apple_Boot

Volume UUID: EE7AAD83-563F-311E-BBF6-7AA245E7206D

==================================================


With respect to deleting the bootcamp partition, since it no longer shows up in Bootcamp Assistant or DU, I don't know of any way to delete it. That's why I am preparing for a full reinstall.

Sep 6, 2016 8:09 AM in response to clarkfromtopeka

Let us first try to correct the GPT. We can create a new blank GPT and create partition table by hand. If you have El Capitan, please disable SIP using Local Recovery (Command+R) and csrutil disable, otherwise Gdisk write will fail.


The following steps create a new GPT and overwrite the current MBR. GPT Fdisk (Gdisk) uses single character commands. The text in parentheses is for explanation purposes.


sudo gdisk /dev/disk0

o (Create a blank GPT)

x (Experts Menu)

l (Character 'L' - set sector alignment)

1 (digit 1 - set alignment to 1 sector)

m (Main Menu)

n (New)

1 (Partition 1)

40 (Start)

409639 (End)

EF00 (EFI)

n (New)

2 (Partition 2)

409640 (Start)

+1811206328 ( Use '+' for size - End)

AF05 (CoreStorage - OSX Partition)

n (New)

3 (Partition 3)

1811615968 (Start)

+1269536 ( Use '+' for size - End)

AB00 (Recovery HD)

n (New)

4 (Partition 4)

1812885504 (Start)

+62498816 ( Use '+' for size - End)

0700 (Bootcamp)

p (Print)

w (Write)

y (Confirm write)

q (Quit Gdisk)


Reboot. Test for OSX boot. Check if the Windows partition is visible in Finder and you can see Windows files.


Once this is tested, we will re-create the MBR as the next step. Please check the values to ensure there are no values which are incorrect.

Sep 6, 2016 8:32 AM in response to Loner T

"Updated AF00 to AF05 to support CS"


What are the ramifications of this? Just googling a bit, I see CS was introduced in Lion. Am I not using it now? If not, why did it not get installed when I did fresh installs of all the new OSs since Lion. I always do fresh installs. I most recently did a fresh install when I installed the SSD.


Did you see anything in my SATA System Report that looked odd?


Thanks again for your ongoing help!!!


Clark

Sep 6, 2016 9:11 AM in response to clarkfromtopeka

clarkfromtopeka wrote:


Am I correct that if something goes wrong on the above procedure, it could make ALL partitions unbootable...it's not just messing with the Bootcamp partition. Right?

WE are not modifying any data on the disk, but just the partition table. If something goes wrong, we can use an external bootable OSX disk or Internet Recovery, as appropriate .

Sep 6, 2016 3:43 PM in response to Loner T

It worked pretty well. The computer still boots and I can see the Bootcamp partition in Finder. Also Bootcamp assistant know knows there is a bootcamp partition and I can use BA to delete it later if I need to.


There is one thing wrong. It boots VERY SLOW. It takes 45 seconds from the gong to until the login is shown. That used to be almost instantaneous. But there used to be a lockup sort of delay after I entered my login while the desktop was being loaded. That now seems to be gone. I suppose all this means there is something wrong with the SSD. I just noticed that the System Report now shows different info about the SSD:


NVidia MCP79 AHCI:



Vendor: NVidia

Product: MCP79 AHCI

Link Speed: 3 Gigabit

Negotiated Link Speed: 3 Gigabit

Physical Interconnect: SATA

Description: AHCI Version 1.20 Supported



OWC Mercury Electra 3G SSD:



Capacity: 960.2 GB (960,197,124,096 bytes)

Model: OWC Mercury Electra 3G SSD

Revision: N1007C

Serial Number: OW1603041001A526E

Native Command Queuing: Yes

Queue Depth: 32

Removable Media: No

Detachable Drive: No

BSD Name: disk0

Medium Type: Solid State

TRIM Support: No

Partition Map Type: GPT (GUID Partition Table)

S.M.A.R.T. status: Verified

Volumes:

EFI:

Capacity: 209.7 MB (209,715,200 bytes)

BSD Name: disk0s1

Content: EFI

Volume UUID: 0E239BC6-F960-3107-89CF-1C97F78BB46B

disk0s2:

Capacity: 927.34 GB (927,337,639,936 bytes)

BSD Name: disk0s2

Content: Apple_CoreStorage

Recovery HD:

Capacity: 650 MB (650,002,432 bytes)

BSD Name: disk0s3

Content: Apple_Boot

Volume UUID: EE7AAD83-563F-311E-BBF6-7AA245E7206D

BOOTCAMP:

Capacity: 32 GB (31,999,393,792 bytes)

Available: 604.3 MB (604,323,840 bytes)

Writable: No

File System: NTFS

BSD Name: disk0s4

Mount Point: /Volumes/BOOTCAMP

Content: Microsoft Basic Data

Volume UUID: 29C3738A-5FA6-40E7-AFF2-05003BF5423C


I notice the speed is now 3GB.


I have one more question....once you give me the final instructions and I setup the MBR, how will I increase the partition size for Bootcamp? Will I need to delete bootcamp using Bootcamp Assistant then recreate it larger, then reinstall Windows?


LonerT, again, I thank you for your help and patience. I see you spend a lot of time helping people. You must be a saint.

Sep 6, 2016 4:07 PM in response to clarkfromtopeka

clarkfromtopeka wrote:


It worked pretty well. The computer still boots and I can see the Bootcamp partition in Finder. Also Bootcamp assistant know knows there is a bootcamp partition and I can use BA to delete it later if I need to.

Excellent.


There is one thing wrong. It boots VERY SLOW. It takes 45 seconds from the gong to until the login is shown. That used to be almost instantaneous. But there used to be a lockup sort of delay after I entered my login while the desktop was being loaded. That now seems to be gone.

Can you run NVRAM and SMC Reset and test?


Reset the System Management Controller (SMC) on your Mac - Apple Support

How to Reset NVRAM on your Mac - Apple Support


I suppose all this means there is something wrong with the SSD. I just noticed that the System Report now shows different info about the SSD:


NVidia MCP79 AHCI:



Vendor: NVidia

Product: MCP79 AHCI

Link Speed: 3 Gigabit

Negotiated Link Speed: 3 Gigabit

Physical Interconnect: SATA

Description: AHCI Version 1.20 Supported



OWC Mercury Electra 3G SSD:



Capacity: 960.2 GB (960,197,124,096 bytes)

Model: OWC Mercury Electra 3G SSD

Revision: N1007C

Serial Number: OW1603041001A526E

Native Command Queuing: Yes

Queue Depth: 32

Removable Media: No

Detachable Drive: No

BSD Name: disk0

Medium Type: Solid State

TRIM Support: No

Partition Map Type: GPT (GUID Partition Table)

S.M.A.R.T. status: Verified

Volumes:

EFI:

Capacity: 209.7 MB (209,715,200 bytes)

BSD Name: disk0s1

Content: EFI

Volume UUID: 0E239BC6-F960-3107-89CF-1C97F78BB46B

disk0s2:

Capacity: 927.34 GB (927,337,639,936 bytes)

BSD Name: disk0s2

Content: Apple_CoreStorage

Recovery HD:

Capacity: 650 MB (650,002,432 bytes)

BSD Name: disk0s3

Content: Apple_Boot

Volume UUID: EE7AAD83-563F-311E-BBF6-7AA245E7206D

BOOTCAMP:

Capacity: 32 GB (31,999,393,792 bytes)

Available: 604.3 MB (604,323,840 bytes)

Writable: No

File System: NTFS

BSD Name: disk0s4

Mount Point: /Volumes/BOOTCAMP

Content: Microsoft Basic Data

Volume UUID: 29C3738A-5FA6-40E7-AFF2-05003BF5423C


I notice the speed is now 3GB.


The 3GB is correct. I was a bit surprised to see 1.5GB speed. The Sandforce controller can be fussy. You may want to check with OWC and some tuning. Some have tried to enable TRIM, but it may not be very beneficial.



I have one more question....once you give me the final instructions and I setup the MBR, how will I increase the partition size for Bootcamp? Will I need to delete bootcamp using Bootcamp Assistant then recreate it larger, then reinstall Windows?

The MBR can be setup using Gdisk. The Apple-supported method of resizing is to remove/re-install but third-party tools like Winclone or CampTune can do this without losing your installed Windows.


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. Please see thesample Q&A as an example. 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. Please see the sample Q&A before you execute these steps.

  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)
  9. N (part 3 boot flag)
  10. Y (part 4 boot flag make NTFS bootable partition)
  11. O (print current Hybrid MBR)
  12. W (Write the new MBR)
  13. Y (Yes! write the new MBR)
  14. Reboot


Here is sample Q&A for this section. Please notice the Press Enter/Return.


Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): Y


Creating entry for GPT partition #2 (MBR partition #2)

Enter an MBR hex code (default AF): Press Enter/Return

Set the bootable flag? (Y/N): N


Creating entry for GPT partition #3 (MBR partition #3)

Enter an MBR hex code (default AB): Press Enter/Return

Set the bootable flag? (Y/N): N


Creating entry for GPT partition #4 (MBR partition #4)

Enter an MBR hex code (default 07): Press Enter/Return

Set the bootable flag? (Y/N): Y


Test 1 - Does Bootcamp Volume show up in Finder?

Test 2 - Can you see files in Bootcamp Volume?

Test 3 - Can you select Bootcamp in System Preferences -> Startup Disk?

Test 4 - If Test 3 is successful, select Bootcamp and Click Restart.

Sep 6, 2016 8:57 PM in response to Loner T

Well, I have mostly good news. First of all, all the tests you listed passed. Also, the boot up process is much faster. The 45 second delay is gone. Also the drive appears to load the OS much faster than it did (even though I don't have any numbers to prove it.) One weird thing is when I checked the SATA configuration, it was back to showing a 1.5GHz negotiated speed. That's really weird since everything seems faster. I'll talk to OMC (the drive mfrg) about this.


The bad news is Windows does not boot. When I booted into Windows I get a big black screen that says Windows failed to start. A recent hardware or software change might be the cause. It says put in my install disk and reboot. When I did that the same message came back but nothing happened when I hit the Enter key which is supposed to cause the system to continue on.


Unless you have any better ideas, I'm going to use Bootcamp Assistant to remove the windows partition, recreate it only much bigger, and reinstall.


THANK YOU FOR YOUR HELP. You have spent a lot of time helping me and I don't know how to thank you. I don't know anything about you, but if you ever need a reference for a job in IT, drop me an email and I'll send a very good one.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Disk shows invalid code

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.