Windows – Lost Windows Bootcamp boot entry after resizing the partition

bootbootcampdual-bootpartitionwindows

I have a 2011 iMac that I had used Bootcamp utility to install Windows 7 on. I got overzealous and tried to triple boot Windows, Mac and Linux on the iMac. I no longer need Linux on this iMac but the process corrupted my boot table and now I can't boot into Windows. If I press and hold 'alt/option' key after it reboots it doesn't show me the Windows bootcamp boot entry — just Mac and Recovery drive.

However, in the file system, I still see all the files for Windows intact. So the file structure is still there, just the boot table entry is messed up somehow. I tried to 'repair' it but Bootcamp utility no longer gives me the optin of making a bootable Windows thumb drive using the Windows ISO that I have. It just asks to download some support software for Windows and that's it.

If this was Linux, I'd use something like 'boot repair' ISO or 'update-grub' to update the boot table but how do I repair the boot entry in Mac?

I have the Windows ISO available and I'm comfortable with command-line.

UPDATE: Details about the system

users-iMac:~ user$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            598.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                400.8 GB   disk0s4

/dev/disk1 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *16.0 GB    disk1
   1:                 DOS_FAT_32 FAT32                   16.0 GB    disk1s1

/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:        CD_partition_scheme Audio CD               *410.5 MB   disk2

GPT:

users-iMac:~ user$ sudo gpt -r show /dev/disk0
Password:
gpt show: /dev/disk0: Suspicious MBR at sector 0
       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  1168862256      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1169271896     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1170541432   782721552      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  1953262984      262151         
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

Fdisk:

users-iMac:~ user$ 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 1023 254  63 - 1023 254  63 [         1 -     409639] <Unknown ID>
 2: AF 1023 254  63 - 1023 254  63 [    409640 - 1168862256] HFS+        
 3: AB 1023 254  63 - 1023 254  63 [1169271896 -    1269536] Darwin Boot 
 4: 0B 1023 254  63 - 1023 254  63 [1170541432 -  782721552] Win95 FAT-32

The optical drive on my system works. I was wondering if I could create a bootable thumb drive though. Bootcamp does not give me this option in the 2011 iMac but I was hoping to the edit the 'info.plist' in Bootcamp's contents folder to add my iMac model in there so that Bootcamp gives me the option of booting from thumb drive. This "patch" is described here: Bootcamp – No ISO Option

But is there any other simpler way to create a bootable thumb drive to install Windows on a Mac?

Best Answer

There are ways to create a bootable Windows installer thumb drive. The problem is you can not use this thumb drive with your computer. The software that searches the USB ports for bootable flash drives is part of the the firmware located on the main logic board. This firmware is not part of the OS X (macOS) operating system. Even though the firmware for the 2011 iMac can boot OS X (macOS) and certain Linux versions from a thumb drive, the Windows 7 installer can not be booted this way. The best option is to use original internal optical (DVD) drive. I would recommend a RW DVD which takes longer to burn, but is reusable.

If the Windows partition is intact, there are three main reasons you can not boot Windows. These reasons are listed below and apply to Mac computers which are booting Windows using the BIOS method.

  • The values in the partition tables are wrong. There are two partition tables. The first is the legacy Master Boot Record (MBR) table and the second is the newer GUID Partition Table (GPT). The bootable Windows partition must exist in both of these tables. The MBR table is stored at the beginning of the drive, followed by the GPT header and array of partition entries. There is also a backup copy of this GPT header and array at the end of the drive.
  • The MBR does not contain the correct code needed to boot Windows. The BIOS boot methods reads at least the first 512 bytes stored on the boot drive into memory and execute the code contained in this 512 bytes. These bytes are referred to as the MBR which also contains the MBR table. This code reads the MBR table and determines which partition to boot Window from. If this code is missing or incorrect, Windows will not boot.
  • Finally, the Windows Boot Configuration Data (BCD) is missing or contains the wrong data. If a change is made to your computer or if the Windows partition is moved regardless if within the same or to different computer, the BCD may need to be corrected or simply recreated. As far as I know, this can only be done (without using a third party tool) by booting from proper Windows installation media. In your case this would be a DVD containing the Windows installation software.

The output from the fdisk command shows the MBR table contains some incorrect values. This output should have appeared as shown below.

users-iMac:~ user$ 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 1023 254  63 - 1023 254  63 [         1 -     409639] <Unknown ID>
 2: AF 1023 254  63 - 1023 254  63 [    409640 - 1168862256] HFS+        
 3: AB 1023 254  63 - 1023 254  63 [1169271896 -    1269536] Darwin Boot 
*4: 07 1023 254  63 - 1023 254  63 [1170541432 -  782721552] HPFS/QNX/AUX

Basically, your forth partition (where Windows resides) has the wrong id (partition type) and is not flaged as active (bootable).

The MBR table can be corrected by using the fdisk command. This command is interactive. An example the the necessary command line entries is shown below.

users-iMac:~ user$ sudo fdisk -e /dev/disk0
Password:
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter 'help' for information
fdisk: 1> e 4
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 4: 0B 1023 254  63 - 1023 254  63 [1170541432 -  782721552] Win95 FAT-32
Partition id ('0' to disable)  [0 - FF]: [B] (? for help) 7
Do you wish to edit in CHS mode? [n] 
Partition offset [0 - 1953525168]: [1170541432] 
Partition size [1 - 782721552]: [782721552] 
fdisk:*1> f 4
Partition 4 marked active.
fdisk:*1> q
Writing current MBR to disk.
Device could not be accessed exclusively.
A reboot will be needed for changes to take effect. OK? [n] y
users-iMac:~ user$

NOTE: For you can just hit a return instead of entering values for the entries shown below. This will instruct fdisk to use the default values. This is what I did in the above example.

Do you wish to edit in CHS mode? [n] 
Partition offset [0 - 1953525168]: [1170541432] 
Partition size [1 - 782721552]: [782721552] 

If you have System Integrity Protect (SIP) enabled, you may have to temporarily disable SIP in order to execute the fdisk command.

If after correcting the MBR table your Mac will not boot Windows, we can try to determine if the other causes listed above may also be at fault.