Back to the main page

Oracle Virtual Box on OL7.5

Install on OL7 VM

Install from yum repo, addson.
yum install VirtualBox-5.2
Configure the VBox
#  rcvboxdrv setup 
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services. vboxdrv.sh: failed: Running VirtualBox in a Xen environment is not supported. 


Install on physical hardware, ol7.5

yum install VirtualBox-5.2
yum install gcc make perl
yum install kernel-uek-devel
# rcvboxdrv setup
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.

# VirtualBox
Qt FATAL: QXcbConnection: Could not connect to display
Aborted (core dumped)

VBoxManage

This is CLI manager.
# VBoxManage
Oracle VM VirtualBox Command Line Management Interface Version 5.2.0
Usage:
VBoxManage [<general option>] <command>
General Options:
[-v|--version]            print version number and exit
[-q|--nologo]          suppress the logo
[--settingspw <pw>]       provide the settings password
[--settingspwfile <file>] provide a file containing the settings password
[@<response-file>]        load arguments from the given response file (bourne style)

Supported OS

# VBoxManage list  ostypes | grep Description | grep Solaris
Description: Oracle Solaris 10 5/09 and earlier (32-bit)
Description: Oracle Solaris 10 5/09 and earlier (64-bit)
...
We'll use Oracle_64 OS type.

Create a VM

VM's name is only mandatory argument. But we also want to register VM, which is importing VM's definition into VBox. Also add os type. VM is still empty with no cpu. ram ,disk.
# VBoxManage createvm --name ca-zdudic3 --register --ostype Oracle_64
Virtual machine 'ca-zdudic3' is created and registered.
UUID: 2b373d3e-9d70-478a-b50f-f7209698e89a
Settings file: '/root/VirtualBox VMs/ca-zdudic3/ca-zdudic3.vbox' (this XML file is created)
For example, edit VM via GUI, like adding description, and this XML file will be updated.
# VBoxManage list vms
"ca-zdudic3" {2b373d3e-9d70-478a-b50f-f7209698e89a}

VM's properties

# VBoxManage showvminfo ca-zdudic3
Name:    ca-zdudic3
Groups:          /
Guest OS:        Oracle (64-bit)
UUID:            2b373d3e-9d70-478a-b50f-f7209698e89a
Config file:     /root/VirtualBox VMs/ca-zdudic3/ca-zdudic3.vbox
Snapshot folder: /root/VirtualBox VMs/ca-zdudic3/Snapshots
Log folder:      /root/VirtualBox VMs/ca-zdudic3/Logs
Hardware UUID:   2b373d3e-9d70-478a-b50f-f7209698e89a
Memory size:     128MB
...
Modify VM, add more cpu/mem/vram.
# VBoxManage modifyvm  ca-zdudic3 --cpus 2 --memory 1024 --vram 256
# VBoxManage showvminfo ca-zdudic3
...
Memory size:     1024MB
VRAM size:     256MB
Number of CPUs:  2

Virtual network adapter

Common networking modes are:
vm<->host vm1<->vm2 vm->internet vm<-internet
host only + + - -
internal - + - -
bridge + + + +
NAT - - + port forwarding
Let's use bridge mode, this is host's interface.
# ip addr s enp1s0f0
2: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 10.211.11.10/21 brd 10.211.15.255 scope global noprefixroute dynamic enp1s0f0
Create VNIC on the VM, in bridge mode, in this example, vnic will get IP from DHCP server.
# VBoxManage modifyvm ca-zdudic3  --nic1 bridged --bridgeadapter1 enp1s0f0
# VBoxManage showvminfo ca-zdudic3 | grep "NIC 1"
NIC 1:   MAC: 08002711AA17, Attachment: Bridged Interface 'enp1s0f0', Cable connected: on, 
Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none

Attach virtual media to VM

Create new virtual hard disk
Default is VDI, size in MB (12G here), variant is standard (it's like sparce, small initial size that grows as usage increase).
# VBoxManage createhd --filename "/root/VirtualBox VMs/ca-zdudic3/ca-zdudic3.vdi" --size 12288 --variant Standard
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: e5ca1452-55e7-444a-9232-2cbe88592436
Add a storage controller
This storage controller will be used with previously created hard disk.
# VBoxManage storagectl ca-zdudic3 --name "SATA_controller" --add sata --bootable on
Attach hard disk to controller
At the end, attach disk to controller.
# VBoxManage storageattach ca-zdudic3 --storagectl SATA_controller --port 0 --type hdd --medium "/root/VirtualBox VMs/ca-zdudic3/ca-zdudic3.vdi"
SATA controller can have up to 30 hard disks, IDE controller can have 4 (one is usually DVD drive).

Install guest OS into VM

Let's install ubuntu-18.04, hence first we need to attach iso image to SATA controller, use port 1. The iso has been placed into /opt directory.
# VBoxManage storageattach ca-zdudic3 --storagectl SATA_controller --port 1 --type dvddrive --medium /opt/ubuntu-18.04-desktop-amd64.iso
Now start VM with this command, it starts GUI, so you can complete installation of ubuntu.
# VBoxManage startvm ca-zdudic3 




The OS is installed, detach ISO and start using the VM.



To power it off.
# VBoxManage controlvm ca-zdudic3 poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Importing VM VBox templates

Download some VBox template (DOC-1002902.ova), check http://www.oracle.com/technetwork/server-storage/linux/downloads/vm-for-hol-1896500.html

Do dry run and check output to get idea about options to use during import!
# VBoxManage import DOC-1002902.ova --dry-run
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /opt/DOC-1002902.ova..
OK.

Now import it:
#  VBoxManage import DOC-1002902.ova --vsys 0 --memory 8192 --cpus 2 --eula accept 

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /opt/DOC-1002902.ova...
OK.
Disks:
  vmdisk2 137438953472  -1  http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized  
  D  OC-1002902-disk1.vmdk   -1      -1

Virtual system 0:
 0: Suggested OS type: "Oracle_64"
    (change with "--vsys 0 --ostype <type>"; use "list ostypes" to list all possible values)
 1: Suggested VM name "DOC-1002902"
    (change with "--vsys 0 --vmname <name>")
 2: Product (ignored): Docker
 3: Vendor (ignored): Oracle
 4: Version (ignored): 1.10
 5: ProductUrl (ignored): https://community.oracle.com/docs/DOC-1002902
 6: VendorUrl (ignored): http://oracle.com
 7: Description "arn how to customize a Docker container image and use it to instantiate application 
    instances across different Linux servers. 
    This article describes how to create a Dockerfile, how to allocate runtime resources to containers, 
   and how to establish a communication channel between two containers 
  (for example, between web server and database containers)."
    (change with "--vsys 0 --description <desc>")
 8: End-user license agreement (accepted)
 9: No. of CPUs specified with --cpus: 2
10: Guest memory specified with --memory: 8192 MB
11: Sound card (appliance expects "", can change on import)
    (disable with "--vsys 0 --unit 11 --ignore")
12: USB controller
    (disable with "--vsys 0 --unit 12 --ignore")
13: Network adapter: orig NAT, config 6, extra slot=0;type=NAT
14: CD-ROM
    (disable with "--vsys 0 --unit 14 --ignore")
15: IDE controller, type PIIX4
    (disable with "--vsys 0 --unit 15 --ignore")
16: IDE controller, type PIIX4
    (disable with "--vsys 0 --unit 16 --ignore")
17: SATA controller, type AHCI
    (disable with "--vsys 0 --unit 17 --ignore")
18: Hard disk image: source image=DOC-1002902-disk1.vmdk, 
   target path=/root/VirtualBox VMs/DOC-1002902/DOC-1002902-disk1.vmdk, controller=17;channel=0
    (change target path with "--vsys 0 --unit 18 --disk path";
    disable with "--vsys 0 --unit 18 --ignore")
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully imported the appliance.
Now you can start the VM.

Delete VM

Power off, unregistered and delete.
# VBoxManage controlvm  "gettingstartedvagrant_default_1535393838184_70910" poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

# VBoxManage unregistervm --delete  "gettingstartedvagrant_default_1535393838184_70910"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Guest Additions Software

Comes with VBox in the file /usr/share/virtualbox/VBoxGuestAdditions.iso

Back to the main page