The reconfiguration planning methods for modular robots based on the exhaustion idea have factorial time complexity with respect to the number of modules, which are difficult to be applied to the cases containing large numbers of modules. To solve this problem, an efficient reconfiguration planning method is proposed, which has linear time complexity with respect to the number of modules. The reconfiguration planning problem is viewed as an optimal control problem. By solving the Hamilton-Jacobi-Bellman equation, the value function and optimal control law defined on the state space are obtained. The domain of attraction of the value function determines the optimal goal for the individual modules, and the optimal trajectories to the optimal goals at different states can be obtained by applying the optimal control law. Thus, the combination explosion caused by calculating the corresponding relations between modules of two configurations can be avoided, and the optimal trajectories of the individual modules that satisfy their kinematic constraints can be obtained at the same time. Simulation results validate the feasibility and efficiency of the proposed method.