Even in the era of Docker and Kubernetes, Vagrant continues to be a simple and effective way to spin up full-featured VMs. If you're setting up an Oracle environment, Vagrant is still a go-to tool for building consistent, disposable, and scriptable development machines.
In this comprehensive tutorial, you'll learn how to build an Oracle Linux 8 VM using Vagrant with VirtualBox as the provider — with steps to configure memory, attach a custom disk, and bring the VM online.
💡 Pro Tip: This setup is perfect for Oracle Database installations, testing environments, and development sandboxes!
📋 Prerequisites
Before we dive in, make sure you have:
- ✅ VirtualBox installed on your system
- ✅ Vagrant installed and configured
- ✅ At least 10GB of free disk space
- ✅ 8GB RAM available for the VM
📁 Step 1: Create Your Vagrant Working Directory and Add the Oracle Linux Box
First, let's create a dedicated folder for your Oracle Linux project:
mkdir C:\vagrant-oraclelinux
cd C:\vagrant-oraclelinux
Now, add the generic Oracle Linux 8 base box using:
vagrant box add generic/oracle8
During the prompt, you'll be asked to choose the provider. Select VirtualBox (option 6) as shown below:
==> box: Loading metadata for box 'generic/oracle8'
box: URL: https://vagrantcloud.com/api/v2/vagrant/generic/oracle8
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.
1) docker
2) hyperv
3) libvirt
4) parallels
5) qemu
6) virtualbox
7) vmware_desktop
Enter your choice: 6
After successful download, you'll see:
==> box: Successfully added box 'generic/oracle8' (v4.3.12) for 'virtualbox (amd64)'!
🎯 Quick Tip: The download might take a few minutes depending on your internet speed. Grab a coffee! ☕
✍️ Step 2: Create and Edit the Vagrantfile
Open the Vagrantfile
in your favorite text editor:
notepad Vagrantfile
Paste the following configuration:
Vagrant.configure("2") do |config|
config.vm.box = "generic/oracle8"
config.vm.hostname = "oracle19c"
config.vm.provider "virtualbox" do |vb|
vb.memory = 8192
vb.cpus = 2
vb.customize [
"storageattach", :id,
"--storagectl", "SATA Controller",
"--port", 1,
"--device", 0,
"--type", "hdd",
"--medium", "C:/vagrant-oraclelinux/u01.vdi"
]
end
end
📝 Configuration Breakdown:
Parameter | Value | Description |
---|---|---|
Box Name | "generic/oracle8" |
Oracle Linux 8 base image |
Hostname | oracle19c |
Sets guest machine name |
Memory | 8192 MB |
Allocates 8 GB RAM |
CPUs | 2 |
Assigns 2 CPU cores |
Custom Disk | u01.vdi |
Additional 50GB storage |
⚠️ Important: Adjust memory and CPU values based on your host machine's capabilities!
💾 Step 3: Create a Virtual Disk for Oracle Data
Use VBoxManage.exe
to create a 50GB virtual hard disk for Oracle data:
& "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" createmedium disk --filename "C:\vagrant-oraclelinux\u01.vdi" --size 51200
This dedicated disk will be used for:
- 🗄️ Oracle installation files
- 💾 Database storage
- 📊 Tablespaces and data files
💡 Storage Tip: You can adjust the size by changing
51200
(50GB) to your preferred size in MB.
🚀 Step 4: Start the Virtual Machine
Now let's power up the VM:
vagrant up
Vagrant will automatically:
- 🔧 Initialize the VM
- 💽 Attach the custom disk
- 🖥️ Boot Oracle Linux 8
- ⚙️ Configure networking
The process typically takes 2-5 minutes. You'll see output similar to:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'generic/oracle8' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
🔐 Step 5: Connect to the VM via SSH
Once the VM is up and running, connect to it:
vagrant ssh
🎉 Success! You're now inside the Oracle Linux 8 virtual machine, ready to install Oracle software or run any manual configuration.
Quick System Check:
# Check OS version
cat /etc/os-release
# Check available disk space
df -h
# List attached disks
lsblk
🛠️ Step 6: VM Lifecycle Management
To stop the VM:
vagrant halt
To restart it:
vagrant up
To reconnect:
vagrant ssh
To destroy the VM (when no longer needed):
vagrant destroy
🔄 Lifecycle Tip: Use
vagrant status
to check the current state of your VM.
🤔 What's Next?
Now that your Oracle Linux 8 VM is ready, you can:
- Install Oracle Database 19c or 21c
- Set up Oracle APEX for web application development
- Configure Oracle Grid Infrastructure for RAC testing
- Install Oracle Enterprise Manager for database management
- Create multiple VMs for cluster configurations
Did you find this tutorial helpful? Share it with your fellow Oracle DBAs and developers! 🚀
Tags: #OracleLinux #Vagrant #VirtualBox #DatabaseDevelopment #DevOps #Oracle #Virtualization #Linux
Comments
Post a Comment