Apple - How do I know if I need a new hard drive?
I have the same model of Macbook which was showing the same issues. After replacing the Harddrive with an SSD I still had the same issue.
It ended up being the SATA cable connecting the hard drive to the logic board. Over some time the insulation had started to wear off and the cable was occasionally shorting against the base of the case causing IO errors. Once I replaced the cable these errors stopped happening.
A good way of checking this would be to use an external USB to SATA cable and try and boot the laptop from it externally. If the drive functions well when doing this then it is likely the SATA cable that is at fault.
I have the same MacBook Pro. I did the following:
I bought a SSD and replaced the hard drive disk. I installed OS X on the SSD. (240 GB - $100).
I inserted 8 GB of RAM (replace the two 2 GB RAM) ( 2 x 4 GB - $50).
Then I replaced the SuperDrive with .... the old HDD. You need to buy an adapter. (Adapter on Amazon - $30).
Yes it's expensive, but it takes 10 seconds to boot (password typing included).
Because new operating systems increase the access to HDD and the original HDD in the MacBook Pro, Mid 2012, is only 5400 RPM, it may be slow.
First, Some Diagnostics
While SSD's will give you a boost in speed simply replacing one with the hopes it solves a problem could get expensive. Let's verify that the problem is the drive in the first place and not something else.
If you can log into your system, open Terminal and issue the command
diskutil list
You will get a listing of all your drives on that particular machine. Find the one that corresponds to your boot drive. Chances are it will be /dev/disk0
but you will want to make sure.
Next, you will want to get the SMART status of the drive. Issue the command, substituting your drive label if different
diskutil info /dev/disk0 | grep -i smart
If you get anything other than "Verified," your drive is in the process of failing and it's time to replace it.
Next, download a drive utility App like DriveDX that will give you in depth diagnostics about your drive.
If everything passes there, it's time to look into Apple Hardware Test. It involves disconnecting everything but your mouse and keyboard, and while booting from a powered off state, hold down the D key. Choose to "Perform Extended Testing" If it provides you with an error, make note of it so you can provide it to us. Also, be sure to visit the link I provided for details.
How to Fix...
Chances are, it's going to be your HDD, but you want to do diagnostics first so you're not spending time and money trying replacing a drive when the problem is your logic board. According to Everymac.com, your MBP came with a 500GB SATA HDD
That spinning drive is now at least 4 years old and is close to EOL. If it turns out that your drive is failing, it's pretty easy to replace with an SSD. To see how to replace, take a look at this post that already details how to do this: My Mac is getting really slow, what should I do?
While You're There...
Everymac.com also lists your max memory as 16GB. You should consider upgrading your memory as well given how cheap memory prices are today. For your specific Mac, I found this Kingston 8GB Module (you will need two).
If it's Your Logic Board...
If you run Apple Hardware Test and you come to the conclusion that it's your logic board, you will have to start making some decisions whether you want to repair/replace your logic board ($300 to $700). Depending on exactly what is involved, it may make sense to just part out the MBP and purchase a new one.