The thermal expansion of gallium (Ga) encapsulated in carbon nanotubes has been studied. It is demonstrated that the volumetric expansion and contraction of the Ga confined in the carbon nanotubes display a linear relationship with temperature. While the level of the tip of the Ga column changes linearly with temperature, it returns to its previous position, without any hysteresis, when reheated or cooled to the original temperature, provided the Ga has not frozen and electron-beam irradiation is minimized. It is shown that electron beam irradiation can cause shrinkage in carbon-nanotube diameter, and that a high-intensity electron beam can also induce the formation of new carbon shells inside the carbon nanotubes. Upon freezing, the solid Ga has two unique orientation relationships with the carbon nanotubes.