iMac won’t boot up from internal drive but can boot from external drive, but internal drive can boot other Macs I am seeking suggestions on what may be going in with an iMac I am currently troubleshooting, as it’s displaying behaviour I do not recall seeing before.

Short story

This iMac refuses to boot up. It gets the Apple logo, gets past the progress bar, and then gets stuck on the grey screen for about two minutes before rebooting itself. However, what makes this odd is that I can:


Start the iMac in Target Disk Mode and use it to successfully boot up other Macs. In doing so everything seems to work perfectly fine.
Successfully boot the iMac from an external drive and everything seems to work perfectly fine.


Long story

I was presented this iMac about 2 weeks ago as it refused to bootup. That is, it would commence booting up and cycle through the Apple logo and progress bar, but after the progress bar completed it would remain on the grey screen for a couple of minutes before rebooting itself and doing the same thing all over again. 

To address this I undertook the following troubleshooting steps:


Resetting SMC - failed
Resetting NVRAM - failed
Starting up in Safe Mode - failed
Starting up in OS X Recovery Mode – failed
Starting up in OS X Recovery Mode via the internet – failed
Undertook an extensive hardware test using Apple Hardware Test (AHT 3A213) - passed
Started iMac in Target Disk Mode and retested hard drive using Scannerz on another iMac - passed
Started iMac in Target Disk Mode and reformatted the hard drive and did a clean install of Mac OS X El Capitan 10.11.6 - successful
Migrated data from a Time Machine backup - successful


After these steps I tested the iMac for four days with no issues in terms of booting up and using the computer. On the fifth day I needed to manually import seven Apple Mail mailboxes. I did these one by one and six of them imported within minutes.

The last mailbox was showing as being 270 GB in size. I knew this was inaccurate, but I decided to import the mailbox so I could do a mailbox rebuild to correct whatever corruption had taken place. This import took over 12hrs to do but seemed to work fine and Mail was displaying the emails.

I then tested the iMac on and off for another day to ensure it had no problems booting up. This was successful.

I then decided to initiate the mailbox rebuild, but as soon as I did the screen went black and stayed that way regardless of any keyboard shortcuts I tried using. I waited an hour, forced a reboot, and ever since the iMac has returned to its original behaviour of not booting up – it would get past the progress bar and stay on the grey screen for a while before rebooting itself and starting the whole vicious cycle again.

I have again retested the hard drive, processor, RAM and Video Ram by starting the iMac from an external hard drive and using a combination of the following packages:


Apple Hardware Test (AHT 3A213)
Scannerz
TechTool Pro
Memtester (under the Homebrew subsystem)


And now I have a situation where I can boot the iMac from external hard drives, and also use it in target disk mode to boot up other Macs, but cannot use it to boot from its own internal drive.

At present I have isolated the internal hard drive and am running a scan to check for any malware. 

In the meantime, I am wondering:


Has anyone come across a similar scenario and, if so, what was the cause?
Assuming I find no malware, do I go through the reformat/clean install/migration process again, but this time not import the last
mailbox and see whether the iMac works fine?
Any other suggestions?


iMac specs are as follows:


iMac (27”, mid 2011)
3.1 GHz Intel Core i5
8 GB RAM
AMD Radeon HD 6970M 1024 MB
1 TB 3.5” SATA HD
Mac OS X El Capitan 10.11.6
I'm answering my own question in the unlikely event it helps someone else, although I suspect this odd behaviour could result from a number of possible hardware issues or a sensor error.

I started to suspect something wasn't quite right with the display so I connected the iMac to an external display and for the first time in about five days the computer booted up from the internal hard drive. Oddly enough both the internal screen and external screen worked fine while using the computer.

I then disconnected the external screen and the problem returned - the iMac would not boot from the internal drive. Reconnecting the external screen results in everything working fine. I went through this disconnect/reconnect process five times and the results were repeatable.

While connected to the external screen I was able to import and rebuild the corrupt mailbox with the end result being a 258 Gb reduction in the mailbox size!

As far as I can tell, both the LCD panel and the internal DisplayPort cable are fine, so I'm recommending to my friend that she run it connected to an external display for a while to determine if any other problems present themselves. While I could inspect and reseat internal DisplayPort cable, this is not something I intend to do unless she reports back that the internal display stops working.

I will update this answer if/when I have anything else useful to share.

[Update]

Eventually the iMac stopped booting altogether - only getting part of the way before restarting itself in an endless loop. Also the display would show vertical lines etc, so the owner bought another 27" model and gave me this to use for parts.

After having it in my office for a few months and not needing any of the parts, I decided to disassemble it to see if I could find any obvious fault. Nothing stood out at me so I decided that since I had gone to all this trouble, I may as well remove the GPU (an AMD Radeon HD 6970M 1024 MB) and bake it in the oven to try and re-flow the solder and heat the Bumps under the surface-mount chip. (Basically I had decided a while back that the GPU was the most likely culprit).

After doing this and reassembling everything the iMac booted up normally. It was the first time this year it had booted successfully! I've since rebooted it 30+ times, run Apple Hardware Test, and so on. Not sure how long this will last (the baking a GPU in the oven trick is often described as a temporary fix, but Ive heard of GPUs still working normally six months later.

For anyone who is interested, below is a brief summary of what I did:


Disassemble the iMac enough to remove the GPU
Set oven to 205℃ (400℉)
Place a sheet of baking paper on an oven tray and place the GPU (only the GPU itself) on the oven tray
Place it in the oven for 8 minutes
Remove the tray and let it cool
Remove any old heatsink compound from the chips and replace with new compound
Reassemble everything 


This process took me approximately 4.5hrs (including various interruptions along the way).

Obviously the steps above do not go into detail, so anyone reading this who feels confident enough to give it a go can post a comment below or in chat and I'd be happy to walk them through the process in greater detail. 

Remember though, I've disassembled countless computers over the years, so if you haven't and still want to give this a go, please be patient and allow more time. Also, you will require some tools that you most likely won't have (but can easily purchase online).