The mineral Magnetite gets its name because it's magnetic. Lodestone, a type of rock containing magnetite, was once use for primitive compasses. Magnetite is present in most igneous and metamorphic rock and provides a record of the earth's changing magnetic field. Grains of magnetite in molten lava and magma will align toward the earth's magnetic poles, becoming fixed in position when they cool and harden. Examination of the magnetic domains of lava beds reveals clues as to the earth's magnetic polarity throughout history.
Magnetite is made of iron(II) and iron(III) oxides. Not all rocks containing grains of magnetite are magnetic because the magnetic domains can cancel out. Those that are magnetic have their magnetic domains oriented in one direction, due to the influence of the earth's magnetic field when they formed.
Magnetite gives black sand its color.