Gerard Lopez’s side went behind after 14 minutes before two goals in three minutes, just before half-time, from Marc Cardona put them ahead in the tie.
Dani Romero then added a third after 65 minutes before Racing had a great chance to get back into it when they were awarded a penalty three minutes later.
However, goalkeeper Jose Suarez was the hero for Barca, diving to his left to push the kick away and preserve his side’s two-goal lead.
Romera then grabbed his second of the game, and Barca’s fourth, with 10 minutes to go, to ensure the visitors will be huge favourites to progress in the return leg on home soil.
However, a word of caution - Racing beat Villanovense 4-0 in the previous round – so Barca must be aware that while they are in a great position, it’s not over just yet.
Barcelona B line-up: Suárez; Palencia, Marlon, Martínez, Cucurella; Aleñá, Fali, Gumbau; Alfaro, Romera, Cardona. Subs: Varo, Borja, Ferran, Busquets, Kaptoum, Perea, Abel Ruiz