If the password is the firmware password (with a
blank box and padlock), then --- as you have a 2009 iMac, you are in some luck, as you can turn off that firmware password (reset it) without too much difficulty.
The firmware password will prevent booting to ANY other system, not just OS X systems. Linux boot CDs would be blocked, too.
(This will absolutely work to get your iMac to boot to another disk, assuming that the problem is a firmware password)
Turn your iMac off, unplug from power.
(Here's the important step that is your clue!) Open the RAM door, and remove ONE RAM stick (make sure you still have one stick installed)
https://www.ifixit.com/Guide/iMac+Intel+20-Inch+EMC+2266+RAM+Replacement/908
Plug power cord back in. Make sure your mouse and keyboard are ready.
Reset the PRAM: Press and release the power button, and immediately press and hold Option-Command-P & R
You will hear a boot chime sound. Continue to hold the same 4 keys until you hear the boot chime two more times, then release the keys to let your iMac boot up normally.
When it finishes booting, do a shut down, and reinstall that one RAM stick.
The firmware password is now reset.
And, that will then allow you to boot to the installer, so you can get that iMac erased, install Linux or whatever works for you.
This reset used to be on the edge of being unethical on this site, but your Mac is old enough already, and it is now unusual to offer these steps. The newer Macs (after mid 2011, I think (?)) will not reset without a trip to an Apple Store, and providing proof of ownership. Most times users are SOL if the password is lost.