CHICAGO — After Gavin Floyd retired the first 14 Red Sox batters, he couldn’t help it. He was definitely thinking about the perfect game Phil Humber pitched last weekend.

“Absolutely. Especially since Phil did recently. It was natural, but obviously you have to put it behind you,” Floyd said. “Your object is to get in there and as late you can and if it happens it happens. You just have to keep your focus and keep attacking.”

Floyd took a no-hit bid into the seventh inning, Adam Dunn hit a two-run homer and the Chicago White Sox beat Boston 4-1 on Sunday.

Floyd (2-3) struck out nine in 6 2-3 innings, yielding one run and three hits. He improved to 7-0 with a 3.21 ERA in nine career appearances against Boston, helping the White Sox stop a five-game losing streak.

Story continues below advertisement.

Floyd started out well just eight days after Humber pitched the 21st perfect game in major league history. Cody Ross walked with two outs in the fifth for Boston’s first base runner, but Floyd struck out Nick Punto to end the inning.

Dustin Pedroia singled with one out in the seventh for Boston’s first hit of the game. Cody Ross had an RBI single for the Red Sox, who had won six straight.

“He wasn’t giving us much to hit,” Pedroia said. “I had three at-bats off him and only got one pitch to hit. I actually got a hit on that one. He kept the ball out of the middle of the zone.”

Dunn helped the White Sox get off to a fast start, belting a two-run shot to right in the first off Red Sox starter Josh Beckett for his first homer at U.S. Cellular Field since Aug. 4 against the Yankees. Dunn’s fifth homer of the season drove in Alex Rios, who put Chicago in front with an RBI single.

“Whenever you get a guy like him you have to score early because he is a workhorse, those guys only get better,” Dunn said. “Usually your best opportunity to get some runs if any are early and we were able to do that.”

Beckett (2-3) settled down after the rough opening inning, shutting down Chicago until he left with two out in the seventh. He struck out eight and allowed six hits while matching a career high with 126 pitches.

“That’s a pretty tough hole to put your team in, especially against a guy who has pitched well against us in the past,” Beckett said. “The two-run homer was the difference between that and the rest of the game. You can give up one in that situation if they want to manufacture a run in the first inning. You minimize the damage and give them the one run and move on.”

Boston finally got on the board in the seventh. Pedroia’s liner got past second baseman Eduardo Escobar’s diving attempt. He moved up on David Ortiz’s two-out double and scored on Ross’ hit.

Addison Reed then came in and got Punto to ground out, stranding Ortiz at third. Reed also got the first two outs of the eighth before Matt Thornton finished for his first save of the season. Thornton retired Pedroia, Adrian Gonzalez and Ortiz to finish the game in the ninth.

White Sox manager Robin Ventura decided to go with Thornton in the ninth as opposed to closer Hector Santiago.

“It is nothing against Hector, he still will be in there in the ninth, but you’re looking at guy with a body of work against those three guys,” Ventura said. “I felt confident leaving Matt in there.”

NOTES: White Sox 1B Paul Konerko missed the game with a stiff neck. He is day to day. … Red Sox slugger Kevin Youkilis was a late scratch due to tightness in his lower left back. … Dunn finished with five homers in April after hitting 11 all of last season. … The only time the Red Sox swept a road trip of seven or more games came in 1977 when they went 9-0 from July 29-Aug. 8, 1977. … Floyd had a near no-hitter against Minnesota on May 6, 2008. Joe Mauer broke up the bid with one out in the ninth. … Beckett last threw 126 pitches for the Marlins against the Houston Astros on May 20, 2004. … Dayan Viciedo added an RBI single in the eighth for Chicago.