Atmospheric magnetic fields in stars with convective envelopes heat stellar chromospheres, and thus increase the observed flux in the CaII H and K doublet. Starting with the historical Mount Wilson monitoring program, these two spectral lines have been widely used to trace stellar magnetic activity, and as a proxy for rotation period (Prot) and consequently for stellar age. Monitoring stellar activity has also become essential in filtering out false-positives due to magnetic activity in extra-solar planet surveys. The CaII emission is traditionally quantified through the R'_HK_-index, which compares the chromospheric flux in the doublet to the overall bolometric flux of the star. Much work has been done to characterize this index for FGK-dwarfs, but M dwarfs - the most numerous stars of the Galaxy - were left out of these analyses and no calibration of their CaII H and K emission to an R'_HK_ exists to date. We set out to characterize the magnetic activity of the low- and very-low-mass stars by providing a calibration of the R'_HK_-index that extends to the realm of M dwarfs, and by evaluating the relationship between R'_HK_ and the rotation period.. We calibrated the bolometric and photospheric factors for M dwarfs to properly transform the S-index (which compares the flux in the CaII H and K lines to a close spectral continuum) into the R'_HK_. We monitored magnetic activity through the CaII H and K emission lines in the HARPS M dwarf sample.