Hi, for long exposures, you need a sturdy tripod, a remote control and a lot of patience
Basically, for anything longer than 30 seconds, the camera automatically takes another picture of same length, but shutter closed, so it gets a black frame, but with the same noise pattern. Then it subtracts the noise from the first picture and you get a clean frame. This is called dark frame subtraction and can take a lot of time, so the K-5 also has the option of bypassing it (it's called slow shutter noise reduction in the menu, I believe), but at the cost of getting slightly noisier pictures. It's your choice