If OSX is installed, restart the iMac while holding down Command S. When the text page appears,
Type: fsck -fy then press RETURN key (NB: there's a space between k and -).
You'll have to wait a little while the installed OS is scanned and repaired. When the repair is done you should read "The volume <<hard drive name >> appears to be OK" If you see "File system has been modified" retry the procedure (fsck -fy) until you see "The volume <<hard drive name >> appears to be OK" then type reboot and hit RETURN. The iMac should restart and boot a repaired system.