Bit of background - the whole problem began with the mac being really slow and unresponsive. I thought it might be a good idea to wipe everything clean, and reinstall a fresh copy of High Sierra. So, restarted and went into Recovery mode, and then disk utility. I could not erase my internal Macintosh HD - the error said it could not unmount it. Same error when trying First Aid too.
From here, it went really dark. Tried internet recovery but it gave an error -2002F. As I didn't have another mac at the time, read an article somewhere to download a High Sierra image from a link (not apple store) and using TransMac to create a bootable - which was a mistake, because I was able to install that OS but it started throwing random errors and was unresponsive as well. From this point onwards, Mac started to get stuck at the apple logo with progress bar at 100% and I waited 24 hours, and it still did nothing. An SMC Reset fixed that issue, and it logged me into my OS which is again the corrupted one.
So, now tried internet recovery from another Wifi, which took me further only to throw an error before install began saying Permission Denied. I also managed to find another mac and download a genuine High Sierra and make a bootable out of it, but when I went to install it, same error - Permission Denied.
Many more hours of research, and I found out by typing the command (lsof|grep 'Volumes/Macintosh HD') that there were two processes running - 169 and 197 (see image below) . Killed them both.
And then was able to force unmount the disk via terminal (diskutil unmountDisk force /dev/disk0). However when I went to erase by trying the command (diskutil eraseDisk JHFS+ Mac /dev/disk0), it threw the error - 69825: Wiping volume data to prevent future accidental probing failed. (image below).
After which I ran the following command (gpt -v destrory /dev/disk0) with the intention it might clear off the partitioning, I guess I was wrong because now I do not have a Macintosh HD in Disk Utility, and the internal Disk says 'Uninitialized' (image below)
So yeah, that's where I am after 5 days of troubleshooting - pretty much nowhere! I am not a mac genius, but I know things. But this is getting too complicated now. The other weird thing I found is when I type the command (diskutil list), I get this long list going upto /dev/disk21 and all of them are disk images. (see below). Not sure if that has anything to do with it.
So assuming the next step would be to initialize the disk, ran the following commands.
diskutil eraseDisk JHFS+ Mac disk0 diskutil partitiondisk disk0 JHFS+ Mac 100%
gives me the same error (image below)
So, not really sure where to go from here. I think my brain's reached the saturation level unless someone can point out something that I haven't tried that might help. Any suggestions are welcome.
Lastly, this could very well be a hardware fault which I might have caused due to my troubleshooting step - I'd never know i guess. But this is an old machine, and I'm willing to get my hands dirty here to find a way out.
Thanks for your time.