It is widely known that the solutions of Lyapunov equations can be used to compute the H2 norm of linear time-invariant (LTI) dynamical systems. In this paper, we show how this theory extends to dynamical systems with delays. The first result is that the H2 norm can be computed from the solution of a generalization of the Lyapunov equation, which is known as the delay Lyapunov equation. From the relation with the delay Lyapunov equation we can prove an explicit formula for the H2 norm if the system has commensurate delays, here meaning that the delays are all integer multiples of a basic delay. The formula is explicit and contains only elementary linear algebra operations applied to matrices of finite dimension. The delay Lyapunov equations are matrix boundary value problems. We show how to apply a spectral discretization scheme to these equations for the general, not necessarily commensurate, case. The convergence of spectral methods typically depends on the smoothness of the solution. To this end we describe the smoothness of the solution to the delay Lyapunov equations, for the commensurate as well as for the non-commensurate case. The smoothness properties allow us to completely predict the convergence order of the spectral method.