···11# dflybsd-up ≽༏≼
2233A convenient CLI tool to quickly spin up DragonflyBSD virtual machines using
44-QEMU with sensible defaults.
44+QEMU with sensible defaults. Includes comprehensive VM management capabilities
55+with database tracking, background execution, and flexible networking options.
5667
78···2324- **🗃️ VM Management**: Track and manage multiple virtual machines with database
2425 storage
2526- **🌐 Bridge Networking**: Support for bridge networking configurations
2626-- **🔍 VM Inspection**: List, start, stop, and inspect virtual machines
2727+- **🔍 VM Inspection**: List, start, stop, restart, and inspect virtual machines
2828+- **📋 VM Management**: Remove VMs, view logs with follow mode, and background
2929+ execution
2730- **🏷️ Automatic MAC Assignment**: Unique MAC addresses generated for each VM
3131+- **🔧 Custom Port Forwarding**: Flexible port mapping with multiple forwards
3232+ support
3333+- **🔄 Background Mode**: Run VMs detached from terminal with logging support
28342935## 📋 Prerequisites
3036···7177# Use bridge networking
7278dflybsd-up --bridge br0
73798080+# Run VM in background (detached mode)
8181+dflybsd-up --detach
8282+8383+# Custom port forwarding (forward host port 8080 to guest port 80)
8484+dflybsd-up --port-forward 8080:80
8585+8686+# Multiple port forwards
8787+dflybsd-up --port-forward 8080:80,3000:3000
8888+7489# Combine options
7590dflybsd-up 6.4.2 \
7691 --cpus 4 \
···7893 --image dragonfly.qcow2 \
7994 --disk-format qcow2 \
8095 --size 50G \
8181- --bridge br0
9696+ --detach \
9797+ --port-forward 2222:22,8080:80
8298```
839984100### VM Management Commands
···9210893109# Start a previously created VM
94110dflybsd-up start my-vm
111111+112112+# Start a VM in background (detached mode)
113113+dflybsd-up start my-vm --detach
9511496115# Stop a running VM
97116dflybsd-up stop my-vm
98117118118+# Restart a VM
119119+dflybsd-up restart my-vm
120120+121121+# Remove a VM (delete from database)
122122+dflybsd-up rm my-vm
123123+124124+# View VM logs
125125+dflybsd-up logs my-vm
126126+127127+# Follow VM logs in real-time
128128+dflybsd-up logs my-vm --follow
129129+99130# Inspect VM details
100131dflybsd-up inspect my-vm
101132```
102133103134## ⚙️ Options
104135105105-| Option | Short | Description | Default |
106106-| --------------- | ----- | ------------------------------------ | ----------------------- |
107107-| `--output` | `-o` | Output path for downloaded ISO | Auto-generated from URL |
108108-| `--cpu` | `-c` | CPU type to emulate | `host` |
109109-| `--cpus` | `-C` | Number of CPU cores | `2` |
110110-| `--memory` | `-m` | Amount of memory for VM | `2G` |
111111-| `--image` | `-i` | Path to VM disk image | None |
112112-| `--disk-format` | | Disk image format (qcow2, raw, etc.) | `raw` |
113113-| `--size` | | Size of disk image to create | `20G` |
114114-| `--bridge` | `-b` | Network bridge name for networking | None (uses NAT) |
136136+| Option | Short | Description | Default |
137137+| ---------------- | ----- | ------------------------------------------- | ----------------------- |
138138+| `--output` | `-o` | Output path for downloaded ISO | Auto-generated from URL |
139139+| `--cpu` | `-c` | CPU type to emulate | `host` |
140140+| `--cpus` | `-C` | Number of CPU cores | `2` |
141141+| `--memory` | `-m` | Amount of memory for VM | `2G` |
142142+| `--image` | `-i` | Path to VM disk image | None |
143143+| `--disk-format` | | Disk image format (qcow2, raw, etc.) | `raw` |
144144+| `--size` | | Size of disk image to create | `20G` |
145145+| `--bridge` | `-b` | Network bridge name for networking | None (uses NAT) |
146146+| `--detach` | `-d` | Run VM in the background | `false` |
147147+| `--port-forward` | `-p` | Custom port forwarding (hostPort:guestPort) | `2222:22` |
115148116149## 🔢 Version Format
117150···138171139172This enables proper console redirection to your terminal.
140173141141-## �️ Virtual Machine Management
174174+## 🔍 VM Management & Background Execution
175175+176176+### Background Mode (Detached)
177177+178178+Run VMs in the background without blocking your terminal:
179179+180180+```bash
181181+# Create and run VM in background
182182+dflybsd-up --detach
183183+184184+# Start existing VM in background
185185+dflybsd-up start my-vm --detach
186186+187187+# When running in background, you can:
188188+dflybsd-up logs my-vm --follow # View real-time logs
189189+dflybsd-up stop my-vm # Stop the VM
190190+dflybsd-up restart my-vm # Restart the VM
191191+```
192192+193193+### VM Lifecycle Management
194194+195195+- **Automatic Tracking**: Each VM is assigned a unique name and tracked in a
196196+ local SQLite database
197197+- **Persistent State**: VM configurations are preserved between sessions
198198+- **Status Monitoring**: Track running and stopped VMs with process IDs
199199+- **Resource Information**: View CPU, memory, disk, and network configurations
200200+ for each VM
201201+- **Log Management**: Each VM maintains its own log file for debugging and
202202+ monitoring
203203+204204+## 🗃️ Virtual Machine Management
142205143206The tool now includes database-backed VM management, allowing you to track and
144207manage multiple virtual machines:
···155218### VM Commands
156219157220- `ps` - List virtual machines (use `--all` to include stopped VMs)
158158-- `start <vm-name>` - Start a previously created VM
221221+- `start <vm-name>` - Start a previously created VM (use `--detach` to run in
222222+ background)
159223- `stop <vm-name>` - Stop a running VM
224224+- `restart <vm-name>` - Restart a VM (stop and start again)
225225+- `rm <vm-name>` - Remove a VM from the database (does not delete disk images)
226226+- `logs <vm-name>` - View VM logs (use `--follow` for real-time logs)
160227- `inspect <vm-name>` - View detailed VM information
161228162229## 🌐 Networking Options
···165232166233By default, VMs use QEMU's user-mode networking with port forwarding:
167234168168-- Host port 2222 → Guest port 22 (SSH)
235235+- Host port 2222 → Guest port 22 (SSH) by default
236236+- Custom port forwarding available with `--port-forward` option
169237- No additional configuration required
170238- Works without root privileges
239239+240240+#### Custom Port Forwarding
241241+242242+You can specify custom port forwarding rules:
243243+244244+```bash
245245+# Forward host port 8080 to guest port 80
246246+dflybsd-up --port-forward 8080:80
247247+248248+# Multiple port forwards (comma-separated)
249249+dflybsd-up --port-forward 8080:80,3000:3000,2222:22
250250+251251+# Use with other options
252252+dflybsd-up 6.4.2 --port-forward 8080:80 --memory 4G
253253+```
171254172255### Bridge Networking
173256···206289207290### NAT Networking (Default)
208291209209-The VM automatically forwards host port 2222 to guest port 22. After configuring
210210-SSH in your DragonflyBSD installation:
292292+The VM automatically forwards host port 2222 to guest port 22 by default. You
293293+can customize port forwarding with the `--port-forward` option. After
294294+configuring SSH in your DragonflyBSD installation:
211295212296```bash
297297+# Default SSH access (2222:22 forwarding)
213298ssh -p 2222 user@localhost
299299+300300+# Custom port forwarding
301301+dflybsd-up --port-forward 2200:22
302302+ssh -p 2200 user@localhost
303303+304304+# Access other services with custom forwarding
305305+dflybsd-up --port-forward 2222:22,8080:80
306306+# SSH: ssh -p 2222 user@localhost
307307+# HTTP: http://localhost:8080
214308```
215309216310### Bridge Networking