Showing posts with label Oracle Virtualbox. Show all posts
Showing posts with label Oracle Virtualbox. Show all posts

Monday, October 31, 2016

Configure Oracle Virtual Box with vdi

Open Oracle VirtualBox Manager


Click on New

Type OCP_CLASS as Name, Select Linux as type, Red Hat (64-bit) as version and Click on continue.

Select Memory Size lets say in my case I want to allocated 2GB (2048 MB) as Memory and Click on continue.

Select Do not add a virtual hard drive and click on create.


Error message will be displayed. Click on continue.


New Virtual Machine OCP_CLASS has been created. Select the virtual machine and Click on Setting.


Once setting window is opened click on Storage for configuring storage setting.




Select Controller: SATA and Click on Plus sign at right to add Drive provided by instructor.

Click on existing disk, select the vdi disk file provided and Click on open.


Once you add the vdi file setting looks as on the listed above.


Click on Network to modify network setting. 

Click on Enable network and Select host only adapter as Attached to: and vboxnet0 as the Name. We are using host only network setting that will be enabled for the host machine only.

It will configure IP pool range of 192.168.56.0/24. 192.168.1.1 will be IP setting for the host and virtual machine wil be configured with the IP from pool 192.168.56.0/24
Click on OK to complete virtual box settings.

Click on Start to start virtual machine.

Login as user root and password. 

Change directory to /etc/sysconfig/network-scripts and open ifcfg-enp0s3 file


Change BOOTPROTO to static from dhcp and add following
IPADDR=192.168.56.200
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
Save file and restart machine to get the change on effect.

Verify newly set ip address is set


Modify host file.



Start listener and database


Configure SQL Developer 
You can connect now.


Once your task completed you can close it and save machine state so that you can open vm immediately whenever required.

Saturday, October 29, 2016

Restore ova file Oracle VirtualBox

Open Oracle VirtualBox.


Click on File > Import Appliance...


Select ova file location and click on Import


Importing on progress..


Once Import Complete Oracle VM will be visible. In our case VM OCP_CLASS has been created.



Select VM and Click on Start to start VM.



Login as user oracle and Start Oracle listener and Oracle database


Now you can connect to oracle with SQL Developer.


Once you have completed the practice you can save the state of machine which helps starting VM faster and you do not have to start listener and database later on.
Click on X(close). Select Save machine state and Click on OK.


To start the saved machine. Select the machine that has state saved. Click on Start to start VM.

Friday, December 4, 2015

Shrink Oracle Virtualbox virtual machines to claim unused space

Over the time, we can notice that the size of the dynamically growing virtual disks vdi file keep growing on Oracle Virtual box. Deleting the files inside the Guest Machine does not free up any space in the Host Machine's hard drive. We need to shrink vdi file to claim unused space.
Please follow the steps below to claim unused space.

We can notice that the size of the DGMaster.vdi is 20GB











Delete unnecessary files from the Guest machine.

Power off the guest machine.

Convert vdi file to compact.

VBoxManage modifyvdi DGMaster.vdi --compact








Power On the Guest Machine and install zero free package inside it.


We can get package from URL below. Package for EL5 works perfect for EL6 too.

http://rpm.pbone.net/index.php3/stat/4/idpl/15277264/dir/redhat_el_5/com/zerofree-1.0.1-5.el5.x86_64.rpm.html
rpm -ivh zerofree-1.0.1-5.el5.x86_64.rpm 




















Now umount the partition or make it read only. In my case I am freeing space from root partition so I need to reboot my Guest Machine to single user mode and make it read only.


Boot the system to single user mode
mount -o remount,ro /dev/mapper/vg_oel1-lv_root


















Now find and fill unused, unallocated blocks with zero. 

zerofree -v /dev/mapper/vg_oel1-lv_root







Output can be interpreted as: Total number of modified blocks/Total number of free blocks/Total number of blocks


Mount back the root partition to rw mode and poweroff the guest machine.

mount -o remount,rw /dev/mapper/vg_oel1-lv_root
poweroff


Now execute VBoxManage compact command from Host Machine to reclaim unused space. After modifyvdi completes you may notice the file size change.

VBoxManage modifyvdi DGMaster.vdi --compact






















We can notice that Size of DGMaster.vdi has been decreased from 20GB to 14GB.