Edinburgh Castle is a historic castle in Edinburgh, Scotland. It stands on Castle Rock, which has been occupied by humans since at least the Iron Age, although the nature of the early settlement is unclear.

There has been a royal castle on the rock since at least the reign of David I in the 12th century, and the site continued to be a royal residence until 1633. From the 15th century, the castle's residential role declined, and by the 17th century it was principally used as military barracks with a large garrison. Its importance as a part of Scotland's national heritage was recognised increasingly from the early 19th century onwards, and various restoration programmes have been carried out over the past century and a half.

The castle stands upon the plug of an extinct volcano, which is estimated to have risen about 350 million years ago during the lower Carboniferous period. The Castle Rock is the remains of a volcanic pipe, which cut through the surrounding sedimentary rock before cooling to form very hard dolerite, a type of basalt. Subsequent glacial erosion was resisted by the dolerite, which protected the softer rock to the east, leaving a crag and tail formation.

More Info: en.wikipedia.org