We investigate metastable and thermodynamically stable phases that can be expected to occur in electroformed filaments in resistively switching hafnia, and discuss their relevance for the switching process. To this end, we conduct a study, based on density functional theory combined with an evolutionary algorithm determining the composition-dependent (meta)stable phases in HfO x , focusing on the region 0 < x < 2. We find that oxygen vacancies in hafnia tend to form regular patterns, which leads to periodic metastable structures featuring onedimensional open channels, thus favoring ionic conductivity in the host material, i.e., oxygen migration. The band gap of such structures is systematically lowered with increasing oxygen deficiency, resulting in metallic behavior when oxygen migrates out of the channels. Moreover, we find that the solubility of oxygen in metallic Hf is very high, up to one oxygen per six metallic atoms, the concentration corresponding to a thermodynamically stable and ordered metallic compound, Hf 6 O. Therefore, thick enough metallic capping of Hf could play the role of an active electrode for hosting oxygen which migrates out of HfO 2. In combination with reversible oxygen migration in predicted suboxide phases, this should lead to robust resistive memory cells with high endurance and long retention.