You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Bootcamp partition disappeared after OSX partition resize - how to repair?

Hi all,


So basically my problem is as follows. I have a MBP with bootcamp running Win8. I most often use Win8 so I wanted to shrink the OSX partition and increase the Bootcamp partition. I've done that before using disk utitlity without any problem, but this time it blew up in my face. I shrunk the OSX partition with the intention of going back to windows to allocate the new space to the Win8 partition, but I can no longer access it. In fact, I no longer see the bootcamp partition in my bootscreen. rEFIt didn't work, although it said it had restored a syncing error.


I looked through the helpful earlier posts by Christoph. This is what the two sudo commands he asked for show up:


gpt show: /dev/rdisk0: mediasize=251000193024; sectorsize=512; blocks=490234752

gpt show: /dev/rdisk0: Suspicious MBR at sector 0

gpt show: /dev/rdisk0: Pri GPT at sector 1

gpt show: /dev/rdisk0: Sec GPT at sector 490234751

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 98961512 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC

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

100640688 242835536

343476224 146757632 4 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7

490233856 863

490234719 32 Sec GPT table

490234751 1 Sec GPT header


and the second one:


Disk: /dev/disk0geometry: 30515/255/63 [490234752 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: AF 1023 254 63 - 1023 254 63 [ 409640 - 98961512] HFS+

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

*4: 0B 1023 254 63 - 1023 254 63 [ 343476224 - 146757632] Win95 FAT-32



I suppose that the partition is still out there somewhere, but I have no clue how to get it back and find it a bit risky to fool around with these things if i don't know exactly what I'm doing. I'm quite good with windowsbased machines, but OSX is all rather new for me.


Thanks so much for your help.

Joost

Posted on Jun 19, 2013 3:30 PM

Reply
Question marked as Top-ranking reply

Posted on Jun 19, 2013 3:43 PM

First off I don't know what you mean by you've done this with Disk Utility before, because that doesn't make sense. OS X doesn't come with tools to resize NTFS volumes at all. It can't even create them. While it lets you resize OS X volumes, when this creates a 5th partition this is arguably a bug that Disk Utility shouldn't allow because when a 5th partition is created, diskutil removes the hybrid MBR that's required to boot Windows, and replaces it with a protective MBR (a single entry MBR) which makes Windows effectively invisible to the EFI CSM (the BIOS emulator).


I don't know the sequence of events, but there's also some evidence that the start sector in the resulting partitions is made incorrect by something, I don't know what. But even when changing the partition type code to the correct one, the Windows volume still isn't available and Windows still won't boot implying that the partition entry for Windows is wrong. If I'm right, that's a separate bug but that's been much harder to reproduce and track down what's doing it.


So the short version is, you can try fdisk to change the partition type code in the MBR. Both your MBR and GPT have the same values for the Windows volume so there's no way to 2nd guess this.


sudo fdisk -e /dev/disk0 [puts you in interactive edit mode]

setpid 4

07

print [print the partition map, confirm partition 4 is 07 and has an asterisk]

write

y


Now reboot and see if Windows is visible and bootable. If not, you're in testdisk territory.

8 replies
Question marked as Top-ranking reply

Jun 19, 2013 3:43 PM in response to Disjoost

First off I don't know what you mean by you've done this with Disk Utility before, because that doesn't make sense. OS X doesn't come with tools to resize NTFS volumes at all. It can't even create them. While it lets you resize OS X volumes, when this creates a 5th partition this is arguably a bug that Disk Utility shouldn't allow because when a 5th partition is created, diskutil removes the hybrid MBR that's required to boot Windows, and replaces it with a protective MBR (a single entry MBR) which makes Windows effectively invisible to the EFI CSM (the BIOS emulator).


I don't know the sequence of events, but there's also some evidence that the start sector in the resulting partitions is made incorrect by something, I don't know what. But even when changing the partition type code to the correct one, the Windows volume still isn't available and Windows still won't boot implying that the partition entry for Windows is wrong. If I'm right, that's a separate bug but that's been much harder to reproduce and track down what's doing it.


So the short version is, you can try fdisk to change the partition type code in the MBR. Both your MBR and GPT have the same values for the Windows volume so there's no way to 2nd guess this.


sudo fdisk -e /dev/disk0 [puts you in interactive edit mode]

setpid 4

07

print [print the partition map, confirm partition 4 is 07 and has an asterisk]

write

y


Now reboot and see if Windows is visible and bootable. If not, you're in testdisk territory.

Jun 19, 2013 3:54 PM in response to Christopher Murphy

Thanks for your quick reply. With regard to the 'i've done this before' , I meant that I shrunk the OSX volume before and in Windows using partition magic allocated the freed up space to the Win partition. At least, that's how i remember it. If this still makes no sense, please disregard it as my memory may be faulty. 🙂


Anyways, I did the steps and rebooted and while I now saw Windows in the bootmenu (holding alt, rEFIt is stil active), I couldn't boot into it because it said Missing operating system.

Jun 19, 2013 6:13 PM in response to Disjoost

So the problem with shrinking in OS X with Lion and Mountain Lion is that in so doing, it creates a 5th partition which renders Windows unbootable. What you propose was possible with 10.6.x since it lacked a Recovery HD partition, therefore shrinking the OS X volume created a 4th partition, which caused the hybrid MBR to survive. Thus Windows was still bootable. The problem though, is that Windows only recognized the MBR, and upon resizing the Windows NTFS volume, it only updates the MBR, not the GPT. So while it works, it breaks the ability of OS X to read the Windows volume, and significantly risks a later utility trying to sync the GPT and MBR which usually means the GPT is used as the trusted source, overwriting the MBR. Since the GPT contains stale information, a sync not only breaks Windows, but its start sector is lost, which then puts you into data recovery territory.


So basically, Apple provides no tools to do this correctly, and neither does Microsoft. You have to use a 3rd party utility that's expressly designed for managing "Boot Camped" drives.


Reboot to OS X and see if it finds the Windows volume. OS X has read only NTFS support built in, so a volume named BOOTCAMP should appear (unless it was renamed to something else at some point). If it's not found, then the start value in the MBR and GPT is probably wrong and you'll need to use testdisk.


If OS X mounts it read only, then the NTFS volume is intact, it just needs its boot loaders fixed which can be done from Windows Startup Repair.

Jun 19, 2013 11:36 PM in response to Christopher Murphy

Uhm, that sounds bad. I'm now in OSX and i can't find the Windows volume.


I have testdisk installed. What do I have to do?




P.S. While it would be great to be able to repair the volume and have access to all the data on the Win partition, it's also ok if the only option left is to format the win partition losing the data. I have backups of most of the important stuff.

Jun 20, 2013 12:48 AM in response to Disjoost

I tried running testdisk, which reveals the following:


Disk /dev/disk0 - 251 GB / 233 GiB - 490234752 sectors (RO)

Current partition structure:

Partition Start End Size in sectors



1 P EFI System 40 409639 409600 [EFI System Partition]

2 P Mac HFS 409640 99371151 98961512 [Customer]

3 P Mac Boot 99371152 100640687 1269536 [Recovery HD]

No FAT, NTFS, ext2, JFS, Reiser, cramfs or XFS marker

4 P MS Data 343476224 490233855 146757632 [BOOTCAMP]

4 P MS Data 343476224 490233855 146757632 [BOOTCAMP]


According to the Testdisk FAQ, having two identical volumes shows that something is indeed wrong. When I did a further analysis with testdisk, i said that 2 partitions were not recoverable (including the bootcamp one). However, it does allow me to enter the file structure of the bootcamp partition, see all my folders and copy the files I need.


Disk /dev/disk0 - 251 GB / 233 GiB - 490234752 sectors (RO)



The harddisk (251 GB / 233 GiB) seems too small! (< 420 GB / 391 GiB)

Check the harddisk size: HD jumpers settings, BIOS detection...



The following partitions can't be recovered:

Partition Start End Size in sectors

> MS Data 490233855 821979127 331745273

Mac HFS 490234708 491504243 1269536


The following screen was the most interesting



Disk /dev/disk0 - 251 GB / 233 GiB - 490234752 sectors (RO)

Partition Start End Size in sectors

>P EFI System 40 409639 409600 [EFI]

P Mac HFS 409640 99371151 98961512

P Mac HFS 99371152 100640687 1269536

P Mac HFS 157218448 158487983 1269536

MS Data 158488576 490233848 331745273 [BOOTCAMP]

MS Data 158488583 490233855 331745273

Mac HFS 488965176 490234711 1269536


It appears that there are way too much partitions, only 4 of which are primary. I don't know why I have 4 partitions called Mac HFS (yesterday, i only had 1 OSX, 1 WIN and 1 recovery partition), but that may be a problem as I recall you saing that the total amount of partitons OSX can understand are 4. FYI, the size of the Mac HFS partitions are 50gig (which is fine) and 3 of 650mb.


Is there some way I can remedy this? And if not, is there some way I can keep my working OSX partition, bundle all remaining partitions together in one new partition which I can then format and reinstall windows to?


Thanks for your help!

Jun 20, 2013 9:41 AM in response to Disjoost

The partition map is supposed to definitively define the start and end sectors of a partition inside which a volume resides, and the superblocks for that volume are located in known offsets from the start and end points.


Testdisk works by essentially ignoring the partition map (because the only reason you'd use it is if you suspect the partition map is wrong) and looks for all superblocks for various file systems and then reports possible volumes. Old superblocks should be marked as invalid but they aren't erased when you resize a file system. So what's happening is, it's finding a combination of invalid, stale, and plausibly good file systems on the disk. It's not indicating a problem.


Anyway, if you have all of the data you want recovered, you're done with testdisk.


Next is how to use the two large partitions you have (one if free space, one is the old broken Windows volume) as a single new Windows volume. If you're happy with the size you've allocated between OS X and Windows, then you could give Disk Utility a shot. It should let you delete the stale Windows partition, and then create a single new MS-DOS volume from all remaining free space. Then you boot the Windows installer, make sure you go into the advanced section when choosing disks to install to, and reformat this volume (as NTFS), then install.


However, I find gdisk significantly more reliable and transparent about what's actually going on than Disk Utility. But it's a command line only utility, which may not be up your alley. It does offer an interactive mode though, so it's readily navigable. The main things to do: delete the Windows partition, create a new partition with default start and end sectors to use all free space, set the partition type code to 0700, and create a hybrid MBR adding partitions 2 3 4 to it. Then write this out to disk. Then run the Windows installer, making sure you reformat that 4th partition first, and installing to it.


The other thing worth mentioning is that I find Boot Camp to be a total PITA for all the problems you've just had with it, and many, many other users. So I suggest if you can, to use a virtual machine instead and just keep one large OS X partition only. Windows then exists in growable disk image file on the OS X volume. If you use Time Machine you'll want to exclude this file from regular backups, as if even one bit changes (which it will just by booting the VM) the whole disk image is considered changed and will be backed up again. One way around this is to use the virtual machine snapshotting feature. The large disk image gets backed up once because it never changes, only the snapshot file changes from that point onward, and is a much smaller file to backup every hour (or whatever).

May 15, 2014 10:28 AM in response to Disjoost

I just lost access to my Windows 7 Bootcamp partition after decreasing the size of my mac partition. I did successfully changed the partition sizes once a few weeks ago. I have studied some of the threads but this is over my head to try to fix myself and I would appreciate any help! Thanks!


MacBook-Pro:~ slvrmbpro$ sudo fdisk /dev/disk0
Password:
Disk: /dev/disk0 geometry: 91201/255/63 [1465149168 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: AF 1023 254 63 - 1023 254 63 [ 409640 - 1318359368] HFS+
3: AB 1023 254 63 - 1023 254 63 [1318769008 - 1269536] Darwin Boot
4: 0C 1023 254 63 - 1023 254 63 [1396791296 - 68356096] Win95 FAT32L


MacBook-Pro:~ slvrmbpro$ sudo gpt -r -vv show disk0
gpt show: disk0: mediasize=750156374016; sectorsize=512; blocks=1465149168
gpt show: disk0: Suspicious MBR at sector 0
gpt show: disk0: Pri GPT at sector 1
gpt show: disk0: Sec GPT at sector 1465149167
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 1318359368 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1318769008 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
1320038544 76752752
1396791296 68356096 4 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
1465147392 1743
1465149135 32 Sec GPT table
1465149167 1 Sec GPT header

Bootcamp partition disappeared after OSX partition resize - how to repair?

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