Barca interim coach Jordi Roura, standing in for Tito Vilanova, who is recovering after throat surgery, also rested Andres Iniesta and Cesc Fabregas, the latter only coming on for Xavi late in the game.
Real struggled to break through a determined Getafe defense in the first half, but once Ramos had scrambled the ball into the net from a corner eight minutes after the break the home side turned the screw.
Ronaldo struck three times in 10 minutes, the first his 300th club goal.
The Portuguese, who was substituted with 15 minutes left after a knock to his right ankle, scored five for Portugal’s Sporting, 118 for Manchester United and now has 179 for Real thanks to his 20th career hat-trick.
Real centerback Ricardo Carvalho appeared to impede Getafe goalkeeper Miguel Angel Moya with his arm in the lead-up to the opening goal.
“It was a very quick passage of play for the Ramos goal and I don’t know if it was a foul or not,” Portuguese Carvalho said. “The important thing was to win in that way, so we can be stronger for the Copa and the Champions League.”
Getafe, who beat Real 2-1 at their Coliseum Alfonso Perez earlier in the season, but whose form has dipped in recent weeks, are 11th on 26 points, one ahead of Bilbao.