Skip to content

Commit 118cb30

Browse files
authored
Create virtualbox guide
VirtualBox Guide for Firecracker Guide to switch from VMWare to VirtualBox. Signed-off-by: Amber Liu <[email protected]>
1 parent 1d5ee0e commit 118cb30

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

docs/virtualbox

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
## VirtualBox Setup for Firecracker
2+
3+
This guide shows how to use **VirtualBox** (GPL-licensed, free for all uses) combined with **Vagrant** (source-available, BSL 1.1) to automate the creation of a **nested-virtualization–capable** Linux VM for Firecracker development on macOS (Intel), Windows, or Linux hosts. It replaces ad hoc VMware Fusion setups with a **reproducible**, **version-controlled** workflow that anyone can run with a single `vagrant up`.
4+
5+
---
6+
7+
## Prerequisites
8+
9+
- **Host CPU**: Intel with VT-x or AMD with AMD-V enabled
10+
- **Host OS**:
11+
- **macOS (Intel)** 10.12–Sonoma (Full VirtualBox support; early Apple Silicon in VirtualBox 7.1.8+)
12+
- **Windows** 7–11 (Disable Hyper-V on Windows 10/11)
13+
- **Linux** with VirtualBox installed
14+
- **Software**:
15+
- **VirtualBox 7.1.x** (GPL v3 core)
16+
- **Vagrant 2.4+** (BSL 1.1 source-available)
17+
- **Box**: `bento/ubuntu-24.04`
18+
19+
---
20+
21+
## 1. Enable Hardware Virtualization
22+
23+
1. **Reboot into BIOS/UEFI** (common keys: F2, Del, Esc)
24+
2. Navigate to **Advanced → CPU Configuration**
25+
3. **Intel**: Enable **Intel VT-x (VMX)**
26+
4. **AMD**: Enable **SVM Mode (AMD-V)**
27+
5. **Save & Exit** (often F10)
28+
6. **Verify** on host:
29+
- **Linux**:
30+
```bash
31+
grep -Eoc '(vmx|svm)' /proc/cpuinfo
32+
```
33+
- **Windows**: Task Manager → Performance → **Virtualization: Enabled**
34+
35+
---
36+
37+
## 2. Apple Silicon Note
38+
39+
Apple Silicon (M1/M2) uses **ARM EL2** via the Hypervisor.framework and **does not** support nested virtualization until **macOS 15 “Sequoia”** on **M3+** hardware. Until then, use an Intel/AMD host for reliable nested VT-x/AMD-V.
40+
41+
---
42+
43+
## 3. Why VirtualBox + Vagrant?
44+
45+
- **VirtualBox** (GPL v3 core) is free for personal, educational, **and commercial** use; nested VT-x/AMD-V passthrough is part of the core package
46+
- **Vagrant** (BSL 1.1) automates VM provisioning via a single `Vagrantfile`, ensuring consistency across macOS, Windows, and Linux
47+
- **Nested Virtualization**: VirtualBox ≥ 6.1 supports `--nested-hw-virt on`, exposing VT-x/AMD-V to guests so KVM (and Firecracker) runs inside the VM
48+
- **Reproducibility**: Teammates and CI pipelines simply run `vagrant up` to spin up identical environments
49+
50+
---
51+
52+
## 4. Automated VM Setup with Vagrant
53+
54+
Create a `Vagrantfile` in your Firecracker project root:
55+
56+
```ruby
57+
# Vagrantfile: Firecracker Dev VM with Nested Virtualization
58+
59+
Vagrant.configure("2") do |config|
60+
# Base Ubuntu 24.04 LTS box
61+
config.vm.box = "bento/ubuntu-24.04"
62+
63+
# SSH key forwarding & synced folder
64+
config.ssh.forward_agent = true
65+
config.vm.synced_folder "./", "/home/vagrant/firecracker"
66+
67+
# Port forwarding & LAN access
68+
config.vm.network "forwarded_port", guest: 9090, host: 9090
69+
config.vm.network "public_network"
70+
71+
# VM resources
72+
cpus = 2
73+
memory = 8192
74+
75+
# VirtualBox provider: enable nested VT-x/AMD-V
76+
config.vm.provider :virtualbox do |vb|
77+
vb.customize ["modifyvm", :id, "--nested-hw-virt", "on"]
78+
vb.cpus = cpus
79+
vb.memory = memory
80+
end
81+
82+
# Provisioning steps
83+
config.vm.provision "update", type: "shell", run: "once" do |sh|
84+
sh.inline = "sudo apt-get update"
85+
end
86+
87+
config.vm.provision "deps", type: "shell", run: "once" do |sh|
88+
sh.inline = <<~SHELL
89+
sudo apt-get install -y \
90+
build-essential git pkg-config libssl-dev libelf-dev \
91+
cmake curl unzip llvm clang
92+
SHELL
93+
end
94+
95+
config.vm.provision "rust", type: "shell", run: "once" do |sh|
96+
sh.inline = <<~SHELL
97+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
98+
sh -s -- -y --default-toolchain stable
99+
source $HOME/.cargo/env
100+
SHELL
101+
end
102+
103+
config.vm.provision "kvm", type: "shell", run: "once" do |sh|
104+
sh.inline = <<~SHELL
105+
sudo apt-get install -y qemu-kvm libvirt-daemon-system \
106+
libvirt-clients bridge-utils
107+
sudo adduser vagrant libvirt
108+
sudo adduser vagrant kvm
109+
SHELL
110+
end
111+
112+
config.vm.provision "firecracker", type: "shell", run: "once" do |sh|
113+
sh.inline = <<~SHELL
114+
cd /home/vagrant/firecracker
115+
[ -d firecracker ] || git clone https://github.com/firecracker-microvm/firecracker.git
116+
cd firecracker
117+
source $HOME/.cargo/env
118+
tools/devtool build
119+
tools/devtool test
120+
SHELL
121+
end
122+
end

0 commit comments

Comments
 (0)