Or by going to recovery mode.
One time my PS3 Slim's 250GB HDD wasn't working, I phoned PlayStation but they were useless as hell, so as it didn't format on PS3 itself I connected to a laptop and there it formatted, then connected back into the PS3 (format again and all working fine since then).
It was my fault primarily, I turned it off incorrectly.