A system and method for aligning a compacting plunger of an agricultural square baler with respect to a gearbox for driving the compacting plunger. The method comprises controlling a position of plunger rails on and against which the compacting plunger will move when the agricultural square baler is in operation, with respect to a position of a carrying beam adapted for carrying the gearbox. Controlling the position of the plunger rails with respect to the carrying beam adapted for carrying the gearbox rather than with respect to the side walls of the baler provides the advantage of reduced wearing and/or fractures of parts of the baler.