To see if the (hidden) Recovery HD partition is still there, turn on the iMac, and hold down the Command and R keys at the same time. If that partition is there, you'll see the screen shown in the following link about the Recovery HD partition:
https://support.apple.com/en-us/HT201314
If it's not there, then you have a couple of options. The one I think could work would be to use your 2009 20" iMac to boot the newer iMac in "Target Disk Mode". This link talks about Target Disk Mode:
http://osxdaily.com/2010/04/07/how-to-boot-a-mac-in-target-disk-mode/
Your newer (ie, 2012) iMac has 2 Thunderbolt ports on it, while the older (ie, 2009) iMac has a Firewire 800 port on it. What you will need to do for connectivity is 1) purchase a Firewire 800 cable, and 2) purchase a Thunderbolt-to-Firewire 800 adapter (
https://www.amazon.com/Apple-Thunderbolt-to-Firewire-Adapter/dp/B00SQ2CJUS). I actually have one of those adapters, and I used it before to connect external drives with a Firewire 800 port to my mid 2013 13" MacBook Air, which has a Thunderbolt port. The procedure would then be as follows:
1. With both machines off, connect the Firewire 800 cable to the Firewire 800 port on your 2009 iMac.
2. Connect the other end of the Firewire 800 cable to the Thunderbolt-to-Firewire 800 adapter.
3. Connect the other end of the Thunderbolt-to-Firewire 800 adapter to one of the Thunderbolt ports on your 2012 iMac.
4. Boot the 2009 iMac.
5. After the 2009 iMac has completed booting, turn on the 2012 iMac, and hold down the T key.
What (hopefully) will happen is that the 212 iMac's hard drive will appear on the desktop of the 2009 iMac. You can then "operate" on that drive.
You will need to decide which newer Mac OS you want on that 2012 iMac. As Cory mentioned, you have a number of choices. However, for the 2009 iMac, you can download any Mac OS from OS 10.10.5, Yosemite, up to and including the latest version of Sierra, OS 10.12.5. If you download either Yosemite or El Capitan to the 2009 iMac, the resulting file will be named "Install OS X Yosemite" or "Install OS X El Capitan". If you download Sierra, the name of the file will be "Install macOS Sierra". In all cases, that resulting file will wind up inside the Applications folder. Make sure to make a copy of it right away, and in another location. You'll see why below.
Now, the 2012 iMac has a 1 TB (5400 rpm) internal drive. So, if I were you, I would launch Disk Utility on the 2009 iMac, and have it Erase, Format, and if you want, Partition that 1 TB drive. One (or maybe the only one) of the partitions will be needed for the OS installation.
Once Disk Utility completes, launch that OS installer file you downloaded, select that location on the 2012 iMac's drive, and perform the clean, fresh, "virgin" installation of the OS you choose. Once that process completes, that installer file gets deleted. That is why I stated above that you need to first make a copy of that installer file somewhere else.
Finally, your choice of what Mac OS you want will possibly depend on what third party software you use. If you want, you can post that information here, and we can help you with getting the correct version of such apps for the Mac OS you want.