A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU

Update README.md to enhance VM management instructions and replace 'drive' option with 'image'

Changed files
+49 -27
+49 -27
README.md
··· 15 15 16 16 ### Core VM Management 17 17 18 - - ๐Ÿ—๏ธ **Full VM lifecycle management**: Create, start, stop, and inspect VMs 18 + - ๐Ÿ—๏ธ **Full VM lifecycle management**: Create, start, stop, inspect, and remove 19 + VMs 19 20 - ๐Ÿ’พ **Persistent state tracking**: SQLite database stores VM configurations and 20 21 state 21 22 - ๐Ÿ“Š **VM listing and monitoring**: View running and stopped VMs with detailed 22 23 information 23 24 - ๐Ÿ” **VM inspection**: Get detailed information about any managed VM 25 + - ๐Ÿ—‘๏ธ **VM removal**: Clean removal of VMs from the database 24 26 - ๐Ÿท๏ธ **Auto-generated VM names**: Unique identifiers for easy VM management 27 + - ๐Ÿ›๏ธ **Cross-platform support**: Works on both x86_64 and aarch64 architectures 25 28 26 29 ### Network & Storage 27 30 ··· 156 159 freebsd-up inspect vm-name 157 160 ``` 158 161 159 - freebsd-up /path/to/your/freebsd.iso 162 + Remove a VM: 163 + 164 + ```bash 165 + freebsd-up rm vm-name 166 + ``` 160 167 161 168 ```` 162 169 ### Customize VM Configuration ··· 171 178 freebsd-up --cpus 4 --memory 8G 15.0-BETA3 172 179 173 180 # Attach a disk image for persistent storage 174 - freebsd-up --drive ./freebsd-disk.img --disk-format qcow2 14.3-RELEASE 181 + freebsd-up --image ./freebsd-disk.img --disk-format qcow2 14.3-RELEASE 175 182 176 183 # Create disk image with specific size 177 - freebsd-up --drive ./freebsd-disk.qcow2 --disk-format qcow2 --size 50G 14.3-RELEASE 184 + freebsd-up --image ./freebsd-disk.qcow2 --disk-format qcow2 --size 50G 14.3-RELEASE 178 185 179 186 # Use bridge networking (requires sudo) 180 187 freebsd-up --bridge br0 14.3-RELEASE ··· 183 190 freebsd-up --output ./downloads/freebsd.iso 15.0-BETA3 184 191 185 192 # Combine all options 186 - freebsd-up --cpu qemu64 --cpus 2 --memory 1G --drive ./my-disk.qcow2 --disk-format qcow2 --size 30G --bridge br0 --output ./my-freebsd.iso 193 + freebsd-up --cpu qemu64 --cpus 2 --memory 1G --image ./my-disk.qcow2 --disk-format qcow2 --size 30G --bridge br0 --output ./my-freebsd.iso 187 194 ```` 188 195 189 196 ### Get Help 190 197 191 198 ```bash 192 - ./main.ts --help 199 + freebsd-up --help 193 200 # or 194 - ./main.ts -h 201 + freebsd-up -h 195 202 ``` 196 203 197 204 ### Alternative Execution Methods 198 205 199 - If the script isn't executable, you can run it directly with Deno: 206 + If you haven't installed via deno install, you can run it directly with Deno: 200 207 201 208 ```bash 202 - deno run --allow-run --allow-read --allow-env main.ts [options] 209 + deno run --allow-run --allow-read --allow-env -g -r -f main.ts -n freebsd-up 203 210 ``` 204 211 205 212 ## ๐Ÿ”ง Command Line Options ··· 211 218 - `-c, --cpu <type>` - CPU type to emulate (default: `host`) 212 219 - `-C, --cpus <number>` - Number of CPU cores (default: `2`) 213 220 - `-m, --memory <size>` - Amount of memory for the VM (default: `2G`) 214 - - `-d, --drive <path>` - Path to VM disk image for persistent storage 221 + - `-i, --image <path>` - Path to VM disk image for persistent storage 215 222 - `--disk-format <format>` - Disk image format: qcow2, raw, etc. (default: 216 223 `raw`) 217 224 - `-s, --size <size>` - Size of disk image to create if it doesn't exist ··· 231 238 - `start <vm-name>` - Start a specific VM by name 232 239 - `stop <vm-name>` - Stop a specific VM by name 233 240 - `inspect <vm-name>` - Show detailed information about a VM 241 + - `rm <vm-name>` - Remove a VM and its configuration from the database 234 242 235 243 ### Help Options 236 244 ··· 250 258 freebsd-up --cpus 4 14.3-RELEASE 251 259 252 260 # Attach a persistent disk image 253 - freebsd-up --drive ./freebsd-storage.qcow2 --disk-format qcow2 14.3-RELEASE 261 + freebsd-up --image ./freebsd-storage.qcow2 --disk-format qcow2 14.3-RELEASE 254 262 255 263 # Create a larger disk image automatically 256 - freebsd-up --drive ./freebsd-big.qcow2 --disk-format qcow2 --size 100G 14.3-RELEASE 264 + freebsd-up --image ./freebsd-big.qcow2 --disk-format qcow2 --size 100G 14.3-RELEASE 257 265 258 266 # Use bridge networking for better network performance 259 267 freebsd-up --bridge br0 14.3-RELEASE ··· 262 270 freebsd-up --output ./isos/freebsd.iso https://example.com/freebsd.iso 263 271 264 272 # Combine multiple options with bridge networking and persistent storage 265 - freebsd-up --cpu host --cpus 4 --memory 8G --drive ./vm-disk.qcow2 --disk-format qcow2 --size 50G --bridge br0 --output ./downloads/ 14.3-RELEASE 273 + freebsd-up --cpu host --cpus 4 --memory 8G --image ./vm-disk.qcow2 --disk-format qcow2 --size 50G --bridge br0 --output ./downloads/ 14.3-RELEASE 266 274 267 275 # List all VMs (including stopped ones) 268 276 freebsd-up ps --all ··· 275 283 276 284 # Get detailed information about a VM 277 285 freebsd-up inspect my-freebsd-vm 286 + 287 + # Remove a VM 288 + freebsd-up rm my-freebsd-vm 278 289 ``` 279 290 280 291 ## ๐Ÿ–ฅ๏ธ Console Setup ··· 299 310 - **Memory**: 2GB RAM (configurable with `--memory`) 300 311 - **Cores**: 2 virtual CPUs (configurable with `--cpus`) 301 312 - **Storage**: ISO-only by default; optional persistent disk (configurable with 302 - `--drive`) 313 + `--image`) 303 314 - **Network**: User mode networking with SSH forwarding (host:2222 โ†’ guest:22) 304 315 or bridge networking with `--bridge` 305 316 - **Console**: Enhanced serial console via stdio with proper signal handling ··· 364 375 freebsd-up --cpus 4 365 376 366 377 # Add persistent storage 367 - freebsd-up --drive ./freebsd-data.qcow2 --disk-format qcow2 378 + freebsd-up --image ./freebsd-data.qcow2 --disk-format qcow2 368 379 369 380 # Combine options with persistent storage 370 - freebsd-up --cpu host --cpus 4 --memory 8G --drive ./vm-storage.qcow2 --disk-format qcow2 14.3-RELEASE 381 + freebsd-up --cpu host --cpus 4 --memory 8G --image ./vm-storage.qcow2 --disk-format qcow2 14.3-RELEASE 371 382 ``` 372 383 373 384 ### Creating Disk Images 374 385 375 - Before using the `--drive` option, you may need to create a disk image. 386 + Before using the `--image` option, you may need to create a disk image. 376 387 FreeBSD-Up can automatically create disk images for you: 377 388 378 389 ```bash 379 390 # Automatically create a 20GB qcow2 disk image (default size) 380 - freebsd-up --drive ./freebsd-data.qcow2 --disk-format qcow2 14.3-RELEASE 391 + freebsd-up --image ./freebsd-data.qcow2 --disk-format qcow2 14.3-RELEASE 381 392 382 393 # Create a larger 50GB disk image 383 - freebsd-up --drive ./freebsd-large.qcow2 --disk-format qcow2 --size 50G 14.3-RELEASE 394 + freebsd-up --image ./freebsd-large.qcow2 --disk-format qcow2 --size 50G 14.3-RELEASE 384 395 385 396 # Manually create disk images with qemu-img 386 397 qemu-img create -f qcow2 freebsd-data.qcow2 20G ··· 408 419 409 420 ### Advanced Customization 410 421 411 - To modify other VM settings, edit the QEMU arguments in the `runQemu` function 412 - in `src/utils.ts`. The main.ts file now serves as the CLI entry point with 413 - subcommand routing. 422 + To modify VM settings beyond command-line options, you can edit the QEMU 423 + arguments in the relevant functions in `src/utils.ts` (for VM creation) or 424 + `src/subcommands/start.ts` (for VM startup). The main.ts file serves as the CLI 425 + entry point with subcommand routing. 414 426 415 - Key architecture changes: 427 + Key architecture components: 416 428 417 429 - **Modular design**: Core functionality split into separate modules in `src/` 418 430 - **Database integration**: SQLite database for persistent VM state management 419 - - **Subcommand structure**: Dedicated commands for VM lifecycle operations 420 - - **Network management**: Automatic bridge setup and MAC address assignment 421 - - **State tracking**: Comprehensive VM state persistence across restarts 431 + (see `src/db.ts`) 432 + - **Subcommand structure**: Dedicated commands for VM lifecycle operations in 433 + `src/subcommands/` 434 + - **Network management**: Automatic bridge setup and MAC address assignment in 435 + `src/network.ts` 436 + - **State tracking**: Comprehensive VM state persistence across restarts in 437 + `src/state.ts` 422 438 423 439 ### Supported Version Formats 424 440 ··· 451 467 โ””โ”€โ”€ subcommands/ # CLI subcommand implementations 452 468 โ”œโ”€โ”€ inspect.ts # VM inspection command 453 469 โ”œโ”€โ”€ ps.ts # VM listing command 470 + โ”œโ”€โ”€ rm.ts # VM removal command 454 471 โ”œโ”€โ”€ start.ts # VM start command 455 472 โ””โ”€โ”€ stop.ts # VM stop command 456 473 ``` ··· 459 476 460 477 The project uses the following key dependencies: 461 478 479 + - **[@paralleldrive/cuid2](https://www.npmjs.com/package/@paralleldrive/cuid2)** - 480 + Unique ID generation for VMs 462 481 - **[@cliffy/command](https://jsr.io/@cliffy/command)** - Modern command-line 463 482 argument parsing and subcommands 464 483 - **[@cliffy/table](https://jsr.io/@cliffy/table)** - Formatted table output for 465 484 VM listings 466 485 - **[@db/sqlite](https://jsr.io/@db/sqlite)** - SQLite database for VM state 467 486 persistence 487 + - **[@soapbox/kysely-deno-sqlite](https://jsr.io/@soapbox/kysely-deno-sqlite)** - 488 + SQLite dialect for Kysely 468 489 - **[kysely](https://www.npmjs.com/package/kysely)** - Type-safe SQL query 469 490 builder 470 491 - **[chalk](https://www.npmjs.com/package/chalk)** - Terminal styling and colors ··· 485 506 486 507 ## ๐Ÿ“ License 487 508 488 - This project is open source. Check the repository for license details. 509 + This project is licensed under the Mozilla Public License 2.0. See the LICENSE 510 + file for details. 489 511 490 512 ## ๐Ÿ”— Useful Links 491 513