There are three main types of rocks: igneous, sedimentary, and metamorphic. Igneous rocks form when magma cools and hardens. Sedimentary rocks form over millions of years as layers of sediments deposited by rivers and wind harden together. Metamorphic rocks form from other rocks undergoing heat and pressure in the crust, changing their mineral structure.