  Earth-like planets orbiting M-dwarf stars, M-Earths, are currently the best
targets to search for signatures of life. Life as we know it requires water.
The habitability of M-Earths is jeopardized by water loss to space: high flux
from young M-dwarf stars can drive the loss of 3--20 Earth oceans from
otherwise habitable planets. We develop a 0-D box model for Earth-mass
terrestrial exoplanets, orbiting within the habitable zone, which tracks water
loss to space and exchange between reservoirs during an early surface magma
ocean phase and the longer deep-water cycling phase. A key feature is the
duration of the surface magma ocean, assumed concurrent with the runaway
greenhouse. This timescale can discriminate between desiccated planets, planets
with desiccated mantles but substantial surface water, and planets with
significant water sequestered in the mantle. A longer-lived surface magma ocean
helps M-Earths retain water: dissolution of water in the magma provides a
barrier against significant loss to space during the earliest, most active
stage of the host M-dwarf, depending on the water saturation limit of the
magma. Although a short-lived basal magma ocean can be beneficial to surface
habitability, a long-lived basal magma ocean may sequester significant water in
the mantle at the detriment of surface habitability. We find that magma oceans
and deep-water cycling can maintain or recover habitable surface conditions on
Earth-like planets at the inner edge of the habitable zone around late M-dwarf
stars -- these planets would otherwise be desiccated if they form with less
than ${\sim}$10 terrestrial oceans of water.
