VirtualBox
Updated: September 10, 2025Categories: Virtualization, Hosted
Printed from:
Oracle VirtualBox Comprehensive Cheatsheet
1. Installation and Initial Setup
Windows
Bash
123456# Download from official Oracle VirtualBox website
https://www.virtualbox.org/wiki/Downloads
# Silent installation with command line
VirtualBox-X.X.X-YYYYY-Win.exe -s
macOS
Bash
12345678# Install via Homebrew
brew install --cask virtualbox
# Manual installation
1. Download .dmg from official website
2. Open and follow installation wizard
3. Allow kernel extension in System Preferences > Security
Linux (Ubuntu/Debian)
Bash
12345678# Add Oracle VirtualBox repository
sudo add-apt-repository multiverse
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
# Install VirtualBox
sudo apt update
sudo apt install virtualbox
2. VirtualBox Manager Interface Navigation
Key Interface Elements
- Machine List: Left panel showing all configured VMs
- Details Panel: Right side showing VM configuration
- Toolbar: Quick actions for VM management
Keyboard Shortcuts
Ctrl+N: Create new virtual machineCtrl+M: Show/hide main toolbarCtrl+G: Global settingsCtrl+S: VM settings
3. Virtual Machine Creation and Configuration
GUI Method
- Click "New" in VirtualBox Manager
- Enter VM name
- Select OS type and version
- Allocate RAM
- Create virtual hard disk
- Dynamic or Fixed size
- Recommended: Dynamic allocation
CLI Method
Bash
123456789# Create new VM
VBoxManage createvm --name "MyVM" --ostype "Ubuntu_64" --register
# Configure VM settings
VBoxManage modifyvm "MyVM" --memory 4096 --cpus 2
VBoxManage createhd --filename "MyVM.vdi" --size 50000
VBoxManage storagectl "MyVM" --name "SATA Controller" --add sata
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "MyVM.vdi"
4. Guest Operating System Installation
Installation Methods
-
ISO Image
- Download OS ISO
- Mount in VM's optical drive
- Boot from ISO
- Follow standard installation process
-
Network Installation
Bash123# Example: Kick off network install VBoxManage modifyvm "MyVM" --boot1 net
5. VirtualBox Guest Additions Installation
Why Install?
- Better video resolution
- Shared clipboard
- Drag-and-drop support
- Seamless mouse integration
Installation Steps
- VM Running
- Devices > Insert Guest Additions CD Image
- Run installer in guest OS
- Windows: Execute .exe
- Linux: Run
./VBoxLinuxAdditions.run - macOS: Run .pkg installer
CLI Installation (Linux)
Bash
1234sudo apt install virtualbox-guest-additions-iso
sudo mount /usr/share/virtualbox/VBoxGuestAdditions.iso /mnt
sudo /mnt/VBoxLinuxAdditions.run
6. Storage Management
Add/Remove Storage Devices
Bash
123456789# Create new hard disk
VBoxManage createhd --filename "extra_disk.vdi" --size 20000
# Attach disk to VM
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium "extra_disk.vdi"
# Remove storage device
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium none
7. Network Configuration
Network Types
- NAT: Default, internet access
- Bridged: Direct network connection
- Host-only: Internal network
- Internal: VMs-only network
Network CLI Configuration
Bash
1234567# Set network adapter type
VBoxManage modifyvm "MyVM" --nic1 bridged
VBoxManage modifyvm "MyVM" --bridgeadapter1 "en0"
# Port forwarding
VBoxManage modifyvm "MyVM" --natpf1 "ssh,tcp,,2222,,22"
8. Snapshots and State Management
Creating Snapshots
- GUI: Machine > Take Snapshot
- CLI:
Bash12345678
VBoxManage snapshot "MyVM" take "Clean Install" # List snapshots VBoxManage snapshot "MyVM" list # Restore snapshot VBoxManage snapshot "MyVM" restore "Clean Install"
9. Shared Folders and Clipboard
Setup Shared Folders
- VM Settings > Shared Folders
- Add host directory
- Select "Auto-mount" and "Permanent"
CLI Shared Folder
Bash
12VBoxManage sharedfolder add "MyVM" --name "Projects" --hostpath "/path/to/host/directory"
10. USB Device Passthrough
Enable USB Support
- VM Settings > USB
- Select USB Controller version
- Add specific USB devices
CLI USB Management
Bash
123456# List USB devices
VBoxManage list usbhost
# Add USB filter
VBoxManage usbfilter add 0 --target "MyVM" --name "My USB Device" --vendorid 0x1234
11. Display and Video Settings
Configuration Options
- Video memory
- 2D/3D acceleration
- Screen resolution
- Multiple monitor support
CLI Video Configuration
Bash
123VBoxManage modifyvm "MyVM" --vram 128
VBoxManage modifyvm "MyVM" --accelerate3d on
12. Command-line Interface (VBoxManage)
Essential Commands
Bash
123456789101112# List all VMs
VBoxManage list vms
# Start VM headless
VBoxManage startvm "MyVM" --type headless
# Stop VM
VBoxManage controlvm "MyVM" poweroff
# Clone VM
VBoxManage clonevm "MyVM" --name "MyVM-Clone" --register
13. Extension Pack Features
Install Extension Pack
Bash
123456# Download from Oracle website
wget https://download.virtualbox.org/virtualbox/X.X.X/Oracle_VM_VirtualBox_Extension_Pack-X.X.X.vbox-extpack
# Install
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-X.X.X.vbox-extpack
Key Features
- Remote Desktop Protocol (RDP)
- USB 2.0/3.0 support
- PXE boot for Intel network cards
14. Import/Export Virtual Appliances
Export OVA
Bash
12VBoxManage export "MyVM" --output "MyVM.ova" --options manifest
Import OVA
Bash
12VBoxManage import "MyVM.ova" --vsys 0 --vmname "ImportedVM"
15. Performance Optimization
Best Practices
- Allocate appropriate RAM
- Use dynamic disk allocation
- Enable hardware virtualization
- Use latest Guest Additions
- Disable unnecessary services
Performance CLI Tuning
Bash
123VBoxManage modifyvm "MyVM" --paravirtprovider KVM
VBoxManage modifyvm "MyVM" --cpuhotplug on
16. Troubleshooting Common Issues
Virtualization Issues
- Enable Intel VT-x/AMD-V in BIOS
- Check kernel modules
- Verify CPU support
Diagnostic Commands
Bash
123456# Check VirtualBox version
VBoxManage --version
# Validate VM configuration
VBoxManage checkinitconfig "MyVM"
17. Scripting and Automation
Example Bash Script
Bash
1234567891011#!/bin/bash
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
VBoxManage createhd --filename "$VM_NAME.vdi" --size 50000
VBoxManage storagectl $VM_NAME --name "SATA" --add sata
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
Cross-Platform Considerations
Host-Specific Nuances
- Windows: Hyper-V conflicts
- macOS: Kernel extension requirements
- Linux: Kernel module dependencies
Conclusion
VirtualBox offers powerful virtualization with flexible management through both GUI and CLI. Master these techniques to streamline your development, testing, and personal computing environments.
Pro Tip: Always keep VirtualBox and Guest Additions updated for best performance and compatibility.
Continue Learning
Discover more cheatsheets to boost your productivity