Boyd struck his second league goal of the season after just 75 seconds at Oakwell on Tuesday night and strike partner Barnett notched his first eight minutes later as Darren Ferguson's side followed up Saturday's surprise 3-1 win at Hull by inflicting on Barnsley their first home defeat of the season.
Barnsley striker Craig Davies, who fired four goals in the recent 5-0 win at Birmingham, hit the crossbar in the 35th minute, but Posh winger Tommy Rowe smashed a volley against the woodwork towards the end of a thrilling first half.
Peterborough found themselves adrift at the foot of the table after losing all of their first seven league games this season, and although they are still bottom, back-to-back wins have lifted them to within two points of fourth-bottom Sheffield Wednesday.
Posh, unchanged from the weekend, made a flying start when defender Shaun Brisley's header came back off the post and Boyd pounced to sidefoot home the rebound from six yards inside the second minute.
Barnsley responded with a shot from Scott Golbourne that flew over the crossbar, but had hardly had time to catch their breath when Boyd forced home goalkeeper Ben Alnwick into a fine save with an angled shot from inside the penalty area.
Posh stormed forward again soon after to increase their lead. Winger Rowe swung over a cross from the left and Barnett emphatically headed home his first goal of the season.
Barnsley defender John Stones tried to rally his side with a long-distance effort that flew over the crossbar and Posh goalkeeper Robert Olejnik saved comfortably from Chris Dagnall's header before Tykes striker Craig Davies rattled the visitors' crossbar with a venomous 25-yard shot.
Tykes skipper Stephen Dawson and Tomasz Cywka were both off target with shots from outside the area soon after, but Peterborough midfielder Nathaniel Knight-Percival headed Boyd's corner inches wide and as half-time beckoned Rowe's stinging volley smashed back off the crossbar.
Dagnall pulled a shot wide early in the second half and Posh goalkeeper Olejnik held on to another crisp shot from Cwyka before Barnsley manager Keith Hill sent on forward Marlon Harewood and midfielder David Perkins for Dagnall and defender Bobby Hassell respectively.
Posh manager Ferguson sent on teenage striker Saido Berahino, signed on loan from West Brom on Monday, for Emile Sinclair with 25 minutes remaining and Hill made his third substitution when swapping midfielder Jacob Mellis with Matty Done.
The second half was always going to struggle to live up to the first 45 minutes, with neither side creating nearly as many chances, and the visitors' intentions were clear when defender Mark Little was booked for time-wasting in the 75th minute.
Davies headed Barnsley defender Martin Cranie's cross straight at Olejnik in the closing stages, but Hill's side failed to muster a late rally and Peterborough held on for a deserved victory.