Skip to main content
RunBook Academy

Proxmox VEIX · Virtual MachinesVirtual devices

virtio-fs, virtio-rng, vmgenid and the rest of the device model

Advanced⏱ ~24 minqm

What you'll learn

  • Share a host directory into a guest with virtio-fs, using a datacenter directory mapping
  • Decide whether a guest needs a virtio-rng device and configure it without starving the host
  • Explain what vmgenid signals and which guests act on it
  • Recognise the migration and lifecycle constraints each of these devices adds

Prerequisites

Verified against Proxmox VE 9.2.4 · Proxmox Backup Server 4.2.5 · Ceph Squid / Tentacle · Debian 13 (Trixie) · Linux kernel 7.0 (PVE 9.2 default) · 2026-08-12

Not yet marked complete on this device.

A virtual machine’s device list is usually a disk, a NIC, a display and whatever was passed through. Three more devices exist, each solving a problem that otherwise gets solved badly:

  • virtio-fs, so a guest can read a host directory without an NFS server in the middle.
  • virtio-rng, so a guest that needs entropy gets it instead of blocking.
  • vmgenid, so a guest can find out it has been rolled back to an earlier state.

The third one has no performance implications at all and is the one whose absence causes the most damage.

virtio-fs: sharing a host directory

The option:

--virtiofs[n] [dirid=]<mapping-id> [,cache=<enum>] [,direct-io=<1|0>]
             [,expose-acl=<1|0>] [,expose-xattr=<1|0>]

documented as “configuration for sharing a directory between host and guest using Virtio-fs”.

The important detail is in the argument type. dirid is a mapping-id, not a path. You do not point a VM at /srv/media; you define a directory mapping at the datacenter level, per node, and then reference it by name.

Configuration changedefine the mapping, then attach it
set -euo pipefail

# On each node that should be able to run the guest, the directory must exist
# and the mapping must name it. Create the directory first.
install -d -m 0755 /srv/shared-media

# Then define the mapping (Datacenter > Resource Mappings > Directory), giving
# it an id such as shared-media and pointing it at /srv/shared-media on each
# node where the guest may run.

# Attach it to the guest by mapping id, not by path.
qm set 118 --virtiofs0 dirid=shared-media,expose-xattr=1,expose-acl=0

qm shutdown 118 --timeout 300
qm start 118
Configuration changeguest side, Linux
set -euo pipefail

mkdir -p /mnt/media
mount -t virtiofs shared-media /mnt/media

# Persist it. The nofail option matters: a guest that may be started on a
# node without the mapping should still boot.
printf '%s\n' 'shared-media /mnt/media virtiofs defaults,nofail 0 0' >> /etc/fstab
findmnt /mnt/media

virtio-rng: entropy for guests

rng0: [source=]</dev/urandom|/dev/random|/dev/hwrng>
      [,max_bytes=<integer>] [,period=<integer>]

with max_bytes defaulting to 1024 and period to 1000 — that is, a rate limit of 1024 bytes per 1000 milliseconds.

Configuration changeadding an entropy source
set -euo pipefail

qm set 118 --rng0 source=/dev/urandom,max_bytes=1024,period=1000

# Inside the guest, confirm the device arrived and something is using it.
#   ls -l /dev/hwrng
#   cat /sys/devices/virtual/misc/hw_random/rng_current

When a guest actually needs this: a guest that boots slowly with services blocked on entropy — historically common on minimal images before Linux 5.6 changed getrandom() behaviour — and guests doing high-volume cryptographic work such as a busy TLS terminator or a certificate authority. For an ordinary application server on a current kernel, adding an RNG device solves a problem it does not have.

vmgenid: telling a guest it has been rolled back

--vmgenid <UUID> (default = 1 (autogenerated))

“Set VM Generation ID. Use 1 to autogenerate on create or update, pass 0 to disable explicitly.”

The generation ID is a 128-bit value the guest can read. Proxmox changes it when the VM’s history forks — the documentation names restoring a backup and rolling back a snapshot as the events it detects.

Configuration changeensuring a guest has one
set -euo pipefail

# Which guests have no vmgenid?
for vmid in $(qm list | awk 'NR>1 {print $1}'); do
qm config "$vmid" | grep -q '^vmgenid:' || echo "VM $vmid has no vmgenid"
done

# Add one. This is a device change and takes effect at the next cold start.
qm set 118 --vmgenid 1

# Explicitly disable it, for a guest whose OS mishandles the device. Do this
# with a reason you have written down, not as a troubleshooting step.
#   qm set 118 --vmgenid 0

Two small options worth knowing

OptionDocumented asUse
protection“Sets the protection flag of the VM. This will disable the remove VM and remove disk operations.” Default 0Put it on anything whose deletion would be an incident. It is one setting that turns an irreversible mistake into an error message
tags“Tags of the VM. This is only meta information.”Filtering and reporting in the interface. It carries no permissions and no behaviour — it is a label, and treating it as a control is a mistake people make
Configuration changeprotection on the guests that matter
set -euo pipefail

for vmid in 101 102 118; do
qm set "$vmid" --protection 1
done

qm config 118 | grep -E '^(protection|tags):'

Knowledge check

Knowledge check · 4 questions

  1. Q1. The virtiofs option takes dirid=<mapping-id> rather than a host path. Why is that the better design?

  2. Q2. Which are true of a virtio-rng device configured with source=/dev/random on the host? Select all that apply.

  3. Q3. The VM generation ID signals to a guest that its history has forked, but does nothing to prevent or repair the fork.

  4. Q4. Which option would you set on a production VM to make an accidental deletion fail rather than succeed?

Passing score: 75%. Answers are checked in this browser.