How to install VirtualBox on Rocky Linux 9

Share on Social Media

Learn how to install VirtualBox on Rocky Linux 9 with our comprehensive step-by-step guide. Enable seamless virtualization and run multiple operating systems on your Linux environment with ease. #centlinux #linux #virtualbox

YouTube player

What is VirtualBox?

VirtualBox is an open-source virtualization software developed by Oracle that allows you to run multiple operating systems (OS) simultaneously on a single physical machine. It creates virtual machines (VMs) that emulate a complete hardware environment, enabling you to install and run different OSes in isolation from each other and from the host operating system. Here are some key features and uses of VirtualBox:

  1. Cross-Platform Compatibility: VirtualBox runs on various host operating systems, including Windows, macOS, Linux, and Solaris. This makes it a versatile tool for users across different platforms.
  2. Guest Operating Systems: You can install a wide range of guest operating systems on VirtualBox, such as different versions of Windows, various Linux distributions, macOS, Solaris, and even older or less common OSes.
  3. Snapshotting: VirtualBox allows you to take snapshots of your virtual machines at any point in time. Snapshots capture the entire state of the VM, allowing you to revert back to that state if needed, which is useful for testing and development.
  4. Seamless Mode: This feature allows you to integrate applications from the guest OS with the host OS desktop, providing a more seamless user experience between the two environments.
  5. Shared Folders and Clipboard: VirtualBox supports shared folders, enabling easy file sharing between the host and guest OS. It also supports shared clipboard functionality, allowing you to copy and paste between host and guest systems.
  6. Networking: VirtualBox offers various networking modes, such as NAT, Bridged, Internal, and Host-only networking, allowing VMs to communicate with each other, the host, and external networks as needed.
  7. USB Support: VirtualBox provides support for USB devices, allowing you to connect USB peripherals to your virtual machines as if they were connected directly to the guest OS.
  8. Virtual Disk Images: VirtualBox uses virtual disk images (VDIs) to store the guest OS and its data. These images are files on the host system that simulate hard drives for the virtual machines.
  9. Extensibility: VirtualBox supports a variety of extension packs that can add additional functionality, such as support for remote desktop protocol (RDP), USB 2.0/3.0 devices, and PXE boot for Intel cards.
  10. Cost and Licensing: VirtualBox is free to use under the GNU General Public License (GPL) for personal and educational purposes. An enterprise version with additional features, called Oracle VM VirtualBox Extension Pack, is available under a different license.

VirtualBox is widely used for software development, testing, and education because it provides an easy way to run multiple OSes on a single machine without the need for additional hardware. It’s a valuable tool for developers who need to test their applications on different platforms, IT professionals managing multiple environments, and anyone interested in learning about or using different operating systems.

What is VirtualBox Guest Additions?

VirtualBox Guest Additions are a suite of software drivers and utilities that can be installed inside a virtual machine (VM) running on VirtualBox to improve the integration and performance of the guest operating system. Here are the key features and benefits of installing Guest Additions:

  1. Improved Performance: Guest Additions include optimized drivers for the guest operating system, which enhance the performance of graphics, disk I/O, and network operations. This leads to smoother and faster operation of the guest OS.
  2. Seamless Mouse Integration: With Guest Additions installed, the mouse pointer can move seamlessly between the host and guest OS without the need to press a special key to release the mouse from the guest. This makes the interaction between the host and guest much more fluid.
  3. Shared Clipboard: Guest Additions enable a shared clipboard between the host and guest OS, allowing you to copy and paste text, files, and other data between the two environments seamlessly.
  4. Shared Folders: This feature allows you to create folders on the host that are accessible from the guest OS, making it easy to transfer files between the host and guest without needing network shares or external storage.
  5. Automated Window Resizing: With Guest Additions, you can resize the VM window, and the guest OS will automatically adjust its screen resolution to match the new window size. This makes it easier to manage VM display settings and improves usability.
  6. Better Graphics Support: Guest Additions provide enhanced video drivers that support higher resolutions, better color depth, and smoother graphics performance. This is particularly useful for graphical applications and desktop environments.
  7. Seamless Mode: This feature allows you to run applications from the guest OS as if they were running on the host OS desktop. Applications from the guest appear on the host desktop without the full guest desktop environment, providing a more integrated user experience.
  8. Time Synchronization: Guest Additions synchronize the guest OS clock with the host OS clock, ensuring that the time settings remain consistent between the two systems.
  9. Automated Logins: For supported guest OSes, Guest Additions can automate the login process, allowing you to log into the guest OS without needing to enter credentials each time.
  10. Shared Memory and Drag-and-Drop: Some features like shared memory and drag-and-drop functionality between the host and guest OS are also provided by Guest Additions, enhancing the overall usability and interaction between systems.

VMware vs VirtualBox

VMware

Pros

  • Performance: Better CPU and memory utilization.
  • Features: Advanced options like cloning and snapshots.
  • 3D Graphics: Superior support.
  • Support: Robust commercial support.

Cons

  • Cost: Paid product (Pro); Player is free but limited.
  • Complexity: More complex to use and configure.

VirtualBox

Pros

  • Cost: Free and open-source.
  • Ease of Use: User-friendly setup.
  • Cross-Platform: Supports Windows, macOS, Linux, and Solaris.
  • Extensibility: Rich plugin ecosystem.

Cons

  • Performance: Generally lower than VMware.
  • 3D Graphics: Basic support.
  • Support: Lacks dedicated commercial support.

Best for

  • VMware: Professional and enterprise environments needing advanced features and performance.
  • VirtualBox: Personal use, education, and small projects due to its cost-effectiveness and simplicity.

Recommended Online Training: Mastering VirtualBox and Network Virtualization

1433424 b574 3show?id=oLRJ54lcVEg&offerid=1074652.1433424&bids=1074652

Environment Specification

We are using a minimal Rocky Linux 9 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux release 9.0 (Blue Onyx)
  • Hostname – virtualbox-01.centlinux.com
  • IP Address – 192.168.116.131/24

Read Also: How to install VirtualBox on CentOS 7

Check CPU Support for Virtualization

By using a ssh client, connect with your Rocky Linux 9 server as root user.

By executing lscpu command, you can easily verify that, Is your CPU is supporting virtualization or not?

# lscpu | grep Virtualization
Virtualization:                  VT-x
Virtualization type:             full

If you get the above output, then it means that your CPU supports virtualization and you can setup a VirtualBox virtualization host thereon.

However, if the above command returns no result on your server then:

  • In case of bare-metal machine, you have to enable the VT support from system BIOS.
  • In case of virtual machine, you have to enable the VT support from VM’s CPU Settings.

Set Hostname in Rocky Linux 9

By using hostnamectl command, set the hostname of your Linux server.

# hostnamectl set-hostname virtualbox-01.centlinux.com

Update Linux Software Packages

Refresh cache of your enabled yum repositories with the help of dnf command.

# dnf makecache --refresh
Rocky Linux 9 - BaseOS                          376 kB/s | 1.7 MB     00:04
Rocky Linux 9 - AppStream                       398 kB/s | 6.0 MB     00:15
Rocky Linux 9 - Extras                          1.5 kB/s | 2.9 kB     00:01
Metadata cache created.

Now, execute following command to update your Linux software packages.

# dnf update -y

The above command may also updates your Linux Kernel. In this case, you should reboot your operating system with the new Linux Kernel.

# reboot

Check the versions of your Linux operating system and Kernel as follows.

# cat /etc/rocky-release
Rocky Linux release 9.0 (Blue Onyx)

# uname -r
5.14.0-70.26.1.el9_0.x86_64

Add VirtualBox Yum Repository

Some required packages of VirtualBox software are not available in Standard yum repositories.

Therefore, you need to install EPEL (Extra Packages for Enterprise Linux) yum repository.

# dnf install -y epel-release

VirtualBox RPM packages are available at https://www.virtualbox.org/wiki/Linux_Downloads.

Oracle VirtualBox Downloads
Oracle VirtualBox Downloads

Besides that Vendor also provides an official yum repository for Red Hat based Linux distros.

You can download virtualbox.repo file and place it in /etc/yum.repos.d directory for immediate addition to dnf repolist.

# wget https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
--2022-10-28 21:46:47--  https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo
Resolving download.virtualbox.org (download.virtualbox.org)... 23.36.48.85
Connecting to download.virtualbox.org (download.virtualbox.org)|23.36.48.85|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 259 [text/plain]
Saving to: ‘/etc/yum.repos.d/virtualbox.repo’

/etc/yum.repos.d/vi 100%[===================>]     259  --.-KB/s    in 0s

2022-10-28 21:46:49 (875 KB/s) - ‘/etc/yum.repos.d/virtualbox.repo’ saved [259/259]

You have added new yum repositories, therefore, you should rebuild your yum cache now.

# dnf makecache
Extra Packages for Enterprise Linux 9 - x86_64  658 kB/s |  11 MB     00:16
Rocky Linux 9 - BaseOS                          990  B/s | 3.6 kB     00:03
Rocky Linux 9 - AppStream                       1.9 kB/s | 3.6 kB     00:01
Rocky Linux 9 - Extras                          873  B/s | 2.9 kB     00:03
Oracle Linux / RHEL / CentOS-9 / x86_64 - Virtu 174  B/s | 181  B     00:01
Oracle Linux / RHEL / CentOS-9 / x86_64 - Virtu 1.3 kB/s | 1.7 kB     00:01
Importing GPG key 0x98AB5139:
 Userid     : "Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>"
 Fingerprint: 7B0F AB3A 13B9 0743 5925 D9C9 5442 2A4B 98AB 5139
 From       : https://www.virtualbox.org/download/oracle_vbox.asc
Is this ok [y/N]: y
Oracle Linux / RHEL / CentOS-9 / x86_64 - Virtu  36 kB/s |  33 kB     00:00
Metadata cache created.

Install VirtualBox Prerequisites

You have successfully setup required yum repositories on your Rocky Linux server. Therefore, you can now easily install all VirtualBox prerequisites by executing a single dnf command.

# dnf -y install kernel-devel kernel-headers glibc-headers glibc-devel binutils libgomp make patch gcc dkms

Install VirtualBox on Rocky Linux 9

Search for the available versions of VirtualBox by using dnf command.

# dnf search virtualbox
Last metadata expiration check: 0:07:29 ago on Fri 28 Oct 2022 09:49:34 PM CDT.
====================== Name & Summary Matched: virtualbox ======================
VirtualBox-6.1.x86_64 : Oracle VM VirtualBox
VirtualBox-7.0.x86_64 : Oracle VM VirtualBox

You can now install VirtualBox 7.0 on your Linux server by executing following command.

# dnf install -y VirtualBox-7.0

The VirtualBox installation process creates a systemd unit vboxdrv.service.

Check the status of vboxdrv.service.

# systemctl status vboxdrv.service
● vboxdrv.service - VirtualBox Linux kernel module
Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: di>
Active: active (exited) since Fri 2022-10-28 22:07:30 CDT; 2min 12s ago
Process: 718 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, s>
CPU: 30.588s

Oct 28 22:06:35 virtualbox-01.centlinux.com systemd[1]: Starting VirtualBox Lin>
Oct 28 22:07:11 virtualbox-01.centlinux.com vboxdrv.sh[718]: vboxdrv.sh: Starti>
Oct 28 22:07:30 virtualbox-01.centlinux.com vboxdrv.sh[899]: VirtualBox service>
Oct 28 22:07:30 virtualbox-01.centlinux.com systemd[1]: Started VirtualBox Linu>

VirtualBox 7.0 has been successfully installed on your Rocky Linux 9 machine.

Installing VirtualBox Extension Pack

VirtualBox extension pack extends the VirtualBox support for VirtualBox RDP, disk encryption, NVMe and PXE boot for Intel cards.

You can download VirtualBox 7.0 Extension Pack for your preferred Linux distribution from VirtualBox website.

Alternatively, you can use wget command to download VirtualBox Extension Pack direct from Linux commandline.

# cd /tmp
# wget https://download.virtualbox.org/virtualbox/7.0.2/Oracle_VM_VirtualBox_Extension_Pack-7.0.2.vbox-extpack
--2022-10-28 22:12:52--  https://download.virtualbox.org/virtualbox/7.0.2/Oracle_VM_VirtualBox_Extension_Pack-7.0.2.vbox-extpack
Resolving download.virtualbox.org (download.virtualbox.org)... 104.119.104.89
Connecting to download.virtualbox.org (download.virtualbox.org)|104.119.104.89|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18515967 (18M) [text/plain]
Saving to: ‘Oracle_VM_VirtualBox_Extension_Pack-7.0.2.vbox-extpack’

Oracle_VM_VirtualBo 100%[===================>]  17.66M  1.22MB/s    in 15s

2022-10-28 22:13:08 (1.19 MB/s) - ‘Oracle_VM_VirtualBox_Extension_Pack-7.0.2.vbox-extpack’ saved [18515967/18515967]

Now, install VirtualBox extension pack by executing following Linux command.

# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.2.vbox-extpack
VirtualBox Extension Pack Personal Use and Evaluation License (PUEL)

<VirtualBox License Agreement>

Do you agree to these license terms and conditions (y/n)? y

License accepted. For batch installation add
--accept-license=33d7284dc4a0ece381196fda3cfe2ed0e1e8e7ed7f27b9a9ebc4ee22e24bd23c
to the VBoxManage command line.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".

VirtualBox 7.0 Extension Pack has been installed on your Rocky Linux server.

Although, it is quiet convenient to use VirtualBox in a Graphical User Interface (GUI). But you can also manage your VirtualBox environment on a headless server from Linux commandline (CLI). For this purpose, VirtualBox provides a set of commands prefixed with vbox*.

Final Thoughts

Congratulations on successfully learn how to install VirtualBox on Rocky Linux 9! With VirtualBox up and running, you can now create and manage virtual machines, allowing you to run multiple operating systems simultaneously on your Linux environment. This setup enhances your flexibility for testing, development, and running different applications. Embrace the power of virtualization and take your productivity to the next level. Happy virtualizing! If you want to learn more about Oracle VirtualBox, then you should read VirtualBox Made Easy: Virtualize Your Environment with Ease (Computers Made Easy) (PAID LINK)by James Bernstein.

2 thoughts on “How to install VirtualBox on Rocky Linux 9”

Leave a Comment