Oracle VirtualBox is a powerful x86 and AMD64 / Intel64 virtualization product for enterprise and home use. VirtualBox is a general-purpose complete virtual machine for x86 hardware. Targeted at server, desktop and embedded applications, it is now the only professional-quality virtualization solution and also open source software.

This document describes how to install VirtualBox 6.0 (currently 6.0.10) on CentOS 7.6/6.10 and Red Hat (RHEL) 7.6/6.10. This guide uses Virtual Box’s own YUM repository.

1. Change the user name to root

su -
## OR ##
sudo -i
Copy the code

2. Install the RHEL Repo file

curl http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -o /etc/yum.repos.d/virtualbox.repo
Copy the code

3. Update the latest software package and check the kernel version

Update package

yum -y update
Copy the code

Check if you are running the latest installed kernel version the output version number of the following command should match:

rpm -qa kernel |sort -V |tail -n 1

uname -r
Copy the code

Note: If you get a kernel update or run an older kernel than the latest installation, then reboot:

reboot
Copy the code

4. Install the following dependency packages

CentOS 7/6 and Red Hat (RHEL) 7/6 require the EPEL repository. Use the following command to install it:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Copy the code
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers-`uname -r` kernel-devel-`uname -r` dkms
Copy the code

5. Install VirtualBox latest version 6.0 (currently 6.0.10)

Yum install VirtualBox - 6.0Copy the code

Note: This command automatically creates the vboxUsers group of which the VirtualBox user must be a member. This command also builds the required kernel modules. The package is VirtualBox-6.0 instead of VirtualBox.

Use the following command to rebuild the kernel module:

/usr/lib/virtualbox/vboxdrv.sh setup
Copy the code

6. Add the VirtualBox user to the vboxUsers group

Replace user_name with your own user name or another real user name.

usermod -a -G vboxusers user_name
Copy the code

7. Start the VirtualBox screen

Use the launcher from the menu or just run VirtualBox as a normal user:

VirtualBox
Copy the code

8. Change the storage directory of the VM

# Default directory ~/VirtualBox VMs
VBoxManage setproperty machinefolder ~/virtualbox_vms
Copy the code

###9. Boot

Replace user_name with your own user name or another real user name. Replace vm-name with the name of the VM to be started

# edit the rc.local file
vim /etc/rc.d/rc.local

# add at the end of the file
su - <user_name> -c "VBoxManage startvm <vm_name> --type headless"

# Save the execution command
chmod +x /etc/rc.d/rc.local
Copy the code

troubleshooting

If you experience problems with the KERN_DIR parameter or your kernel directory is not automatically detected, manually set the KERN_DIR environment variable using the following methods:


## Current running kernel on CentOS and Red Hat (RHEL) ##
KERN_DIR=/usr/src/kernels/`uname -r`-`uname -m`


## CentOS and Red Hat (RHEL) example ##KERN_DIR = / usr/SRC/kernels 2.6.18-194.11.1. El5 - x86_64## Export KERN_DIR ##
export KERN_DIR
Copy the code

Original English: www.if-not-true-then-false.com/2010/instal…