Doncaster had reached half-time level and even had the better of the chances in the opening period.
They should have taken the lead after 26 minutes but after good play from Ben Jackson and Tommy Roe, Joe Dodoo somehow failed to find the back of the net.
And Portsmouth dominated the second half, with Hackett heading the hosts in front from a Marcus Harness cross 11 minutes after the break.
Hirst made it 2-0 in the 63rd minute with a neat finish from inside the penalty area.
O’Brien, who joined the club on deadline day, came on with 10 minutes left and a minute later was celebrating a goal after sweeping in Ronan Curtis’ cross.
Raggett sealed the rout with a stoppage-time header.