This is part 8 of Proxmox from scratch. In part 7 my three servers became one cluster, kaddu-systems: phoebe, the Lenovo Tiny with the Ryzen 5 PRO that runs Nextcloud and Jellyfin, priscilla, the older Tiny with a 7th-generation i5 and the standby, and stephen, the backup server in the garage office, which is in the cluster for its vote. This part puts the cluster to work. A guest moves from one node to another, and the example is Jellyfin, which goes from phoebe to priscilla.

There are two reasons for picking Jellyfin. priscilla’s i5 has Intel’s Quick Sync, and in two weeks I compare it with the AMD graphics in phoebe that Jellyfin at home set up for transcoding. And Jellyfin is a good test: a container with six volumes on two kinds of storage, Docker inside it, and the server’s graphics passed through to it. If that moves cleanly, most things will.

VMs and containers move differently

Proxmox calls moving a guest to another node migration, and the Migrate button sits at the top right of every guest [2] [1]. What happens next depends on the kind of guest.

Virtual machines: online migration

A virtual machine can move while it runs. Proxmox starts an empty copy of it on the target, copies the memory across while the VM carries on, then pauses it for a moment, copies the last changes, and lets it run on the new node [2]. Network connections survive, and the user notices at most a short hiccup. With local disks, as mine are, the disks are copied too, and that is what takes the time.

To try it, I moved VM 100 from phoebe to priscilla. It’s a Kubuntu desktop with 4 GB of memory and a 32 GB disk on vmdatanvme. The Migrate dialog fills in the mode by itself, Online, because the VM is running, and it warns about the disk: “Migration with local disk might take long”. Target storage stays at Current layout, which means the same storage ID on the other node.

The Migrate VM 100 (kadduhq) dialog: source node phoebe, target node priscilla, mode Online, target storage Current layout, and the warning Migration with local disk might take long: vmdatanvme:vm-100-disk-0 (32.00 GiB)

The task log shows the two halves. First the disk: Proxmox starts the VM on priscilla, waiting, opens a tunnel, and mirrors the disk across while the VM keeps running on phoebe, at about 115 MB a second, which is what one gigabit port can carry.

The task log at the start: the local disk vmdatanvme:vm-100-disk-0 found, the VM started on priscilla, the storage migration started, and the disk mirror counting up, 223 MiB after one second, 1.7 GiB after 14

Then the memory: 3.6 GB of it, copied while the VM ran, at an average of 124.6 MiB/s. At the very end the VM was paused, the last changes sent, and it carried on from priscilla. The downtime was 113 milliseconds. The whole move took 3 minutes and 49 seconds.

The end of the task log: memory copied at 110-125 MiB/s, average migration speed 124.6 MiB/s, downtime 113 ms, the disk mirror completed, and migration finished successfully (duration 00:03:49), TASK OK

Moving it back to phoebe afterwards was the same again: 4 minutes and 7 seconds in all, 3 minutes and 13 of them for the disk, and 77 milliseconds of downtime. Nobody using that desktop would have noticed either move.

It isn’t free, though. While it ran, the UPS that feeds the whole homelab showed 86-89 W, with dips to 76 W and spikes to 115 W. Idle is 53-56 W, and a film playing straight from Jellyfin, as one was on the TV the whole time, doesn’t change that. The film didn’t stutter once, either, even with phoebe’s one network port full of disk copy. Both Tinys work flat out during a migration, one reading and sending, the other receiving and writing, with the copy encrypted over SSH on the way. Another reason to let replication copy the bulk in the background beforehand, as the next sections show for containers.

One thing the VM lost on the way: its ZFS snapshots. An online migration copies the disk block by block while the VM runs, into a new volume on the target, and the snapshots sanoid had taken of it don’t come along. After the trip there and back, kadduhq’s disk on phoebe was a fresh volume with no history, and stephen’s backup run refused it:

text
CRITICAL ERROR: Target fatagnus/backup/phoebe/vmdatanvme/vm-100-disk-0
exists but has no snapshots matching with rpool/data/vmdatanvme/vm-100-disk-0!

syncoid won’t throw away a backup to make room for a new one, and that’s the right call. The fix is to move the old backup aside on stephen, so the next run starts a new full copy, and delete it once that has arrived. Containers are different, as the next section shows.

Containers: restart migration

A container can’t do that. Its processes run directly on the host’s kernel, and there is no way to lift them across to another kernel while they run. So a running container is moved in restart mode: it is shut down, its volumes are copied, and it is started again on the target [1]. On the command line:

sh
pct migrate 1002 priscilla --restart

The outage is the shutdown, the copy and the start. The copy is the part you can make small, and that is what replication is for.

Before the first move

The storage has to exist on the target

A guest’s configuration names its storage, not a path: Jellyfin’s root disk is vmdatanvme:subvol-1002-disk-0, not a dataset on phoebe. On the target, the same storage ID has to exist and point at something. Part 4 set that up for this moment: vmdatanvme is the NVMe drive and vmdatahdd the hard drive on both Tinys, with the same dataset paths, so a volume lands in the same tier on either one.

stephen has neither. It runs no guests, so the two storages should say so. I set that when stephen joined: in Datacenter > Storage, edit each one and set Nodes to phoebe and priscilla, or:

sh
pvesm set vmdatanvme --nodes phoebe,priscilla
pvesm set vmdatahdd --nodes phoebe,priscilla

Then the Migrate dialog doesn’t offer stephen as a target for anything stored there.

Only the storages a guest actually uses matter. phoebe has a couple of others, local-zfs from the installer and an empty one left over from an experiment, and since nothing of Jellyfin’s is on them, they play no part in the move.

Check the space, too. Jellyfin’s volumes add up to about 480 GB of quota: 32 GB for the container itself and 84 GB on the NVMe for its configuration, metadata and cache, and 360 GB of media on the hard drive. Only what is used gets copied, but it has to fit.

The network has to match

The container keeps its MAC address and its fixed IP address, and it expects a bridge called vmbr0 on whatever node it runs on. Each node has its own vmbr0, set up by hand in part 5, and they match because I keep them alike. The cluster doesn’t check that for you.

The migration network

Datacenter > Options > Migration Settings says which network the copies go over [4]. With one network port per Tiny, there is only one, so I left it alone. When the Tinys get 2.5 Gbit cards in their M.2 slots next year, this is where the faster network goes, and migrations and replication use it from then on.

Making it fast: replication

Without help, a restart migration copies every volume in full, every time. Jellyfin’s media alone would keep it offline for an hour or so on a gigabit network.

Replication fixes that. It keeps a copy of a guest’s ZFS volumes on another node and refreshes it on a schedule, by default every 15 minutes, sending only what changed since the last run [3]. When the guest then moves to that node, the migration only has to send the last few minutes of changes.

It needs ZFS on both ends, with the same storage ID [3], which is exactly what part 4 built. In the guest’s Replication tab, Add, pick the target node and the schedule. Or on the command line, where 1002-0 is the job’s ID, the guest’s number and a running number:

sh
pvesr create-local-job 1002-0 priscilla --schedule "*/15"
pvesr schedule-now 1002-0
pvesr status

The first run is a full copy and takes as long as a migration would. After that, each run is small.

One of Jellyfin’s volumes is left out on purpose. The transcoding cache has replicate=0, set in Jellyfin part 1: it is temporary files that Jellyfin rebuilds, and there is no reason to send them every 15 minutes. A volume left out of replication is still moved when the guest moves, just in full.

When a guest moves to its replication target, Proxmox turns the job round by itself: the old source becomes the new target, and phoebe now keeps the copy [3]. Moving back is then just as quick.

What doesn’t move by itself

The cluster moves the guest’s configuration and its volumes. Anything the guest depends on that lives on the host, outside /etc/pve, stays where it is. For Jellyfin, that was:

  • The graphics. The container’s dev0 line hands it the host’s /dev/dri/renderD128. The line moves, and the path exists on priscilla too, but behind it is a different chip with a different driver. More on that below.
  • Snapshots and backups set up on the host. sanoid takes my ZFS snapshots and syncoid sends them to stephen, and both are configured per node, in files on that node. After the move, the live datasets are on priscilla (and with replication, phoebe keeps a copy). sanoid on priscilla has to cover them, and syncoid has to fetch them from priscilla. Mine were set up for whole pools on both nodes, so nothing had to change, but the backups still paid for the move: stephen saw Jellyfin’s volumes on priscilla as new and started fetching them in full, 423 GB over a PowerLine link that manages about 4 MB a second. That’s more than a day, with every hourly run in between told Cannot sync now: … is already target of a zfs receive process. Renaming stephen’s existing copies to the new node’s path first would have let it carry on where it left off, since the migration brought the snapshots it needs along. Next time, that’s step one.
  • Bind mounts. A mount point that is a path on the host, rather than a volume on a Proxmox storage, only exists on the node that has that path. Jellyfin has none, because part 1 made all six volumes Proxmox volumes for exactly this reason.
  • USB devices and anything else plugged into one particular box.

Moving Jellyfin

Before

Before the move, container 1002 ran on phoebe, with phoebe’s AMD graphics doing the transcoding. A 4K HDR film played in a browser, which needs both a new format and tone mapping, transcoded at 3.5 times real time with the container’s processors at about 10 %.

Container 1002 (jellyfin) on phoebe: the Summary page with the Migrate button at the top, and the CPU graph for an hour: almost idle, a little higher during a Direct Play stream, and about 10 % during a 4K HDR transcode

The move

I’ll admit it: I didn’t set up the replication job first. I pressed Migrate to see what a container move does on its own, and that’s worth seeing once. For a container, the dialog has nothing to choose but the node. The mode is Restart Mode, since a running container can’t move any other way.

The Migrate CT 1002 (jellyfin) dialog: source node phoebe, target node priscilla, Restart Mode, Config Check ticked

Proxmox shut Jellyfin down and then copied its volumes one by one. The task log held a surprise: each volume goes across with every ZFS snapshot it has. My datasets carry sanoid’s snapshots, kept every 15 minutes, hourly, daily, weekly, monthly and yearly, plus the one syncoid keeps as its starting point for the backups on stephen, and the migration sends all of them, oldest first, before the current state.

The task log of the container migration: send from one autosnap snapshot to the next for subvol-1002-disk-1, including a syncoid_stephen snapshot, total estimated size 2.52G, and then a list of SENT SNAPSHOT lines, yearly, monthly, weekly and daily

That has two sides. The history comes along, so the snapshots are on priscilla too, and syncoid’s starting point with them. But every snapshot is more data to send, and Jellyfin is offline for all of it.

The media volumes are where it slowed down. On priscilla, the receiving end, the processor sat at 5-10 % while the IO delay in the node’s summary was 15-20 %, and close to 50 % on the heaviest snapshots: the share of time the processor spends waiting for the disks. The media volume came to 423 GB in all, and one daily snapshot from mid-November alone held 284 GB of films. It went across at 60 to 110 MB a second, which is about what one gigabit port can carry. So here the network sets the pace: a single 2.5" laptop drive can write a little faster than that, and the high IO delay shows it working just below its own limit to keep up. With the 2.5 Gbit cards I’m planning for the Tinys, it would be the other way round, and the hard drive would be what holds the copy back.

With the media volumes on the hard drive, the whole move took 2 hours and 3 minutes, and Jellyfin was offline for all of it. With a replication job in place first, the same move only has to send what changed in the last few minutes, and Jellyfin is back almost as soon as it’s down. Next time, that’s how I’ll do it.

It also didn’t end cleanly. The volumes all arrived, Proxmox started Jellyfin on priscilla, and then the task ended with TASK ERROR: migration problems. One line further up says why:

text
ERROR: removing local copy of 'vmdatahdd:subvol-1002-disk-1' failed -
zfs error: cannot unmount '/paula/data/vmdatahdd/subvol-1002-disk-1':
pool or dataset is busy

The move itself worked: the log has successfully imported for all eight volumes, and ZFS receives each snapshot whole or not at all, so nothing arrived half-copied. What failed was the cleanup afterwards: Proxmox couldn’t delete the old copy of the media volume on phoebe, because something still had it open. fuser names the culprit:

text
root@phoebe:~# fuser -vm /paula/data/vmdatahdd/subvol-1002-disk-1
                     USER        PID ACCESS COMMAND
/paula/data/vmdatahdd/subvol-1002-disk-1:
                     root     kernel mount /paula/data/vmdatahdd/subvol-1002-disk-1
                     root      2071444 ..c.. tmux: server
                     root      2071445 ..c.. bash

The c means current directory. It was me: an old tmux session on phoebe, with a shell still sitting in the media folder from when I last copied films in. A filesystem can’t be unmounted while a shell stands in it, so the delete stopped halfway. It had already removed the volume’s snapshots, but not the volume itself. What’s left on phoebe is a snapshot-less copy that belongs to no container, and it isn’t harmless: it would block the move back, because Proxmox refuses to copy a volume to a node where one with the same name already exists. So: leave the shell, and delete the rest by hand.

sh
# On phoebe: tmux attach, then cd / (or exit) in that shell
fuser -vm /paula/data/vmdatahdd/subvol-1002-disk-1   # should list only the mount
zfs destroy -r paula/data/vmdatahdd/subvol-1002-disk-1

The lesson for next time is cheap: before a move, close any shell that stands inside the guest’s volumes.

None of that touched the copy on priscilla. On the new node the media volume holds its 420 GB of films, and the next morning Jellyfin played a film over Tailscale to my laptop on the train to work.

What changes for hardware transcoding

Moving the container is only half of moving Jellyfin, because the hardware under it changes, and Jellyfin doesn’t notice by itself.

The device has the same name on both nodes, /dev/dri/renderD128, because each has one graphics chip, so the container’s dev0 line still points at something real. But behind it is a different chip with a different driver. On phoebe it’s AMD’s Vega 11 with Mesa’s VA-API driver. On priscilla it’s Intel’s HD Graphics 630 with Intel’s own media driver, which Jellyfin’s Docker image brings with it [6]. Jellyfin is still set up for AMD, and with the wrong method selected, a transcode can fall back to the processor without saying so.

Three things have to be checked after a move like this:

  1. The group. The gid= in the dev0 line is the render group inside the container, which moved along with it, so it needs no change. Check that the device shows up in the container with that group: pct exec 1002 -- ls -l /dev/dri.
  2. Jellyfin’s transcoding settings. In Dashboard > Playback > Transcoding, switch hardware acceleration from VA-API to Intel QuickSync (QSV), which is what Jellyfin’s Intel guide recommends [6], and set the decode boxes to what this chip can do.
  3. Check that it’s really the graphics. Play something that transcodes and look at the host with intel_gpu_top: the Video engine should be busy, and the processor shouldn’t.

On phoebe, the same 4K HDR film that a browser can’t play transcoded at 3.5 times real time with the container’s processors at about 10 %. How priscilla’s Quick Sync does with the same film, the switch to QSV step by step, and what each costs in power, is the next Jellyfin post, on 14 December.

Moving back, and emptying a node

Moving Jellyfin back to phoebe is the same button with the other node. This time I’ll set up the replication job first and let it do its full copy in the background, with Jellyfin running, and then move it. Same container, same data, so the difference in downtime is all down to replication. I’ll add the numbers to this post when I’ve done it.

That’s also the standby role priscilla was set up for: before an update of phoebe, move its guests to priscilla, update and reboot phoebe, and move them back.

For that to work with everything, every guest on phoebe needs a replication job to priscilla, and priscilla needs room for all of it, on both drives, at the same time.

Jellyfin can do that now. Nextcloud can’t yet, and it’s my own doing. When I set up its container, I gave it its database, its application files and its users’ files as bind mounts: ZFS datasets I made by hand on phoebe and mounted into the container by their path on the host. That’s exactly the kind of mount point the cluster can’t move. Proxmox won’t migrate a container with a bind mount unless it’s marked as available on every node [1], and replication only copies volumes on a Proxmox storage [3]. The datasets would simply not be on priscilla.

The fix is to turn them into Proxmox volumes, the way Jellyfin’s were made from the start. The data doesn’t have to be copied for that: a dataset renamed within the same pool moves in an instant, so each one can be renamed into the storage’s own naming and the mount point pointed at the volume instead of the path. That’s a planned evening with Nextcloud in maintenance mode and snapshots first, and it gets its own post. Until then, an update of phoebe means a few minutes without Nextcloud.

What’s next

Part 9 stays with priscilla’s graphics, but for a virtual machine: passing the built-in GPU through with Intel’s GVT-g. Part 10 expands a ZFS mirror with new disks.

Sources