Assuming you know what your doing and the PS3 is powered off and unplugged from mains follow theses instructions.
Download a partition recovery software like free EASEUS home edition to your PC or Laptop and use it to create a fat32 partition ,but if you have hard drives over 30gb then only create a primary partition of at least 20 or 30gb only in FAT32. Leave the remainder of the hardrive un partitioned and unformatted. Then place the hard drive back in and try safe mode. If you have lost the software(firmware) on your ps3 or its corrupted format a usb memory stick too fat32 and create a folder in upper case PS3 then inside this create a folder all upper case again named UPDATE download the latest update and place this inside the UPDATE folder and restore all in safe mode by taking the update option in safe mode..
You will need a usb sata drive caddyquite cheap on ebay etc so that you can work on hardrive with Pc or laptop.