The fossil remains, the dead and decayed matter is the main source for the oil and mineral deposits underground. All the dead plants and animals buried underground go through decomposition by the bacteria and microorganisms present deep inside the ground. All these decomposed and left over remains combine to form the oil deposits.
As more and more sediments gets deposited underground the temperature and pressure causes breakdown in them. Protein, lignin and cellulose break down instantly into amino acids and sugars. The heat catalyses the reaction. Through exposure to air and water it oxidises. A small proportion of this organic matter gets settled down under the beds of seas and oceans. This organic matter gets mixed up with inorganic matter like clay, sand particles and dead planktons. So this mud mixture hardens and gets settled at the rock beds. And eventually produces oil and gas deposit.
Increasing sediment deposit on rocks increases the weight of the rock. These heavy weight rocks are pushed into the deep sea beds. And the further deposition increases eventually. This sedimentation process increases year to year and thus it takes over millions of years for the oil deposit. As the sediment rocks accumulate there will be increase in temperature and pressure. Under these physical conditions sulphur and phosphorous gradually get converted to kerogen. This kerogen is a transitional material made up of water, carbon dioxide and hydrogen which are eventually transformed into oils and gases.
The oil deposits are formed between two porous layers. So the oil flow or movement will be sideways and there will be no downward movement of these deposits. So the pressure inside the ground various the oil movement level. As the pressure increases the oil moves upwards towards the ground surface. And the oils when raised due to pressure may find its way between the rocks. That is why we can get oil from old age rocks. To check whether the rocks have oil remains, they are drilled layer by layer. As the cork reaches the inside of rock the nature of it can be governed. By studying the rocks underground the oil deposits proportion can be determined. If the study gives positive outcome then further procedures are followed to extract oil from deposits.