···11# FreeBSD-Up ๐
2233-A simple, zero-configuration script to quickly boot FreeBSD ISO images using
44-QEMU. Perfect for testing, development, or learning FreeBSD without complex
55-setup.
33+A comprehensive FreeBSD virtual machine management tool built with Deno and
44+QEMU. Effortlessly create, manage, and run FreeBSD VMs with persistent state
55+tracking, network bridging support, and zero-configuration defaults.
6677
8899## โจ Features
10101111+### Core VM Management
1212+1313+- ๐๏ธ **Full VM lifecycle management**: Create, start, stop, and inspect VMs
1414+- ๐พ **Persistent state tracking**: SQLite database stores VM configurations and
1515+ state
1616+- ๐ **VM listing and monitoring**: View running and stopped VMs with detailed
1717+ information
1818+- ๐ **VM inspection**: Get detailed information about any managed VM
1919+- ๐ท๏ธ **Auto-generated VM names**: Unique identifiers for easy VM management
2020+2121+### Network & Storage
2222+2323+- ๐ **Flexible networking**: Support for both user-mode and bridge networking
2424+- ๐ **Network bridge support**: Automatic bridge creation and management with
2525+ `--bridge`
2626+- ๐ง **MAC address management**: Persistent MAC addresses for each VM
2727+- ๐พ **Persistent storage support**: Attach and auto-create disk images
2828+- ๐๏ธ **Multiple disk formats**: Support for qcow2, raw, and other disk formats
2929+- ๐ **Configurable disk sizes**: Specify disk image size on creation
3030+3131+### Convenience Features
3232+1133- ๐ **Download and boot from URLs**: Automatically downloads ISO images from
1234 remote URLs
1335- ๐ **Local file support**: Boot from local ISO files
···1739 (FreeBSD 14.3-RELEASE)
1840- โก **Zero configuration**: Works out of the box with sensible defaults
1941- ๐ฅ๏ธ **Serial console**: Configured for headless operation with stdio console
2020-- ๐ **Network ready**: Pre-configured with SSH port forwarding (host:2222 โ
2121- guest:22)
2242- ๐พ **Smart caching**: Automatically skips re-downloading existing ISO files
2343- ๐ **Help support**: Built-in help with `--help` or `-h` flags
2444- โ๏ธ **Configurable VM options**: Customize CPU type, core count, memory
2525- allocation, and persistent storage
2626-- ๐พ **Persistent storage support**: Attach disk images for data persistence
2727-- ๐๏ธ **Multiple disk formats**: Support for qcow2, raw, and other disk formats
4545+ allocation
2846- ๐ **Enhanced CLI**: Powered by [Cliffy](http://cliffy.io/) for robust
2947 command-line parsing
3048···101119freebsd-up /path/to/your/freebsd.iso
102120```
103121122122+### VM Management Commands
123123+124124+List all running VMs:
125125+126126+```bash
127127+freebsd-up ps
128128+```
129129+130130+List all VMs (including stopped):
131131+132132+```bash
133133+freebsd-up ps --all
134134+```
135135+136136+Start a specific VM:
137137+138138+```bash
139139+freebsd-up start vm-name
140140+```
141141+142142+Stop a specific VM:
143143+144144+```bash
145145+freebsd-up stop vm-name
146146+```
147147+148148+Inspect VM details:
149149+150150+```bash
151151+freebsd-up inspect vm-name
152152+```
153153+154154+freebsd-up /path/to/your/freebsd.iso
155155+156156+````
104157### Customize VM Configuration
105158106106-Specify custom CPU type, core count, memory allocation, and persistent storage:
159159+Specify custom CPU type, core count, memory allocation, persistent storage, and networking:
107160108161```bash
109162# Custom CPU and memory
···115168# Attach a disk image for persistent storage
116169freebsd-up --drive ./freebsd-disk.img --disk-format qcow2 14.3-RELEASE
117170171171+# Create disk image with specific size
172172+freebsd-up --drive ./freebsd-disk.qcow2 --disk-format qcow2 --size 50G 14.3-RELEASE
173173+174174+# Use bridge networking (requires sudo)
175175+freebsd-up --bridge br0 14.3-RELEASE
176176+118177# Download to specific location
119178freebsd-up --output ./downloads/freebsd.iso 15.0-BETA3
120179121180# Combine all options
122122-freebsd-up --cpu qemu64 --cpus 2 --memory 1G --drive ./my-disk.qcow2 --disk-format qcow2 --output ./my-freebsd.iso
123123-```
181181+freebsd-up --cpu qemu64 --cpus 2 --memory 1G --drive ./my-disk.qcow2 --disk-format qcow2 --size 30G --bridge br0 --output ./my-freebsd.iso
182182+````
124183125184### Get Help
126185···142201143202FreeBSD-Up supports several command-line options for customization:
144203204204+### VM Configuration Options
205205+145206- `-c, --cpu <type>` - CPU type to emulate (default: `host`)
146207- `-C, --cpus <number>` - Number of CPU cores (default: `2`)
147208- `-m, --memory <size>` - Amount of memory for the VM (default: `2G`)
148209- `-d, --drive <path>` - Path to VM disk image for persistent storage
149210- `--disk-format <format>` - Disk image format: qcow2, raw, etc. (default:
150211 `raw`)
212212+- `-s, --size <size>` - Size of disk image to create if it doesn't exist
213213+ (default: `20G`)
214214+215215+### Network Options
216216+217217+- `-b, --bridge <name>` - Name of the network bridge to use (e.g., br0)
218218+219219+### File Options
220220+151221- `-o, --output <path>` - Output path for downloaded ISO files
222222+223223+### Management Commands
224224+225225+- `ps [--all]` - List running VMs (use --all to include stopped VMs)
226226+- `start <vm-name>` - Start a specific VM by name
227227+- `stop <vm-name>` - Stop a specific VM by name
228228+- `inspect <vm-name>` - Show detailed information about a VM
229229+230230+### Help Options
231231+152232- `-h, --help` - Show help information
153233- `-V, --version` - Show version information
154234···167247# Attach a persistent disk image
168248freebsd-up --drive ./freebsd-storage.qcow2 --disk-format qcow2 14.3-RELEASE
169249250250+# Create a larger disk image automatically
251251+freebsd-up --drive ./freebsd-big.qcow2 --disk-format qcow2 --size 100G 14.3-RELEASE
252252+253253+# Use bridge networking for better network performance
254254+freebsd-up --bridge br0 14.3-RELEASE
255255+170256# Save ISO to specific location
171257freebsd-up --output ./isos/freebsd.iso https://example.com/freebsd.iso
172258173173-# Combine multiple options with persistent storage
174174-freebsd-up --cpu host --cpus 4 --memory 8G --drive ./vm-disk.qcow2 --disk-format qcow2 --output ./downloads/ 14.3-RELEASE
259259+# Combine multiple options with bridge networking and persistent storage
260260+freebsd-up --cpu host --cpus 4 --memory 8G --drive ./vm-disk.qcow2 --disk-format qcow2 --size 50G --bridge br0 --output ./downloads/ 14.3-RELEASE
261261+262262+# List all VMs (including stopped ones)
263263+freebsd-up ps --all
264264+265265+# Start a previously created VM
266266+freebsd-up start my-freebsd-vm
267267+268268+# Stop a running VM
269269+freebsd-up stop my-freebsd-vm
270270+271271+# Get detailed information about a VM
272272+freebsd-up inspect my-freebsd-vm
175273```
176274177275## ๐ฅ๏ธ Console Setup
···197295- **Cores**: 2 virtual CPUs (configurable with `--cpus`)
198296- **Storage**: ISO-only by default; optional persistent disk (configurable with
199297 `--drive`)
200200-- **Network**: User mode networking with SSH forwarding
298298+- **Network**: User mode networking with SSH forwarding (host:2222 โ guest:22)
299299+ or bridge networking with `--bridge`
201300- **Console**: Enhanced serial console via stdio with proper signal handling
202301- **Default Version**: FreeBSD 14.3-RELEASE (when no arguments provided)
302302+- **State Management**: Persistent VM state stored in SQLite database
303303+- **Auto-naming**: VMs get unique names for easy management
304304+305305+### Networking Modes
306306+307307+FreeBSD-Up supports two networking modes:
308308+309309+1. **User Mode (Default)**: Port forwarding for SSH access (host:2222 โ
310310+ guest:22)
311311+2. **Bridge Mode**: Direct network access via bridge interface (requires
312312+ `--bridge` and sudo)
313313+314314+### VM State Management
315315+316316+All VMs are tracked in a local SQLite database with the following information:
317317+318318+- VM name and unique ID
319319+- Hardware configuration (CPU, memory, cores)
320320+- Network settings (bridge, MAC address)
321321+- Storage configuration
322322+- Current status (RUNNING, STOPPED)
323323+- Process ID (when running)
324324+- Creation timestamp
203325204326### Available CPU Types
205327···245367246368### Creating Disk Images
247369248248-Before using the `--drive` option, you may need to create a disk image:
370370+Before using the `--drive` option, you may need to create a disk image.
371371+FreeBSD-Up can automatically create disk images for you:
249372250373```bash
251251-# Create a 20GB qcow2 disk image
374374+# Automatically create a 20GB qcow2 disk image (default size)
375375+freebsd-up --drive ./freebsd-data.qcow2 --disk-format qcow2 14.3-RELEASE
376376+377377+# Create a larger 50GB disk image
378378+freebsd-up --drive ./freebsd-large.qcow2 --disk-format qcow2 --size 50G 14.3-RELEASE
379379+380380+# Manually create disk images with qemu-img
252381qemu-img create -f qcow2 freebsd-data.qcow2 20G
382382+qemu-img create -f raw freebsd-data.img 10G
383383+```
253384254254-# Create a 10GB raw disk image
255255-qemu-img create -f raw freebsd-data.img 10G
385385+### Setting up Bridge Networking
386386+387387+For bridge networking, you need to set up a bridge interface first:
388388+389389+```bash
390390+# Create a bridge interface (requires root)
391391+sudo ip link add br0 type bridge
392392+sudo ip link set br0 up
393393+394394+# Add your network interface to the bridge
395395+sudo ip link set eth0 master br0
396396+397397+# Then use FreeBSD-Up with bridge networking
398398+freebsd-up --bridge br0 14.3-RELEASE
256399```
400400+401401+Note: Bridge networking requires sudo privileges and FreeBSD-Up will
402402+automatically create the bridge if it doesn't exist.
257403258404### Advanced Customization
259405260406To modify other VM settings, edit the QEMU arguments in the `runQemu` function
261261-in `main.ts`:
407407+in `src/utils.ts`. The main.ts file now serves as the CLI entry point with
408408+subcommand routing.
262409263263-```typescript
264264-const cmd = new Deno.Command("qemu-system-x86_64", {
265265- args: [
266266- "-enable-kvm",
267267- "-cpu",
268268- options.cpu,
269269- "-m",
270270- options.memory,
271271- "-smp",
272272- options.cpus.toString(), // Number of CPU cores
273273- "-chardev",
274274- "stdio,id=con0,signal=off", // Enhanced console handling
275275- "-serial",
276276- "chardev:con0",
277277- // Conditional drive attachment for persistent storage
278278- ...(options.drive
279279- ? [
280280- "-drive",
281281- `file=${options.drive},format=${options.diskFormat},if=virtio`,
282282- ]
283283- : []),
284284- // ... other options
285285- ],
286286- // ...
287287-});
288288-```
410410+Key architecture changes:
411411+412412+- **Modular design**: Core functionality split into separate modules in `src/`
413413+- **Database integration**: SQLite database for persistent VM state management
414414+- **Subcommand structure**: Dedicated commands for VM lifecycle operations
415415+- **Network management**: Automatic bridge setup and MAC address assignment
416416+- **State tracking**: Comprehensive VM state persistence across restarts
289417290418### Supported Version Formats
291419···303431304432```
305433freebsd-up/
306306-โโโ main.ts # Main script with Cliffy CLI integration
307307-โโโ deno.json # Deno configuration with dependencies
308308-โโโ deno.lock # Dependency lock file
309309-โโโ README.md # This file
434434+โโโ main.ts # CLI entry point with Cliffy command routing
435435+โโโ deno.json # Deno configuration with dependencies
436436+โโโ deno.lock # Dependency lock file
437437+โโโ README.md # This file
438438+โโโ src/ # Core functionality modules
439439+ โโโ constants.ts # Configuration constants
440440+ โโโ context.ts # Application context and database setup
441441+ โโโ db.ts # Database schema and migrations
442442+ โโโ network.ts # Network bridge management
443443+ โโโ state.ts # VM state management functions
444444+ โโโ types.ts # TypeScript type definitions
445445+ โโโ utils.ts # Core VM utilities and QEMU interface
446446+ โโโ subcommands/ # CLI subcommand implementations
447447+ โโโ inspect.ts # VM inspection command
448448+ โโโ ps.ts # VM listing command
449449+ โโโ start.ts # VM start command
450450+ โโโ stop.ts # VM stop command
310451```
311452312453### Dependencies
···314455The project uses the following key dependencies:
315456316457- **[@cliffy/command](https://jsr.io/@cliffy/command)** - Modern command-line
317317- argument parsing
458458+ argument parsing and subcommands
459459+- **[@cliffy/table](https://jsr.io/@cliffy/table)** - Formatted table output for
460460+ VM listings
461461+- **[@db/sqlite](https://jsr.io/@db/sqlite)** - SQLite database for VM state
462462+ persistence
463463+- **[kysely](https://www.npmjs.com/package/kysely)** - Type-safe SQL query
464464+ builder
318465- **[chalk](https://www.npmjs.com/package/chalk)** - Terminal styling and colors
466466+- **[dayjs](https://www.npmjs.com/package/dayjs)** - Date formatting and
467467+ manipulation
468468+- **[lodash](https://www.npmjs.com/package/lodash)** - Utility functions
469469+- **[moniker](https://www.npmjs.com/package/moniker)** - Unique name generation
470470+ for VMs
319471320472## ๐ค Contributing
321473