···1717- ๐ฅ **Automatic ISO download**: Downloads NetBSD ISO images from official CDN
1818- ๐ท๏ธ **Version-aware**: Specify NetBSD versions and automatically construct
1919 download URLs
2020-- ๐ **Flexible input**: Support for local ISO files, URLs, version numbers, or OCI registry images
2020+- ๐ **Flexible input**: Support for local ISO files, URLs, version numbers, or
2121+ OCI registry images
2122- โ๏ธ **Configurable VM settings**: Customize CPU, memory, cores, and disk
2223 options via CLI or configuration file
2324- โก **KVM acceleration**: Automatically enables hardware virtualization for
···3334 configurations
3435- ๐ท๏ธ **Auto-naming**: Automatic generation of unique VM names
3536- ๐ **Bridge networking**: Support for custom network bridges
3636-- ๐ฆ **OCI Registry Support**: Pull, push, and tag VM images to/from OCI-compliant registries (GitHub Container Registry, Docker Hub, etc.)
3737+- ๐ฆ **OCI Registry Support**: Pull, push, and tag VM images to/from
3838+ OCI-compliant registries (GitHub Container Registry, Docker Hub, etc.)
3739- ๐ผ๏ธ **Image Management**: List and remove local VM images
3838-- ๐ **Configuration File**: Initialize and use `vmconfig.toml` for persistent VM settings
4040+- ๐ **Configuration File**: Initialize and use `vmconfig.toml` for persistent
4141+ VM settings
4242+- ๐ฝ **Volume Management**: Create, list, inspect, and remove persistent volumes
4343+- ๐ **Volume Attachment**: Attach persistent volumes to VMs for data storage
4444+- ๐ **HTTP API**: RESTful API for managing machines, images, and volumes
4545+ programmatically
39464047## ๐ Requirements
4148···260267# Custom port forwarding (SSH on port 2222, HTTP on port 8080)
261268netbsd-up --port-forward "2222:22,8080:80"
262269270270+# Attach a volume to the VM
271271+netbsd-up start my-vm --volume my-data-volume
272272+263273# Combine multiple options
264274netbsd-up --memory 8G --cpus 4 --detach --port-forward "3000:3000"
265275```
···279289| `--detach` | `-d` | Run VM in the background and print VM name | `false` |
280290| `--port-forward` | `-p` | Port forwarding rules (format: hostPort:guestPort) | None |
281291| `--install` | | Persist changes to the VM disk image | `false` |
292292+| `--volume` | `-v` | Name of the volume to attach to the VM | None |
282293283294## ๐ง VM Management Commands
284295285285-| Command | Description |
286286-| -------------------------------- | ------------------------------------------------------- |
287287-| `netbsd-up init` | Initialize a default VM configuration file |
288288-| `netbsd-up ps` | List all running virtual machines |
289289-| `netbsd-up ps --all` | List all virtual machines (including stopped) |
290290-| `netbsd-up start <name>` | Start a stopped virtual machine |
291291-| `netbsd-up start <name> -d` | Start a virtual machine in background (detached) |
292292-| `netbsd-up stop <name>` | Stop a running virtual machine |
293293-| `netbsd-up restart <name>` | Restart a virtual machine |
294294-| `netbsd-up inspect <name>` | Show detailed information about a VM |
295295-| `netbsd-up rm <name>` | Remove a virtual machine from database |
296296-| `netbsd-up logs <name>` | View logs for a virtual machine |
297297-| `netbsd-up logs <name> -f` | Follow logs in real-time |
298298-| `netbsd-up pull <image>` | Pull VM image from OCI registry |
299299-| `netbsd-up push <image>` | Push VM image to OCI registry |
300300-| `netbsd-up tag <vm-name> <image>`| Tag a VM with an image name |
301301-| `netbsd-up run <image>` | Create and run a VM from an image |
302302-| `netbsd-up images` | List all local VM images |
303303-| `netbsd-up rmi <image>` | Remove a local VM image |
304304-| `netbsd-up login <registry>` | Authenticate to an OCI registry |
305305-| `netbsd-up logout <registry>` | Logout from an OCI registry |
296296+| Command | Description |
297297+| --------------------------------- | ------------------------------------------------ |
298298+| `netbsd-up init` | Initialize a default VM configuration file |
299299+| `netbsd-up ps` | List all running virtual machines |
300300+| `netbsd-up ps --all` | List all virtual machines (including stopped) |
301301+| `netbsd-up start <name>` | Start a stopped virtual machine |
302302+| `netbsd-up start <name> -d` | Start a virtual machine in background (detached) |
303303+| `netbsd-up start <name> -v <vol>` | Start a VM and attach a volume |
304304+| `netbsd-up stop <name>` | Stop a running virtual machine |
305305+| `netbsd-up restart <name>` | Restart a virtual machine |
306306+| `netbsd-up inspect <name>` | Show detailed information about a VM |
307307+| `netbsd-up rm <name>` | Remove a virtual machine from database |
308308+| `netbsd-up logs <name>` | View logs for a virtual machine |
309309+| `netbsd-up logs <name> -f` | Follow logs in real-time |
310310+| `netbsd-up pull <image>` | Pull VM image from OCI registry |
311311+| `netbsd-up push <image>` | Push VM image to OCI registry |
312312+| `netbsd-up tag <vm-name> <image>` | Tag a VM with an image name |
313313+| `netbsd-up run <image>` | Create and run a VM from an image |
314314+| `netbsd-up run <image> -v <vol>` | Run a VM from an image with an attached volume |
315315+| `netbsd-up images` | List all local VM images |
316316+| `netbsd-up rmi <image>` | Remove a local VM image |
317317+| `netbsd-up login <registry>` | Authenticate to an OCI registry |
318318+| `netbsd-up logout <registry>` | Logout from an OCI registry |
319319+| `netbsd-up volumes` | List all volumes |
320320+| `netbsd-up volume rm <name>` | Remove a volume |
321321+| `netbsd-up volume inspect <name>` | Inspect a volume |
322322+| `netbsd-up serve` | Start the HTTP API server |
323323+| `netbsd-up serve -p <port>` | Start the HTTP API server on a specific port |
306324307325## ๐ Examples
308326···462480netbsd-up logout ghcr.io
463481```
464482483483+### ๐ฝ Volume Management Examples
484484+485485+```bash
486486+# List all volumes
487487+netbsd-up volumes
488488+489489+# Start a VM with a volume attached
490490+netbsd-up start my-vm --volume my-data-volume
491491+492492+# Run a VM from an image with a volume
493493+netbsd-up run ghcr.io/tsirysndr/netbsd:10.1 --volume db-storage
494494+495495+# Inspect a volume
496496+netbsd-up volume inspect my-data-volume
497497+498498+# Remove a volume
499499+netbsd-up volume rm my-data-volume
500500+```
501501+502502+### ๐ HTTP API Examples
503503+504504+```bash
505505+# Start the API server
506506+netbsd-up serve
507507+508508+# Start on custom port
509509+netbsd-up serve --port 9000
510510+511511+# List all machines via API
512512+curl -H "Authorization: Bearer your-token" http://localhost:8892/machines
513513+514514+# Start a machine via API
515515+curl -X POST -H "Authorization: Bearer your-token" \
516516+ http://localhost:8892/machines/my-vm/start
517517+518518+# List all volumes via API
519519+curl -H "Authorization: Bearer your-token" http://localhost:8892/volumes
520520+```
521521+465522## ๐ Networking
466523467524The VM supports flexible networking configurations:
···514571## ๐พ Data Storage
515572516573NetBSD-UP uses a SQLite database (`~/.netbsd-up/state.sqlite`) to track virtual
517517-machine states and configurations. The database stores:
574574+machine states, configurations, and volumes. The database stores:
518575519576- VM names and unique identifiers
520577- CPU, memory, and disk configurations
···523580- Creation and update timestamps
524581- Process IDs for running VMs
525582- Log file locations for each VM
583583+- Volume information and attachments
526584527585### ๐ VM Logging
528586···536594## ๏ฟฝ OCI Registry Support
537595538596NetBSD-UP supports pulling and pushing VM images to OCI-compliant registries
539539-such as GitHub Container Registry (ghcr.io), Docker Hub (docker.io), and
540540-others. This enables sharing and distributing pre-configured NetBSD VMs.
597597+such as GitHub Container Registry (ghcr.io), Docker Hub (docker.io), and others.
598598+This enables sharing and distributing pre-configured NetBSD VMs.
541599542600### ๐ Authentication
543601···587645588646## ๐ VM Configuration File
589647590590-NetBSD-UP supports using a `vmconfig.toml` file for persistent VM
591591-configuration. This is useful for reproducible VM setups.
648648+NetBSD-UP supports using a `vmconfig.toml` file for persistent VM configuration.
649649+This is useful for reproducible VM setups.
592650593651### Creating a Configuration File
594652···620678621679CLI options will override configuration file settings.
622680623623-## ๏ฟฝ๐ License
681681+## ๐ฝ Volume Management
682682+683683+NetBSD-UP supports persistent volumes that can be attached to VMs for data
684684+storage. Volumes are stored as disk images in `~/.netbsd-up/volumes/` and
685685+persist independently of VM lifecycles.
686686+687687+### Creating and Using Volumes
688688+689689+Volumes are automatically created when you attach them to a VM:
690690+691691+```bash
692692+# Start a VM with a volume (volume is created if it doesn't exist)
693693+netbsd-up start my-vm --volume my-data-volume
694694+695695+# Run a new VM from an image with an attached volume
696696+netbsd-up run ghcr.io/tsirysndr/netbsd:10.1 --volume db-storage
697697+```
698698+699699+### Managing Volumes
700700+701701+```bash
702702+# List all volumes
703703+netbsd-up volumes
704704+705705+# Inspect a volume
706706+netbsd-up volume inspect my-data-volume
707707+708708+# Remove a volume
709709+netbsd-up volume rm my-data-volume
710710+```
711711+712712+### Volume Features
713713+714714+- ๐ฆ **Persistent Storage**: Volumes persist independently of VMs
715715+- ๐ **Reusable**: Attach the same volume to different VMs
716716+- ๐พ **Automatic Creation**: Volumes are created on first use
717717+- ๐ **Tracking**: All volumes are tracked in the SQLite database
718718+719719+## ๐ HTTP API
720720+721721+NetBSD-UP includes a RESTful HTTP API for programmatic management of machines,
722722+images, and volumes. The API is protected by bearer token authentication.
723723+724724+### Starting the API Server
725725+726726+```bash
727727+# Start on default port (8892)
728728+netbsd-up serve
729729+730730+# Start on custom port
731731+netbsd-up serve --port 9000
732732+733733+# Set API token via environment variable
734734+export NETBSD_UP_API_TOKEN="your-secure-token"
735735+netbsd-up serve
736736+```
737737+738738+If no `NETBSD_UP_API_TOKEN` is set, a random token will be generated and
739739+displayed.
740740+741741+### API Endpoints
742742+743743+The API provides the following endpoints:
744744+745745+#### Machines
746746+747747+- `GET /machines` - List all machines
748748+- `GET /machines/:id` - Get machine details
749749+- `POST /machines` - Create a new machine
750750+- `POST /machines/:id/start` - Start a machine
751751+- `POST /machines/:id/stop` - Stop a machine
752752+- `POST /machines/:id/restart` - Restart a machine
753753+- `DELETE /machines/:id` - Remove a machine
754754+755755+#### Images
756756+757757+- `GET /images` - List all images
758758+- `GET /images/:name` - Get image details
759759+- `POST /images/pull` - Pull an image from registry
760760+- `POST /images/push` - Push an image to registry
761761+- `DELETE /images/:name` - Remove an image
762762+763763+#### Volumes
764764+765765+- `GET /volumes` - List all volumes
766766+- `GET /volumes/:name` - Get volume details
767767+- `POST /volumes` - Create a volume
768768+- `DELETE /volumes/:name` - Remove a volume
769769+770770+### API Authentication
771771+772772+All API endpoints require bearer token authentication:
773773+774774+```bash
775775+# Example API request
776776+curl -H "Authorization: Bearer your-token" http://localhost:8892/machines
777777+```
778778+779779+### Environment Variables
780780+781781+- `NETBSD_UP_API_TOKEN` - Set the API authentication token
782782+- `NETBSD_UP_PORT` - Set the default API server port
783783+784784+## ๐ License
624785625786See [LICENSE](LICENSE) file for details.
626787