  The remarkable anharmonicity of the E_{2g} phonon in MgB_2 has been suggested
in literature to play a primary role in its superconducting pairing. We
investigate, by means of LDA calculations, the microscopic origin of such an
anharmonicity in MgB_2, AlB_2, and in hole-doped graphite. We find that the
anharmonic character of the E_{2g} phonon is essentially driven by the small
Fermi energy of the sigma holes. We present a simple analytic model which
allows us to understand in microscopic terms the role of the small Fermi energy
and of the electronic structure. The relation between anharmonicity and
nonadiabaticity is pointed out and discussed in relation to various materials.
