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.

First you need to expand the vdi size using the following command

Now the vdi disk space is expanded to 30GB but that space is not located. Here is how

1. Start up you virtual machine and log on as root
2. Type fdisk -l the result should be something like this

3. Type fdisk /dev/sda replacing the sda with the bold name from Step 2 if different
4. By typing p and enter so as to print the partition table
5. By typing n and enter so as to add a new partition
6. Type again p and enter so as to make it a primary partition
7. You will be prompted to enter some values, those represent the disk cylinders. Usually the default value would be the correct one, else type the last cylinder value of the last partition (usually sda2 or sda3).
8. You you be prompted to enter the last cylinder. Usually the default value would be the correct one, else type the max cylinder value from Step 2.
9. Type w and enter to save
10. Restart the VM and Log in back as root
11. By typing fdisk -l again you will notice one more partition
12. Next step is to type df -h, so as to get the name of the Volume Group for our next Steps. Running df -h Will get you something like this
Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root
13. Now we will use the command vgextend to add the created partition to the Volume Group

(where sda4 the name of the created partition and where VolGroup the bold name from Step 12)
14. Expand the Logical Volume by typing lvextend -L+17G /dev/VolGroup/lv_root (where VolGroup the bold name from Step 12 and 17G the remaining space)
15. Finally expand the file system in the logical volume by typing resize2fs /dev/VolGroup/lv_root(where VolGroup the bold name from Step 12).

YOU ARE FINALLY DONE do a df -h to verify the results

Even though I have never done this it was pretty easy. Obviously I didn’t figure all this stuff by myself, so I copied most steps from this blog and adjusted the solution to my needs. Also I tried to simplify the Steps as I understood them myself.

Then I went along and installed the ArcGIS server, flushed the iptables and everything worked like a charm. ArcGis Server officially does not support Oracle Linux, but since Oracle Linux is based on Red Hat (which esri supports) I thought to give it a try. So far it works pretty well but only time and tests will tell if that is actually the case.