Virtualbox For Dummies
Virtualbox For Dummies
Virtualbox For Dummies
by Simon Coter
and Simon Hayler
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
VirtualBox® For Dummies®, Oracle® Special Edition
Published by
John Wiley & Sons, Inc.
111 River St.
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2021 by John Wiley & Sons, Inc., Hoboken, New Jersey
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by
any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted
under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of
the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department,
John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online
at http://www.wiley.com/go/permissions.
Trademarks: Wiley, For Dummies, the Dummies Man logo, The Dummies Way, Dummies.com, Making
Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons,
Inc. and/or its affiliates in the United States and other countries, and may not be used without written
permission. Oracle, Java, MySQL, and VirtualBox are registered trademarks of Oracle and/or its affiliates.
All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated
with any product or vendor mentioned in this book.
Publisher’s Acknowledgments
Some of the people who helped bring this book to market include the following:
Development Editor: Business Development Representative:
Rebecca Senninger William Hull
Acquisition Editor: Ashley Coffey Production Editor:
Tamilmani Varadharaj
Editorial Manager: Rev Mengle
Special Help: Faithe Wempen
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Table of Contents
INTRODUCTION ............................................................................................... 1
About This Book ................................................................................... 1
Foolish Assumptions............................................................................ 2
Icons Used in This Book....................................................................... 2
Beyond the Book .................................................................................. 2
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Introduction
E
ver wish you could run more than one operating system on a
single hardware platform? Oracle VM VirtualBox enables
that, and a whole lot more.
In this book, you learn the basics of virtualization, and see how
VirtualBox enables it. Then you find out how using VirtualBox
features such as encryption, automation, and packaging for the
cloud address many of the challenges of modern application
development.
Introduction 1
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Foolish Assumptions
In writing this book, we’ve made some assumptions about who
will be reading it. Mainly we assume you work in IT in a pro-
fessional capacity such as an application developer, architect,
or development operations manager. It’s also possible that you
just love technology and want to learn how to get more from
VirtualBox.
This icon points out the key takeaways that you’ll want to file
away in your mind for later recall.
When you see this icon, look for friendly advice for sidestepping
pitfalls.
This icon points out bright ideas and best practices that can
help your organization make the most out of automation for
cross-platform virtualization.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
IN THIS CHAPTER
» Getting to know VirtualBox
Chapter 1
Unlocking VirtualBox
Introducing VirtualBox
With thousands of downloads each day, VirtualBox is the world’s
most popular free and open source, cross-platform virtualization
software. It’s based on vibrant community participation com-
bined with world-class development and support by Oracle.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Linux on your Windows PC, and so on, all alongside your existing
applications. You can install and run as many virtual machines
as you like. The only practical limits are disk space and memory.
Here are some of the cool things that VirtualBox makes possible:
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
LEARNING SOME LINGO
Here are some key terms that will be popping up as you go along.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Here are some of the key features and benefits that VirtualBox
offers.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Remote machine display: You can access your virtual machines
remotely from anywhere that has Internet access via the Virtual-
Box Remote Desktop Extension (VRDE). This extension supports
the Remote Desktop Protocol (RDP) originally built into Micro-
soft Windows, with special additions for full client USB support.
VirtualBox VRDE also supports Winlogon authentication on
Windows, pluggable authentication modules (PAM) on Linux, and
enables remote access to USB ports over RDP.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Virtual machine clone: You can make clones of virtual machines.
You can also retain the hardware UUID, MAC address policy, and
disk image names — or not, your choice.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
HASHICORP VAGRANT
HashiCorp Vagrant is a tool for building and managing virtual
machines on VirtualBox in a single workflow. With an easy-to-use
workflow and focus on automation, Vagrant lowers development
environment setup time, increases production parity, and makes the
“works on my machine” excuse a relic of the past. Vagrant features
prominently in Chapter 2 of this book, so you may want to go ahead
and install it. You can find it at https://www.vagrantup.com/.
After you create your first virtual machine, you can then run it and
explore other options, including how to access the console and
how to interact with your virtual machine. Your virtual machine
needs specific settings defined such as CPU, memory, displays,
network, and storage. For these settings, refer to the VirtualBox
User Manual.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
Chapter 2 discusses in detail, and with examples, some options
for using encryption and automation with Vagrant. We provide
some sample code that shows the steps to enable these features
and how to use them with your own virtual machines.
VIRTUALBOX ENTERPRISE
Organizations can streamline operations by purchasing VirtualBox
Enterprise, which includes commercial licenses and technical support
and provides:
• 24x7 support from Oracle for the Base Package and Extension
Pack
• Multiple remote desktop connections (VRDP) to virtual machines
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
IN THIS CHAPTER
» Leveraging built-in virtual machine
encryption
Chapter 2
Automating with
Encryption
W
e all have data we want to keep private and secure both
for personal and business use. Exposing sensitive data
to others could lead to financial, personal, and contrac-
tual implications. Encryption puts data in a form that is unreada-
ble to anyone without authorization.
In this chapter, you find out how virtual machines are encrypted
in VirtualBox and you learn how to automate virtual machine
creation — and how to include encryption in that automation.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
keys (DEK). Current thinking suggests that the larger the key the
more secure the encryption. The DEK is stored encrypted and is
decrypted when the virtual machine starts by entering a password.
You can configure encryption using either the GUI or the CLI (via
the VBoxManage command).
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
If you later want to remove encryption, go back to this same
section in Settings and deselect the Enable Disk Encryption
check box.
The command to use is VBoxManage, and here’s the syntax for it:
» The disk image file: You can supply either the disk UUID or
absolute path to the disk image file. If you run the following
command, it lists the disks, with UUID, and which virtual
machine it belongs to:
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
» Specifying the cipher: The --cipher <cipher id> option
can be either AES-XTS128-PLAIN64 or AES-XTS256-PLAIN64.
Here is an example of single disk, prompt for a password,
256-bit cipher, and a disk id of disk1:
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
When you export a virtual machine using the Open Virtualiza-
tion Format (OVF), encryption is removed before the export, and
you’re prompted to enter the password. See Chapter 3 to find out
how to export a virtual machine.
Vagrant basics
Infrastructure as code is the process of creating and managing com-
pute resources using machine-readable definition files. Vagrant,
by HashiCorp, is infrastructure as code that automates the process
of provisioning and configuring virtual machines using Virtual-
Box as its default virtual machine provider. A Vagrant Provider is
a hypervisor leveraged to run virtual machines.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
A Vagrantfile is created with the Oracle Linux 8 details
reusable for later projects.
4. Run the vagrant up command.
This command tells VirtualBox to create the Oracle Linux 8
virtual machine with NAT networking and automatically
generated ssh keys.
5. Run the vagrant ssh command.
You’re now in the Oracle Linux 8 virtual machine as the
vagrant user. Running sudo su - gives you the ability to get
to the root user.
This simple and repeatable process uses Oracle Linux base images
called Oracle Linux Vagrant Boxes. They’re available in Oracle Linux
versions 6, 7, and 8, and are designed to serve as a starting point.
Vagrant boxes
Vagrant uses boxes for its packaging format. These boxes can be
created from ISO images, provided there is a base configuration to
reference. The box approach enables any user on any operating sys-
tem supported by Vagrant to bring up an identical virtual machine.
You’ll want to study the Vagrantfile and its syntax more closely
before you start editing it. Here’s an example:
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
vb.memory = 5120
vb.name = "my-vm"
vb.cpus = 2
vb.customize ["modifyvm", :id, "--nested-hw-
virt", "on"]
vb.customize ["modifyvm", :id, "--nictype1",
"virtio"]
vb.customize ["modifyvm", :id, "--nictype2",
"virtio"]
vb.customize ["modifyvm", :id,
"--nicpromisc2", "allow-all"]
vb.customize ["modifyvm", :id, "--vram", "9"]
vb.customize ["modifyvm", :id,
"--graphicscontroller", "vmsvga"]
end
s.ssh.forward_agent = true
s.vm.box = "oraclelinux/7"
s.vm.box_url = "https://oracle.github.io/
vagrant-projects/boxes/oraclelinux/7.json"
s.vm.hostname = "olvm-mgr"
s.vm.network "private_network", ip:
"192.168.56.101", netmask: "255.255.255.0"
Vagrant plugins
Vagrant has some very useful plugins. For example, the reload
plugin enables you to add a reboot of a virtual machine into the
configuration flow. This is useful if you script, for example, an
update or package install that needs a reboot. Following a reboot,
the steps in the Vagrantfile continue to run enabling a single
configuration flow.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
required configuration and answer files. For example, you can run
scripts using the shell statement, move files using the file state-
ment, and schedule a reboot using the reload plugin. Here’s an
example:
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
IN THIS CHAPTER
» Leveraging Open Virtualization Format
(OVF) to export and import
Chapter 3
Packaging and Migrating
to the Cloud
I
n this chapter, you find out how to package virtual machines,
how to share these packages with other users, and how to
export to and import VMs from Oracle Cloud Infrastructure
(OCI). OCI is a set of complementary cloud services that enable
you to build and run a wide range of applications and services
in a highly available hosted environment. OCI offers high-
performance compute capabilities (as physical hardware
instances) and storage capacity in a flexible overlay virtual
network that is securely accessible from your on-premises
network.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
TRY ORACLE CLOUD FREE
You can build, test, and deploy applications for free using the
no-charge version of Oracle Cloud. You also get $300 of credits for
30 days to use on even more services, such as Container Engine for
Kubernetes, Analytics Cloud, and Data Integration.
OVF doesn’t care about the type of virtual disk files; the disk type
is left to the technology that exported the virtual machine. For
example, VirtualBox uses the VDI disk format (*.vdi) by default,
but it can also handle VMDK (*.vmdk) and VHD (*.vhd) formats.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
virtual machines can be imported into VirtualBox, edited, and
then exported back into test and production. This decouples the
need for expensive development environments and permanent
virtual private network development sessions for a home worker.
You can export your virtual machine from either the GUI or the
command line.
After you select the virtual machine to export via the GUI, you
have the option of Guided or Expert mode. Guided takes you
through the default flow to create your appliance, whereas Expert
enables you to attach additional information to your appliance,
referred to as Virtual System Settings: Product, Vendor, Descrip-
tion, and License. The License section is simply a statement users
agree to. It’s useful for providing a declaration of acceptance such
as “Yes, I agree to the usage of this appliance.”
» The default format is 1.0 OVF, but you can choose versions
0.9 or 2.0.
» File is the name and location of where the appliance will be
exported to; this can be changed.
» MAC address policy is set by default to include only NAT
network adapter MAC addresses. This is changeable to strip
out all MAC addresses or leave all in. You can use the default
setting unless you have a local script or network functions
that rely upon MAC addresses.
» The option of writing a manifest file is set by default. This
option writes all the VirtualBox specific information as part
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
of the appliance, enabling error checking on subsequent
imports.
» Including ISO image files isn’t set by default but can be
enabled if needed. Be aware that attached ISO images can
increase the overall size of the appliance, making upload and
download times longer.
As with the export flow, you have the option of Expert or Guided
mode. Guided mode asks for the location of the appliance, and
then displays the appliance settings such as CPU and adapter
details that can then be edited. Expert mode shows all the details
in one page.
For both modes, VirtualBox asks for the location to place the
virtual machine created from the appliance and the MAC address
policy. It also suggests changing the disk format to the preferred
VirtualBox VDI.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
OCI. To do this, you need an account with suitable access to OCI
as well as VirtualBox version 6.1 or higher. For further details on
integrating VirtualBox with OCI, refer to the documentation.
VirtualBox requirements
VirtualBox needs identity information to interact with OCI and
upload your virtual machine.
First you need to gather some information from your OCI pres-
ence. You can find the needed Oracle Cloud Identifier (OCID)
details from your account via the OCI console: User, Tenancy,
Region, and Compartment. The key_file and fingerprint need to
be generated on your host system; refer to the OCI documentation
for details.
From the VirtualBox user interface, open the File menu and
choose Cloud Profile Manager. Click Add to create a new profile.
After the profile is created, select it, click Properties, and fill in all
the pertinent details.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
» Configure a console connection or Remote Desktop Protocol
(RDP) access to the virtual machine.
» Install the virtual I/O drivers available for the virtual machine
operating system.
» Use either VMDK or QCOW2 as the disk format.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
IN THIS CHAPTER
» Compelling reasons to use VirtualBox
Chapter 4
Ten Reasons to Use
VirtualBox
W
hy do millions of people use VirtualBox? As the world’s
most popular open source, cross-platform virtualiza-
tion software, there are plenty of reasons. Here are ten
of the most compelling ones.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
» It simplifies quality assurance and testing. By using
a single physical device to test software on multiple OS
platforms and versions, VirtualBox enables software quality
assurance teams to simplify their environment and reduce
resources.
» It offers powerful hardware virtualization. VirtualBox
offers a wide range of virtual storage controllers, including
NVMe, SAS, SATA, SCSI, and IDE controllers. VirtualBox
utilizes an asynchronous I/O virtual disk subsystem to
achieve high performance while maintaining high data
integrity. It also offers a rich range of networking models,
including easy-to-use NAT networking, fully functional
bridged networking, and specialist internal and host-only
networking.
» Its virtual machines are secure and encrypted. VirtualBox
offers built-in encryption securing your data using the AES
algorithm 128-bit or 256-bit using XTS block cipher mode
data encryption keys (DEK).
» You can use it to provide secure remote access via
virtual machines. VirtualBox enables IT managers to
distribute desktop-based images to remote workers when a
VPN connection is considered insufficient. This capability
helps organizations increase security by implementing
restrictions defined by pre-built appliances.
» It’s easy to adopt. An easy-to-use GUI and a powerful CLI
make it easy for developers to work with multiple operating
systems on the same system. The command-line interface
also enables you to automate operations with Linux shell or
Windows PowerShell using the VBoxManage command.
» You can import and export virtual machines using OVF/
OVA standards. VirtualBox enables you to export and
import virtual machines by leveraging the standard Open
Virtualization Format. It also enables you to create and
distribute virtual machine appliances, so you can distribute
an application inside a virtual machine that will run on any
version of any supported OS.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
» You can automate secure virtual machine builds using
Vagrant or the VirtualBox Unattended Installation
feature. Using Vagrant boxes with VirtualBox or using
VirtualBox’s Unattended Installer within a script, you can
quickly provision development VMs with preconfigured
applications software and automate the release to
production.
» You can build a multitier demonstration system on a
single portable machine. VirtualBox enables you to create
a multitier solution with separated and isolated networking,
emulating complex production environments.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
These materials are © 2021 John Wiley & Sons, Inc. Any dissemination, distribution, or unauthorized use is strictly prohibited.
WILEY END USER LICENSE AGREEMENT
Go to www.wiley.com/go/eula to access Wiley’s ebook EULA.