In the hard X-ray region, to obtain the theoretical resolution or diffraction limited focusing size in an imaging optical system, both ultraprecise optics and highly accurate alignment are necessary. An adaptive optical system is used for the compensation of aberrations in various optical systems, such as optical microscopes and space telescopes. In situ wavefront control of hard X-rays is also effective for realizing ideal performance. The aim of this paper is to develop an adaptive optical system for sub-10nm hard X-ray focusing. The adaptive optical system performs the wavefront measurement using a phase retrieval algorithm and wavefront control using grazing incidence deformable mirrors. Several results of experiments using the developed system are reported.