We present direct numerical simulations of a supersonic, zero-pressure-gradient, adiabatic turbulent boundary layer at a free-stream Mach number of
$M_\infty =2$, over cubical roughness elements. The simulations are complemented by a subsonic rough-wall boundary layer over the same geometry, alongside reference smooth-wall data, allowing us to elucidate compressibility effects. The simulations feature turbulent flow transitioning from a smooth to a rough surface with an extended computational domain to facilitate recovery. At the smooth-to-rough transition, we compare the development of an internal boundary layer between the subsonic and supersonic cases, introducing a novel definition of its height that is less sensitive to local compressibility effects. We demonstrate that, although the internal boundary-layer growth is similar to the subsonic case, a delayed equilibrium is expected for the supersonic case due to the sudden growth of the external boundary-layer thickness at the onset of roughness. Turbulence statistics are then evaluated far from the surface transition, where various compressibility transformations reveal outer-layer similarity for the mean velocity. We find that the classical van Driest II transformation can also be applied to rough walls, at least in the adiabatic case. Analysis of thermal statistics for the supersonic case confirms the significant influence that roughness has on both mean and fluctuating temperature fields, which, unlike velocity fields, do not display outer-layer similarity. Nonetheless, we find that the temperature–velocity relation established for smooth walls is also valid over rough surfaces, implying that the mean temperature field can be predicted solely based on the mean velocity.