Escherichia coli glycogen metabolism is controlled by the PhoP-PhoQ regulatory system at submillimolar environmental Mg2+ concentrations, and is highly interconnected with a wide variety of cellular processes.