Road cracks significantly affect the serviceability and safety of roadways, especially in mountainous terrain. Traditional inspection methods, such as manual detection, are excessively time-consuming, labor-intensive, and inefficient. Additionally, multi-function detection vehicles equipped with various sensors are expensive and not suitable for mountainous roads due to poor conditions. To address these challenges, this study proposes a customized Unmanned Aerial Vehicles (UAV) inspection system designed for automatic crack detection. The system focuses on enhancing autonomous capabilities in mountainous terrains by incorporating embedded algorithms for route planning, autonomous navigation, and automatic crack detection. The slide window method is proposed to enhance the autonomous navigation of UAV flights by generating path planning in mountainous roads. This method compensates for GPS/IMU positioning errors, particularly in GPS-denied or GPS-drift scenarios. Moreover, the YOLOv8 algorithm is introduced to conduct autonomous crack detection from UAV imagery in the offboard module. To validate our UAV inspection system's performance, we conducted several experiments to assess its accuracy, robustness, and efficiency. The experimental results demonstrate that our UAS inspection system accurately estimates the flight trajectory along the mountainous road for autonomous navigation. Furthermore, the experimental detection results also demonstrate that the YOLOv8 algorithm achieves higher recognition accuracy compared to the YOLOv5, and YOLOv7-tiny algorithms, exceeding 3.1%,and 6.8% of mAP, respectively. In summary, the UAV inspection system proposed in this study can provide a useful tool and technological guidance for the regular inspection of mountainous roads.