VirtualBox
Printed from:
Oracle VirtualBox Comprehensive Cheatsheet
1. Installation and Initial Setup
Windows
123456# Download from official Oracle VirtualBox website
https://www.virtualbox.org/wiki/Downloads
# Silent installation with command line
VirtualBox-7.1.x-YYYYY-Win.exe -s
macOS
123456789# Install via Homebrew (Intel and Apple Silicon supported)
brew install --cask virtualbox
# Manual installation
1. Download .dmg from official website
2. Open and follow installation wizard
3. Allow kernel extension / system extension in System Settings > Privacy & Security
4. Reboot when prompted
Linux (Ubuntu/Debian)
123456789101112# Add Oracle VirtualBox repository (apt-key is deprecated; use signed-by)
sudo install -d -m 0755 /etc/apt/keyrings
wget -qO- https://www.virtualbox.org/download/oracle_vbox_2016.asc \
| sudo gpg --dearmor -o /etc/apt/keyrings/oracle-virtualbox-2016.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/oracle-virtualbox-2016.gpg] \
https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" \
| sudo tee /etc/apt/sources.list.d/virtualbox.list
# Install VirtualBox
sudo apt update
sudo apt install virtualbox-7.1
2. VirtualBox Manager Interface Navigation
Key Interface Elements
- Machine List: Left panel showing all configured VMs (with grouping support)
- Details / Tools Panel: Right side showing VM configuration, snapshots, logs
- Toolbar: Quick actions for VM management
- Global Tools: Welcome, Media Manager, Host Network Manager, Cloud Profile Manager, Activities, Extension Pack Manager
Keyboard Shortcuts
Ctrl+N: Create new virtual machineCtrl+A: Add an existing virtual machineCtrl+G: Global preferencesCtrl+S: VM settingsHost+F: Toggle full-screen (default Host key: Right Ctrl)
3. Virtual Machine Creation and Configuration
GUI Method
- Click "New" in VirtualBox Manager
- Enter VM name and select machine folder
- Select OS type and version
- (Optional) Provide ISO and enable Unattended Install to auto-provision guest user, password, and Guest Additions
- Allocate RAM and CPUs
- Create virtual hard disk (VDI by default)
- Dynamic or Fixed size
- Recommended: Dynamic allocation
CLI Method
12345678910# Create new VM (use --ostype to match the guest; see: VBoxManage list ostypes)
VBoxManage createvm --name "MyVM" --ostype "Ubuntu_64" --register
# Configure VM settings
VBoxManage modifyvm "MyVM" --memory 4096 --cpus 2 --firmware efi
VBoxManage createmedium disk --filename "MyVM.vdi" --size 50000 --format VDI
VBoxManage storagectl "MyVM" --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 0 --device 0 \
--type hdd --medium "MyVM.vdi"
Note:
VBoxManage createhdis a deprecated alias; prefercreatemedium disk.
4. Guest Operating System Installation
Installation Methods
-
ISO Image
- Download OS ISO
- Attach to the VM's optical drive
- Boot from ISO and follow standard installation
-
Unattended Installation (recommended for automation)
Bash1234567VBoxManage unattended install "MyVM" \ --iso=/path/to/ubuntu.iso \ --user=admin --password=secret \ --full-user-name="Admin" \ --install-additions --time-zone=UTC \ --locale=en_US --country=US -
Network Boot
Bash12VBoxManage modifyvm "MyVM" --boot1 net
5. VirtualBox Guest Additions Installation
Why Install?
- Better video resolution and dynamic resizing
- Shared clipboard
- Drag-and-drop support
- Seamless mouse integration
- Time synchronization and shared-folder support
Installation Steps
- Start the VM
- Devices > Insert Guest Additions CD Image
- Run the installer in the guest OS
- Windows: Execute
VBoxWindowsAdditions.exe - Linux: Run
sudo ./VBoxLinuxAdditions.run - Solaris: Use the included
.pkg
- Windows: Execute
Note: A native Guest Additions package for macOS guests is not supplied by Oracle.
CLI Installation (Linux guest)
1234sudo apt install build-essential dkms linux-headers-$(uname -r)
sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run
6. Storage Management
Add/Remove Storage Devices
1234567891011121314# Create a new virtual disk
VBoxManage createmedium disk --filename "extra_disk.vdi" --size 20000 --format VDI
# Attach the disk to a VM
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 1 --device 0 \
--type hdd --medium "extra_disk.vdi"
# Detach a storage device
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 1 --device 0 \
--type hdd --medium none
# Resize a dynamic VDI/VHD
VBoxManage modifymedium disk "extra_disk.vdi" --resize 40000
7. Network Configuration
Network Types
- NAT: Default, internet access via host
- NAT Network: Multiple VMs share a virtual NAT with inter-VM connectivity
- Bridged: Direct connection to the physical network
- Host-only: Private network between host and VMs
- Internal: VMs-only network (no host access)
- Cloud Network: Connect to an Oracle Cloud Infrastructure VCN
Network CLI Configuration
1234567891011# Set network adapter type
VBoxManage modifyvm "MyVM" --nic1 bridged
VBoxManage modifyvm "MyVM" --bridgeadapter1 "en0"
# NAT port forwarding (host 2222 -> guest 22)
VBoxManage modifyvm "MyVM" --natpf1 "ssh,tcp,,2222,,22"
# Create and use a NAT network
VBoxManage natnetwork add --netname natnet1 --network "10.0.2.0/24" --enable --dhcp on
VBoxManage modifyvm "MyVM" --nic1 natnetwork --nat-network1 natnet1
8. Snapshots and State Management
Creating Snapshots
- GUI: Machine > Take Snapshot
- CLI:
Bash1234567891011
VBoxManage snapshot "MyVM" take "Clean Install" --description "Fresh OS install" # List snapshots VBoxManage snapshot "MyVM" list # Restore snapshot (VM must be powered off) VBoxManage snapshot "MyVM" restore "Clean Install" # Delete (merge) a snapshot VBoxManage snapshot "MyVM" delete "Clean Install"
9. Shared Folders and Clipboard
Setup Shared Folders
- VM Settings > Shared Folders
- Add host directory
- Select "Auto-mount" and "Make Permanent"
CLI Shared Folder
123456VBoxManage sharedfolder add "MyVM" --name "Projects" \
--hostpath "/path/to/host/directory" --automount
# Enable bidirectional clipboard / drag-and-drop
VBoxManage modifyvm "MyVM" --clipboard-mode bidirectional --draganddrop bidirectional
10. USB Device Passthrough
Enable USB Support
- VM Settings > USB
- Select USB Controller version (USB 2.0/3.0 requires the Extension Pack)
- Add USB device filters
CLI USB Management
123456# List USB devices visible to the host
VBoxManage list usbhost
# Add a USB device filter
VBoxManage usbfilter add 0 --target "MyVM" --name "My USB Device" --vendorid 0x1234
11. Display and Video Settings
Configuration Options
- Video memory (VRAM)
- Graphics controller: VBoxSVGA (default for modern guests), VMSVGA (Linux), VBoxVGA (legacy)
- 3D acceleration
- Screen resolution
- Multiple monitor support
CLI Video Configuration
1234VBoxManage modifyvm "MyVM" --vram 128
VBoxManage modifyvm "MyVM" --graphicscontroller vboxsvga
VBoxManage modifyvm "MyVM" --accelerate-3d on
Note: 2D video acceleration was removed in VirtualBox 6.1 and is no longer available.
12. Command-line Interface (VBoxManage)
Essential Commands
123456789101112131415161718# List all VMs
VBoxManage list vms
# Start a VM headless
VBoxManage startvm "MyVM" --type headless
# Send ACPI shutdown
VBoxManage controlvm "MyVM" acpipowerbutton
# Force power off
VBoxManage controlvm "MyVM" poweroff
# Clone a VM
VBoxManage clonevm "MyVM" --name "MyVM-Clone" --register
# Show running VM info
VBoxManage showvminfo "MyVM" --machinereadable
13. Extension Pack Features
Install Extension Pack
1234567# Versions must match the installed VirtualBox release
wget https://download.virtualbox.org/virtualbox/7.1.x/Oracle_VirtualBox_Extension_Pack-7.1.x.vbox-extpack
# Install (accept license non-interactively)
sudo VBoxManage extpack install --accept-license=sha256 \
Oracle_VirtualBox_Extension_Pack-7.1.x.vbox-extpack
Key Features
- VirtualBox Remote Desktop Protocol (VRDP)
- USB 2.0 (EHCI) and USB 3.0 (xHCI) support
- Host webcam passthrough
- Disk image encryption (AES-XTS)
- Intel PXE boot ROM
- Cloud integration with Oracle Cloud Infrastructure
Licensing: Beginning with version 7.1, the Extension Pack is available under the Oracle VirtualBox Personal Use and Evaluation License (PUEL) for personal, educational, and evaluation use; commercial use requires a paid Oracle license. The base VirtualBox package remains GPLv3.
14. Import/Export Virtual Appliances
Export OVA
12VBoxManage export "MyVM" --output "MyVM.ova" --options manifest,nomacs
Import OVA
12VBoxManage import "MyVM.ova" --vsys 0 --vmname "ImportedVM"
Export to Oracle Cloud Infrastructure
1234VBoxManage export "MyVM" --output "MyVM.oci" \
--cloud 0 --cloudprofile "default" --cloudbucket "my-bucket" \
--cloudshape "VM.Standard.E4.Flex" --cloudlaunchmode emulated
15. Performance Optimization
Best Practices
- Allocate appropriate RAM and CPUs (avoid over-committing host resources)
- Use dynamic disk allocation for flexibility, fixed for raw speed
- Enable hardware virtualization (VT-x/AMD-V, nested paging)
- Install and keep Guest Additions updated
- Match the paravirtualization provider to the guest OS
Performance CLI Tuning
12345678910# Paravirt: 'kvm' for Linux, 'hyperv' for Windows, 'default' for auto
VBoxManage modifyvm "MyVM" --paravirtprovider kvm
# Nested paging and nested virtualization (host CPU support required)
VBoxManage modifyvm "MyVM" --nested-paging on
VBoxManage modifyvm "MyVM" --nested-hw-virt on
# Hot-pluggable CPUs
VBoxManage modifyvm "MyVM" --cpu-hotplug on
16. Troubleshooting Common Issues
Virtualization Issues
- Enable Intel VT-x/AMD-V in firmware (BIOS/UEFI)
- On Windows, disable conflicting Hyper-V/WSL2/Memory Integrity (or rely on the Hyper-V backend introduced in 6.1+; performance may be reduced)
- On Linux, ensure
vboxdrvkernel module is loaded:sudo /sbin/vboxconfig - On macOS, approve the Oracle system extension and reboot
Diagnostic Commands
12345678910# Show VirtualBox version
VBoxManage --version
# List host capabilities and properties
VBoxManage list hostinfo
VBoxManage list extpacks
# Inspect a VM's log
VBoxManage debugvm "MyVM" log --release
17. Scripting and Automation
Example Bash Script
12345678910111213141516#!/usr/bin/env bash
set -euo pipefail
VM_NAME="AutoVM"
ISO_PATH="/path/to/os.iso"
VBoxManage createvm --name "$VM_NAME" --ostype "Ubuntu_64" --register
VBoxManage modifyvm "$VM_NAME" --memory 4096 --cpus 2 --firmware efi --nic1 nat
VBoxManage createmedium disk --filename "$VM_NAME.vdi" --size 50000 --format VDI
VBoxManage storagectl "$VM_NAME" --name "SATA" --add sata --controller IntelAhci
VBoxManage storageattach "$VM_NAME" --storagectl "SATA" --port 0 --device 0 \
--type hdd --medium "$VM_NAME.vdi"
VBoxManage storageattach "$VM_NAME" --storagectl "SATA" --port 1 --device 0 \
--type dvddrive --medium "$ISO_PATH"
VBoxManage startvm "$VM_NAME" --type headless
Python (via the VirtualBox SDK / XPCOM/COM API)
123456import virtualbox
vbox = virtualbox.VirtualBox()
for m in vbox.machines:
print(m.name, m.state)
Cross-Platform Considerations
Host-Specific Nuances
- Windows: Hyper-V, Windows Hypervisor Platform, and Memory Integrity can conflict; the Hyper-V backend allows coexistence at reduced performance.
- macOS: Requires approval of Oracle's system extension. Apple Silicon support is developer preview only — expect limited guest compatibility and performance.
- Linux: Ensure matching
linux-headersanddkmsare installed sovboxdrvrebuilds after kernel upgrades. Secure Boot requires signing the module.
Conclusion
VirtualBox offers powerful Type-2 virtualization with flexible management through both GUI and CLI. Master these techniques to streamline your development, testing, and personal computing environments.
Pro Tip: Keep VirtualBox, the matching Extension Pack, and Guest Additions on the same version for best performance, security, and compatibility.
Continue Learning
Discover more cheatsheets to boost your productivity