Vagrant OEL 8 DevOps · VirtualBox · Box Packaging

VagrantCustom OEL 8 Box Creation

Create custom Vagrant boxes for OEL 8 — repackage existing VMs or build from ISO. Pre-bake database prerequisites, kernel tuning and Oracle tools.

Creating a custom Vagrant box lets you pre-bake everything you need — Oracle Linux packages, kernel tuning, database prerequisites, company-standard configurations — so every team member starts with an identical, ready-to-use environment in minutes.

ApproachStarting PointBest for
Repackage existing VMExisting running Vagrant VMQuick — add software to public box and repackage
Build from scratchOEL 8 ISOFull control — custom partitioning, kernel, packages
BASH — Customize VM
# Start from generic/oracle8
mkdir ~/custom-box-build && cd ~/custom-box-build
vagrant init generic/oracle8
vagrant up

# SSH in and install everything you want pre-baked
vagrant ssh

# Inside VM — install common tools and DB prerequisites
sudo dnf install -y vim wget curl net-tools telnet bind-utils   gcc make perl kernel-devel dkms   libaio libaio-devel numactl sysstat   oracle-database-preinstall-19c

# Tune sysctl for databases
sudo cat >> /etc/sysctl.conf << EOF
vm.swappiness = 10
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
EOF
sudo sysctl -p

# Set timezone
sudo timedatectl set-timezone Asia/Kolkata

# Disable firewall (lab use)
sudo systemctl disable --now firewalld

# Disable SELinux
sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

# Clean up to reduce box size
sudo dnf clean all
sudo rm -rf /tmp/*
sudo cat /dev/null > ~/.bash_history
history -c
exit
BASH — Package Box
# From host — halt the VM cleanly
vagrant halt

# Package the VM (VirtualBox only)
vagrant package --output oel8-custom.box

# This creates oel8-custom.box in current directory
ls -lh oel8-custom.box
BASH — Test Box
# Add the box
vagrant box add oel8-db-ready oel8-custom.box

# Verify
vagrant box list
# oel8-db-ready (virtualbox, 0)

# Test it
mkdir ~/test-custom && cd ~/test-custom
vagrant init oel8-db-ready
vagrant up
vagrant ssh
# Should have all your pre-installed tools!
exit

# Clean up test
vagrant destroy -f
BASH — Build from ISO
# 1. Download OEL 8 ISO from oracle.com
# https://yum.oracle.com/oracle-linux-isos.html

# 2. In VirtualBox GUI — create new VM:
#    Name: OEL8-Box-Template
#    Type: Linux, Version: Oracle (64-bit)
#    RAM: 2048 MB
#    Disk: 40 GB (VDI, dynamically allocated)
#    Mount OEL 8 ISO

# 3. Install OEL 8 — minimal install with:
#    - Root password set
#    - vagrant user created during install

# 4. After install — configure for Vagrant (run inside VM):

# Create vagrant user if not done during install
sudo useradd vagrant
echo "vagrant" | sudo passwd --stdin vagrant
echo "vagrant ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/vagrant
sudo chmod 440 /etc/sudoers.d/vagrant

# Install Guest Additions dependencies
sudo dnf install -y gcc make perl kernel-devel kernel-headers bzip2

# Mount and install Guest Additions (Devices menu → Insert GA CD)
sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run
sudo umount /mnt

# Add Vagrant insecure SSH key
sudo mkdir -p /home/vagrant/.ssh && sudo chmod 700 /home/vagrant/.ssh
sudo curl -sSL   https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub   -o /home/vagrant/.ssh/authorized_keys
sudo chmod 600 /home/vagrant/.ssh/authorized_keys
sudo chown -R vagrant:vagrant /home/vagrant/.ssh

# Fix SSH config
sudo sed -i "s/UseDNS yes/UseDNS no/" /etc/ssh/sshd_config

# Clean up
sudo dnf clean all && sudo rm -rf /tmp/*
sudo shutdown -h now

# On host — package the VirtualBox VM
vagrant package --base "OEL8-Box-Template" --output oel8-from-iso.box

# Add box
vagrant box add oel8-from-iso oel8-from-iso.box
vagrant box list
BASH — Pre-bake DB Tools
# Inside custom VM — pre-install everything for database labs

# Oracle prerequisites
sudo dnf install -y oracle-database-preinstall-19c

# MySQL prerequisites
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
sudo dnf install -y https://dev.mysql.com/get/mysql80-community-release-el8-9.noarch.rpm
sudo dnf module disable -y mysql

# Common database tools
sudo dnf install -y   mysql-community-client   mysql-shell   unzip wget curl vim   net-tools telnet bind-utils   sysstat lsof strace   python3 python3-pip

# Tune kernel for databases
sudo cat >> /etc/sysctl.conf << EOF
vm.swappiness                  = 10
kernel.sem                     = 250 32000 100 128
fs.file-max                    = 6815744
net.ipv4.ip_local_port_range   = 9000 65500
net.core.rmem_default          = 262144
net.core.rmem_max              = 4194304
net.core.wmem_default          = 262144
net.core.wmem_max              = 1048576
EOF
sudo sysctl -p

echo "Custom database-ready OEL 8 box complete!"
💡 Note: Custom boxes reduce vagrant up time dramatically. Instead of a 10-minute provisioning run, a pre-baked box starts in under 2 minutes with everything ready.