How to fix macOS High Sierra Boot Failure on iMac Apple 21.5-inch Computer? Few weeks ago, on an Apple 21.5” iMac Desktop Computer (4th-Generation, late 2013), I installed the just released macOS High Sierra v.10.13.1. I’ve recognized that on November 29, 2017, Apple Released a Security Update for macOS High Sierra and installed it on the iMac in the background (without consent). During the next weekend I’ve Shut Down the computer, then turned it off with the power button and unplug the power cord overnight. When I reconnected the power cord and turned on the iMac with the power button on the next morning, I could see the log-in screen, enter the password, and then a muddy picture with a unusually slow moving progress bar, which run (filled) completely, but the screen did not progress, as typically, to open a functional Desktop (picture) with the Dock. After waiting for about an hour, I’ve tried to Force Shutdown the computer by pressing and holding the power button, then restart the iMac with the power button, but only got the same muddy picture with the slowly moving progress bar, which, again, after running till the end, the computer did not progress to opening a functional Desktop with a Dock.  

I restarted several more times, unsuccessfully, then I contacted Apple Support and talked on the phone to few advisors (Case ID: 100370008105). In order to correct this situation, together, or I myself, did several times the following:  


Manual restart 
Start up in Safe Mode 
Reset the System Management Controller (SMC) 
Reset the Nonvolatile Random-Access Memory (NVRAM)
In Single-User Mode, a “senior” advisor from Apple Support wanted me to run the following commands (without further explanation):
mount -uw /
rm /var/db/.AppleSetupDone
reboot  


However, after the log-in screen asking for the password, we have always ended up at the following GRAY SCREEN: user account picture, user account name, and progress bar (initially “filling” fast until the middle, and then slowing down, “filled” completely, till the end, after about 20 minutes). But NO visible progress to open the Desktop with the Dock (when waiting for several hours).
GRAY SCREEN

Since I could not recognize whether the computer could communicate with the original wireless keyboard and mouse in Bluetooth, I’ve replaced them and connected an Apple wired keyboard and mouse to the iMac.  

Starting up from macOS Recovery, I’ve been able several times to  


“Install the latest macOS that was installed on your Mac, without upgrading to a later version” using Command (⌘)-R  
“Upgrade to the latest macOS that is compatible with your Mac,” macOS High Sierra v.10.13.2, using Option-Command-R  
“Install the macOS that came with your Mac, or the version closest to it that is still available” using Shift-Option-Command-R


Options 1 and 2 download and installation had always run (apparently) without problems, until I’ve ended up, again, at the same GRAY SCREEN. Option 3 could NOT be completed: “OS X Mavericks cannot be installed on “Macintosh HD” because a newer OS was installed.   

Current Startup Disk (is):
Macintosh HD
OS X, 10.13.2  

The iMac’s hardware (hard drive) appeared NOT damaged:  


Starting up in Single-User Mode by pressing Command-S as the iMac starts up and running a disk check [sbin/fsck -fy], showed “The volume Macintosh HD appears to be OK.”
Disk Check
The Apple Diagnostics and Apple Hardware Test showed “No issues found” 
Hardware Test
Running the Disk Utility displayed “Operation successful”  


The only issue I’ve able to identify was after a start up in Verbose Mode and using the key combination Command-V. It did display “indefinitely” the following message: “Process [x] crashed: opendirectoryd. Too many corpses being created.” After several hours it went from Process [187] to Process [1379], when I’ve lost patience and did a Force Shutdown.
First Aid on Macintosh

I appeal to all iGeeks to show their prowess and assist me in fixing the (software, macOS) issue on this iMac, so I can use it again before the Holidays, and thanks in advance for your consideration.
Verbose Mode
Have you tried using disk utility to delete all partitions and create a new one when installing? That might work, I bet there's an error on your disk, since it was probably was writing someting to it when you forced it to shut down, that's bad. It's ok to do that when reading data, not writing.

Alternatively, take the disk out (or tryt slave mode) and use paragon partition manager on some windows pc to check for errors. (paragon is not free)