The production of molecular hydrogen in the radiolysis of dried or hydrated nanoporous controlled-pore glasses (CPG) has been carefully studied using 10 MeV electron irradiation at high dose rate. In all cases, the H2 yield increases when the pore size decreases. Moreover, the yields measured in dried materials are two orders of magnitude smaller than those obtained in hydrated glasses. This proves that the part of the H2 coming from the surface of the material is negligible in the hydrated case. Thus, the measured yields correspond to those of nanoconfined water. Moreover, these yields are not modified by the presence of potassium bromide, which is a hydroxyl radical scavenger. This experimental observation shows that the back reaction between H2 and HO* does not take place in such confined environments. These porous materials have been characterized before and after irradiation by means of Fourier-transform infrared (FT-IR) spectroscopy, electron paramagnetic resonance (EPR) and nuclear magnetic resonance (NMR) techniques, which helps to understand the elementary processes taking place in this type of environment, especially the protective effect of water on the surface in the case of hydrated glasses.