dcvm turns one Linux machine into a small VM lab. dcvm create web builds a
VM from a Debian, Ubuntu, Arch Linux, Kali Linux or Fedora cloud image, creates your
user with a password and SSH key, installs the packages you asked for, and
puts the VM on a private network. It's for students, homelabs, CTF and
security practice, and anyone who wants a throwaway Linux box to try things
on. Under the hood it's Bash on top of KVM/QEMU and libvirt, so every VM is an
ordinary libvirt domain.
- One command, ready VM. Nine built-in cloud images (Debian 11/12/13,
Ubuntu 20.04/22.04/24.04, Arch Linux, Kali Linux, Fedora 44).
dcvm createreturns in about two seconds once the image is downloaded, and the VM finishes its first boot about a minute later. - Set up on first boot. User, password (stored only as a hash), SSH key,
static IP or DHCP, and
-kpackages, with nginx, Apache, MySQL/MariaDB, Docker and Tailscale set up for you. - Private by default. VMs sit on a NAT network (
10.10.10.0/24); one command forwards SSH and HTTP ports from the host when you want them reachable. - Break it, get it back. Backups, restore in place or as a copy, export/import between hosts.
- Any installer ISO.
dcvm create-isoboots Linux, BSD or Windows 10 installers, BIOS or UEFI, with VNC, SPICE or a serial console; unattended ISOs install without anyone watching. (Windows 11's TPM and Secure Boot are not set up.) - For you and your agents, without root. Members of the
dcvmgroup run dcvm from their own accounts and see only their own VMs, within quotas.--wait,--json,--ttlanddcvm execlet an agent create a VM, test something in it and throw it away (Users and agents). - No lock-in. No resident daemon;
virshand virt-manager keep working on every VM.
You need: an x86_64 Linux host (Debian/Ubuntu, Arch or Fedora based) with VT-x/AMD-V enabled, root access and an internet connection.
sudo -i # the installer runs as root
bash -c "$(curl -fsSL https://raw.githubusercontent.com/metharda/dcvm/main/lib/installation/install-dcvm.sh)"Tip
Prefer to read the installer before it runs as root? Download it first:
curl -fsSL -o install-dcvm.sh https://raw.githubusercontent.com/metharda/dcvm/main/lib/installation/install-dcvm.sh && less install-dcvm.sh && sudo bash install-dcvm.sh.
It then fetches the rest of dcvm from the same repository and branch. See
Installation for a manual install from a clone.
Fresh Ubuntu 24.04 host, all installer defaults. Recorded in real time (the packages took 47 s on this host) and played back 4× faster.
The installer asks a few questions; the defaults are fine. It installs
QEMU/KVM, libvirt and the image tools, creates the datacenter-net network
and /srv/datacenter, and installs the dcvm command.
Next steps
read -rs VM_PASSWORD && export VM_PASSWORD # the VM user's password, not echoed
dcvm create web -f -p "$VM_PASSWORD" -k nginx --ip 10.10.10.50
curl 10.10.10.50 # after about a minute of first boot
ssh ubuntu@10.10.10.50 # key login with the host root's SSH keyThe first dcvm create for an OS downloads its cloud image (Ubuntu 24.04 is
about 600 MB). Run dcvm create myvm without flags for an interactive wizard,
and see the Usage guide for every option.
flowchart LR
cmd["dcvm create web"] --> img["Cloud image<br/>(downloaded once)"]
img --> disk["web-disk.qcow2<br/>copy-on-write overlay"]
cmd --> seed["cloud-init seed<br/>user, password hash,<br/>SSH key, packages"]
disk --> vm(["VM 'web'<br/>libvirt + KVM"])
seed --> vm
vm --- net["datacenter-net<br/>10.10.10.0/24, NAT + DHCP"]
net --- host["Host<br/>ssh / curl to the VM IP"]
net -. "dcvm network ports setup" .- lan["Other machines<br/>host:2221 → VM:22, host:8081 → VM:80"]
- Image. Each OS maps to one official cloud image, downloaded once from
the fastest mirror into
/srv/datacenter/storage/templates. - Disk. The VM gets a qcow2 overlay on that image, so creating it takes seconds and it only stores its own changes.
- Seed. dcvm writes a cloud-init seed with the user, the password hash, your SSH key, packages and network settings.
- Boot.
virt-installdefines the VM on the NAT network and sets it to start with the host; cloud-init finishes the setup inside the guest.
More detail, including networking and backups, is in Architecture.
Practise an exploit, misconfigure a server, rm -rf the wrong folder: a
backup puts the VM back exactly as it was.
- Consistent. The VM is shut down for the copy (up to 60 seconds for a clean shutdown), then started again. A fresh Ubuntu VM took 20 seconds to back up and 80 seconds to restore on the demo host.
- In place or as a copy.
dcvm backup restore webreplaces the VM and keeps its MAC address and IP.dcvm backup restore web latest web2creates a second VM with new MACs, hostname, machine-id and SSH host keys. - Portable.
dcvm backup exportpacks a backup into a.tar.gzwithout yourauthorized_keys(with libguestfs-tools installed);dcvm backup importrestores it on another dcvm host. - The 5 most recent backups of each VM are kept.
Note
Backups store the VM's overlay disk, not a full disk image, and record the
exact base build it sits on. dcvm keeps that build while anything needs it,
moves VMs onto newer builds by itself, and restore and import find the
right build on their own (--full exports need none). See
Base images.
| Task | Command |
|---|---|
| Create (wizard / one line) | dcvm create myvm · dcvm create myvm -f -p "$PASS" -o 1 -m 4096 -c 4 -d 50G |
| Several at once (root and admins) | dcvm create web,db,cache -f -p "$PASS" |
| From an installer ISO | dcvm create-iso win --iso /isos/windows.iso -m 8192 -d 100G |
| List / overview | dcvm list · dcvm status |
| Start, stop, restart (one or all) | dcvm start web · dcvm stop --all · dcvm restart web · dcvm stop web --force |
| Serial console | dcvm console web (exit with Ctrl+]) |
| Reach VMs from the LAN | dcvm network ports setup · dcvm network ports test |
| Network, DHCP, VNC | dcvm network · dcvm network dhcp show · dcvm network vnc enable web |
| Back up and restore | dcvm backup create web · dcvm backup list · dcvm backup restore web |
| Cloud images | dcvm template status · dcvm template download -a |
| Use a VM over SSH | dcvm ssh web · dcvm exec web -- make test · dcvm cp ./app web:app |
| Throwaway VM for a script | dcvm create t1 --ttl 2h --wait --json · dcvm delete t1 --yes |
| Let others in without sudo | sudo dcvm user add alice · dcvm whoami |
| Health check | dcvm doctor · dcvm doctor --fix |
| Delete | dcvm delete web |
| Update dcvm | dcvm self-update --check · dcvm self-update |
-o picks the OS: 1 Debian 13, 2 Debian 12, 3 Debian 11, 4 Ubuntu
24.04 (default), 5 Ubuntu 22.04, 6 Ubuntu 20.04, 7 Arch Linux, 8 Kali
Linux, 9 Fedora 44. Defaults are 2048 MB RAM, 2 vCPUs and a 30G disk (Kali needs at least
30G).
Warning
dcvm delete does not ask for confirmation; it removes the VM, its disk,
DHCP lease and port forwards right away. Backups are kept.
| CPU | x86_64 with VT-x or AMD-V enabled (/dev/kvm present); nested virtualization works for a VM host |
| Memory | 4 GB minimum, 8 GB or more for several VMs (each defaults to 2 GB) |
| Disk | 50 GB or more free; each cloud image is 0.4-0.6 GB, plus what the VMs write |
| Host OS | Debian, Ubuntu, Arch Linux or Fedora, or a derivative (the installer uses apt, pacman or dnf); systemd |
| Access | root to install, internet for packages and images; afterwards members of the dcvm group need no root |
The installer writes /etc/dcvm-install.conf (DATACENTER_BASE,
NETWORK_NAME, BRIDGE_NAME, NETWORK_SUBNET); see
Operations › Settings. These environment
variables change behaviour:
| Variable | Default | Used by | Effect |
|---|---|---|---|
DCVM_REPO_SLUG |
metharda/dcvm |
installer, self-update |
GitHub owner/repo to install or update from (for forks) |
DCVM_REPO_BRANCH |
main |
installer, self-update |
Branch to install or update from |
SSH_PORT_START |
2221 |
dcvm network ports setup |
First host port forwarded to a VM's port 22 |
HTTP_PORT_START |
8081 |
dcvm network ports setup |
First host port forwarded to a VM's port 80 |
DCVM_VERBOSE |
unset | all commands | 1 shows every detail line instead of one line per step |
NO_COLOR |
unset | all commands | Turns colours off (no-color.org) |
# Install from a fork's branch
DCVM_REPO_SLUG=you/dcvm DCVM_REPO_BRANCH=my-branch \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/you/dcvm/my-branch/lib/installation/install-dcvm.sh)"Warning
VMs created with -f have root login enabled with the user's password
unless you pass --disable-root, and every VM accepts SSH passwords.
Forwarded ports listen on all host interfaces. On a host reachable from
untrusted networks, read Security first.
- One Linux x86_64 host. No macOS or Windows hosts, no clusters.
- Automatic setup covers the nine built-in images; ISO installs are manual.
- Backups are cold (the VM is shut down) and depend on the VM's cloud image file (see above). There are no live snapshots.
- Port forwarding covers SSH (22) and HTTP (80) for each running VM, uses
host ports 2221-2299 and 8081-8179, and is reapplied after a host reboot
by
dcvm-boot.service(dcvm network ports applydoes it by hand). - VMs share one bridge and can reach each other, including VMs of different users; the optional NFS share is one folder for every VM.
- Cloud images are checked against the checksum files their publishers put next to them on the official server (SHA256SUMS, SHA512SUMS); signatures are not checked, and a download is refused when that server gives no checksum.
| Tool | Good for | Hosts |
|---|---|---|
| dcvm | Ready Linux VMs from nine cloud images or any ISO, with NAT networking, port forwards, backups and export/import in one CLI | Linux with KVM/libvirt |
| Multipass | Cloud-style Ubuntu VMs with cloud-init, snapshots, mounts and a GUI | Linux, macOS, Windows |
| Vagrant + vagrant-libvirt | Reproducible environments described in a Vagrantfile you commit |
Linux, macOS, Windows |
| virt-install | Full control over every libvirt install method and device | Linux with libvirt |
| quickemu | Desktop VMs, including macOS and Windows guests, without root | Linux, macOS |
Choose dcvm when you want a lab on one Linux box with the image, user, key, network and ports handled for you. Choose another tool for a macOS or Windows host, macOS guests, an environment defined in a file, snapshots, or full control over libvirt options.
| Document | What's in it |
|---|---|
| Installation | Install options, what the installer does, updating, uninstalling |
| Usage | Every command and flag, packages, ISO installs |
| Networking | NAT network, static IPs, port forwarding, DHCP, VNC |
| Backups | Backup, restore, copies, export and import |
| Base images | How VM disks sit on cloud image builds, automatic moves to newer builds, restore on any host |
| dcvm doctor | Every check, what --fix repairs, and when dcvm runs it by itself |
| Users and agents | Using dcvm without root: roles, ownership, quotas, agents, how the socket works |
| Operations | Reading the checks, reboots, updates, logs, settings, troubleshooting |
| Security | Threat model, credentials, network exposure, hardening |
| Architecture | Components, the create flow, design decisions |
| Development | Repository layout, workflow, re-recording these demos |
| Examples | Web, database, Docker and networking walkthroughs |
| Changelog · Contributing | Release notes and how to contribute |
Apache License 2.0. See LICENSE.


