Lost Windows Bootcamp boot entry after resizing the partition

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.