increase vdi space and Linux partition using terminal

Last night as I was setting up a Oracle Linux test server I accidentally allocated the default virtual box value in GB. That was roughly 12GB. Enough space for a test installation if you consider that Oracle Linux 6 takes up around 7GB. But I wanted to install ArcGIS server and for that I needed more than 6GB of space, which apparently the current configuration was not adequate. Till I realised that, I had already spend quite some time configuring the system, so there was no chance to go back and start the process all over again.

On the other hand the easy solution to extend the Disk was through Gparted which again was not an option cause there was no point in spending time installing a Desktop environment and looking around yum for all Gparted dependencies, since Gparted is not part of the default yum repository.

So I had to do the whole process through command line.

Luckily It can be done.