The power supply system of diesel generators is isolated. Sudden loading and unloading will lead to fluctuation of the engine speed and exert an impact on the power supply quality. In order to improve the speed stability of diesel generators against the loading impact, this paper proposes a flywheel with variable moment of inertia, through the adjustment of which, the speed stability can be improved. Imbalance between the output torque and the load torque of the diesel engine can cause changes in the moment of inertia of variable inertia flywheel. The variable inertia flywheel forms the internal feedback loop of the speed control system, it takes the Angular acceleration of engine as the input signal and its output reduces the pulse impact of loading. SIMULINK simulation results under sudden loading and unloading condition have verified that, the variable inertia flywheel makes the diesel generator less sensitive to the loading impact. Meanwhile, variable inertia flywheel changes the maximum magnitude and bandwidth of closed-loop system, and endows the speed control system with a smoother response and better anti-disturbance ability.