The last section of a how-to

In September I published the page I could not find: two fresh Proxmox nodes, an Unraid box exporting a couple of LUNs, and the exact sequence that turns those LUNs into shared storage both nodes can use. It works, and I still stand behind every command in it.

But the part of that article I wrote fastest was the part that should have slowed me down. Shared LVM over iSCSI is thick, raw, and snapshot-free. More than that, the thing keeping two nodes from writing the same disk at once is a lock held in Proxmox’s cluster filesystem. That lock is real and it works, inside a cluster. Point two Proxmox boxes that are not clustered at the same LVM LUN and there is nothing at all stopping both of them from starting the same VM and shredding its disk. The protection is a property of the cluster, not of the storage.

I spent years on VMware before any of this, and VMware had spoiled me on exactly this point. One LUN, every host sees it, VMs live on it, vMotion just works, and none of it cares whether the hosts share a management plane, because the coordination is written on the LUN. That is VMFS, and Linux never grew an equivalent. The alternatives are a clustered filesystem with its own distributed lock manager and fencing stack to babysit, or giving up on the SAN and using NFS.

The spreadsheet, in this story, was a nagging feeling. Every time I looked at the storage view I knew the safety I was relying on lived somewhere other than the disk.

The founding rule

The lock lives on the disk, not in the cluster. Ownership of a volume is a lease stored on the LUN itself. Any host that can read the superblock can join, hold a lease, and be fenced if it stops renewing. Nodes in one cluster, in different clusters, or in no cluster at all share the same pool under the same rules, because the rules are on the storage they share.

Borrowing the shape, not the code

Strip VMFS down to the ideas that matter and there are three: coordination lives on the shared disk, allocation is coarse so the metadata stays tiny, and a host that cannot prove it is alive loses the right to write. I wanted those three and nothing else. In particular I did not want a filesystem, because the moment you need shared files and directories the design turns into a different and much larger project.

So nox is a block pool. You format one iSCSI or Fibre Channel LUN once. Every node that can see it opens it read-write. Each VM disk becomes a plain block device mapped over fixed extents of the LUN, with a device-mapper linear table doing the actual I/O in the kernel, exactly as LVM does. The daemon only ever touches metadata, which means a daemon crash never stalls a running guest.

The decision that shaped everything else was not to write my own on-disk locking. sanlock has been doing disk Paxos for fifteen years for oVirt and libvirt, it needs only ordered reads and writes from the storage, and it comes with wdmd, which resets a host that cannot renew its lease before any peer is allowed to take over. I configured it rather than replacing it.

Proxmox
storage type nox
create · resize · clone · migrate
→JSON over a
Unix socket
noxd
one per node per pool
metadata and leases only
→sanlock leases
4 KiB records
The LUN
superblock · lockspace
leases · table · extents
→dm table
load / reload
device-mapper
linear map per volume
the only kernel piece
The guest's I/O goes straight from QEMU through device-mapper to the LUN. noxd is not in the data path, which is why it can be restarted under a running VM.

The on-disk layout is small enough to describe in a table, and deliberately so:

OffsetRegion
0Superblock, 4 KiB, mirrored in the last 4 KiB of the LUN
1 MiBsanlock lockspace: one delta lease per host id, 1 to 2000
2 MiBThe metadata lease, held for every allocation
3 MiBOne paxos lease per volume slot, 1 MiB each, 1024 slots by default
after the leasesThe volume table: two 4 KiB records per slot, CRC32C and a generation, A and B copies
after the tableThe mailbox: a lease, then one 4 KiB block per host id
next extent boundaryData, in 256 MiB extents

There is no journal. Every record is one aligned 4 KiB block. A writer alternates between the two copies of a slot and a reader takes whichever has the higher valid generation, so a torn write can only lose the write in flight and never the previous version. The allocator bitmap is not stored at all; it is derived from the table on every mutation, under the metadata lease. On a 1 TB LUN all of that metadata is 1.25 GiB, and the crash-replay suite later rebuilt a pool one write and one torn sector at a time to prove the A/B scheme has no window where both copies are bad.

Snapshots, templates and linked clones come from qcow2 rather than from the pool, the same conclusion Proxmox 9 reached for its own thick LVM with the snapshot-as-volume-chain option. A snapshot is a sibling volume; the top of a chain is held exclusive and every backing volume beneath it is held shared, which is precisely what sanlock’s shared mode is for, and it means one template can be in use by clones on every node at once.

Prior art, and the command that is not atomic

I was not the first person to want this. In late October I found two projects doing VMFS-style shared LUNs for Proxmox, and both are kernel filesystems: CetraFS is a new clustered filesystem shipped as a DKMS module, and MeshXFS is a fork of XFS, a few hundred thousand lines, also DKMS. Both coordinate through the SCSI COMPARE AND WRITE command on the LUN.

That last detail is what settled my own design. MeshXFS’s documentation reports that LIO, the Linux target that sits under Unraid, TrueNAS and most homelab storage, returns success for COMPARE AND WRITE without the operation being atomic. A lock built on an atomic primitive the storage only pretends to have is not a lock. sanlock’s disk Paxos does not need COMPARE AND WRITE or persistent reservations to acquire a lease; it needs reads and writes to land in order, which every disk promises.

The no-kernel-module choice was the other half. Both projects list the exact kernels they were tested against and need a rebuild for each new one. A userspace daemon plus device-mapper has no such coupling, and I will take a smaller feature set over a storage layer that breaks on a kernel update.

Two hosts, one disk, on purpose

A lease model that only allows one holder cannot do live migration, because Proxmox activates the volume on the target and the target’s QEMU opens the disk read-write before switchover. For a few seconds two hosts legitimately have the same writable volume open. That window is the only place the design gets interesting.

The target asks for the volume in shared mode. The source, which holds it exclusive, has to agree to convert. In the prototype it learned about the request through a sanlock host event, which is a doorbell with a 64-bit payload that arrives once per lease renewal. Measured on the lab that was 8 to 30 seconds per handoff, and a VM with several disks needed several of them. Migrations took 20 to 40 seconds and most of it was waiting for a bell to ring.

Format v2 replaced the bell with a mailbox on the LUN: one 4 KiB block per host id, written by senders under its own small lease, polled by its owner once a second. The handoff dropped to about a second, and live migration of the 2 GiB test guest now takes 7 to 12 seconds wall time with downtime under 200 ms. When the source deactivates after switchover, the target’s upgrader loop converts back to exclusive within two seconds, and the window is closed.

The detail Proxmox gives you for free

I expected to need a hint field in the volume record to tell the plugin a migration was in progress. It turned out Proxmox already sets PVE_MIGRATED_FROM in the environment of the target’s start before it calls the plugin to activate the volume. The plugin reads the guest’s config from the source node and asks the daemon for every one of its volumes at once. The flag I designed was never written.

The watchdog that never fired

The plan I wrote before any code had one line in bold: resolve the watchdog question first, because nothing else proceeds until it works. Fencing in this model is wdmd on a kernel watchdog device. If a host cannot renew its lease, wdmd stops petting the watchdog and the hardware resets the machine before any peer is allowed to take over. If the watchdog does not actually reset the machine, there is no fencing, and the whole safety argument is a story.

The lab nodes are HP EliteDesk 800 G6 minis. Their iTCO timer loads cleanly, reports a 30 second heartbeat, and never resets the machine. I opened the device, did not pet it, and watched the countdown sit at 30 for four minutes while the box carried on. With sanlock frozen on a node that was wired to it, the node went 400 seconds without a reset before I gave up waiting.

The software watchdog does fire. With wdmd pointed at softdog, the same frozen node reset 123 seconds after its last renewal. So the lab layout became a small ordering unit that loads iTCO first so Proxmox’s own watchdog multiplexer takes the hardware device, a udev symlink that names softdog /dev/watchdog-soft, and wdmd told to use that. Proxmox HA self-fencing on these two nodes is therefore nominal, and the README says so. A production node needs a watchdog that has been tested by not petting it, or IPMI fencing, and I would not trust either on a new box until I had watched it reboot.

A chaos suite, and the four bugs it found

The prototype was tested by hand on the 28th. The rule I set for the next day was that nothing touching the on-disk format or the lease model would land again until the tests were scripts that ran unattended and left a log. Twelve scenarios, each with an expected outcome and a timeout, each resetting the lab to a known state afterward.

The crash scenarios run a writer inside the test guest that writes sequence-numbered 4 KiB blocks and fsyncs each one, logging what was acknowledged. After the crash, the survivor reads the disk and checks that every acknowledged block is intact and that at most the block in flight is torn. That verifier is the only reason I can write the sentence “every block the guest got an fsync for was there” and mean it.

ScenarioHowWhat must be true afterward
Holder hard reset mid-writesysrq-bSurvivor acquires; verifier data consistent to the last fsync
sanlock frozen on the holderSIGSTOPNode reset by the watchdog before a peer can acquire
noxd killed under a running guestSIGKILLGuest unaffected; leases re-adopted on restart
noxd killed mid-createSIGKILL during createNo half record; nox check clean
Concurrent create and delete from both nodes200 iterationsNo duplicate names, no overlapping extents
Delete racing an activateone node eachExactly one wins; the loser gets a clear error
Migration aborted mid-copykill the target QEMUSource back to exclusive; target leases gone
Clock skewone node five minutes offNo effect
iSCSI path lost on the holderdrop the trafficHolder fenced before the survivor acquires
iSCSI path lost on bothstop the targetBoth fence; pool consistent when the target returns
Source loses storage mid-migrationdrop traffic during the copyNever two live copies; guest recoverable
Second start without a clusterstandalone activateRefused in under a second, naming the holder

The log of every run is one line in a results file, and that file is honest in a way a README cannot be: 51 recorded runs on the 29th, 20 of them failures. Some were harness bugs, the usual kind (a pkill pattern matching its own shell, a migration finishing before the kill landed, the verifier reading the CRC from the wrong offset). Four were the product:

That last one is the one I would have shipped. It does nothing wrong on a lab where both clocks come from the same NTP server, which is to say on every lab.

The fence that only looked like it worked

Here is the finding that made the day.

sanlock fences a host by killing the processes that hold its leases, and only escalates to the watchdog if those processes will not die. In nox, the process holding the leases is noxd. The processes actually writing the LUN are the guests’ QEMUs. When a node loses its path to the storage while sanlock itself keeps running (a dropped iSCSI session rather than a crash), sanlock kills noxd, sees every lease pid gone, considers the host clean, and disarms the watchdog. The guest keeps its device-mapper device. If the LUN comes back to that node after a survivor has taken the volume, both can write it.

Why it passed twice before it failed

In several runs the host did fence, because noxd happened to be stuck in uninterruptible I/O on the dead LUN when the kill arrived, could not be reaped, and the watchdog fired on its behalf. Whether that happens is a race on noxd’s I/O timing. The same binary passed the path-loss scenario twice and failed it once, and the two passes were luck. A green run is a measurement of one afternoon, not a proof.

My first instinct was to forbid sanlock from killing noxd at all, so the daemon would stay alive, keep the lockspace, and let the watchdog handle it. That does not work. With both kill signals forbidden sanlock falls back to SIGKILL rather than to nothing, and the setting that restricts everything wedged sanlock’s own acquires on that connection. You cannot keep noxd alive through a kill, and keeping it alive would not stop the guest anyway.

The answer was the same one libvirt uses: a killpath. noxd registers a helper with sanlock at startup, and when a lease is lost sanlock runs the helper instead of reaching for signals. The helper finds every local process that holds one of the pool’s device-mapper devices, kills it, tears the devices down, and then stops noxd. While a guest still holds a volume, noxd refuses to be cleared, so a guest wedged in dead-storage I/O that cannot be reaped takes the whole host down by watchdog instead. Either way, the guest is gone before a survivor acquires. The path-loss scenario now passes deterministically with one of two outcomes recorded in the log: guest killed and host stays up, or host reset. Both are correct.

Then a second layer, where the storage allows it. SCSI-3 persistent reservations let a survivor tell the array to reject writes from a dead host’s key, independent of any watchdog. I wrote the primitives over the SG_IO ioctl, used the all-registrants reservation type so every live node writes concurrently and a preempted one cannot, and proved it two-node on a zvol-backed LIO target: both nodes writing, one preempted, its writes rejected at the array while the other carried on. It is off by default and never required, for a reason that matters to anyone reading this on a homelab: a file-backed LIO target answers the persistent reservation queries and does not reliably enforce them. The lab’s main LUN is file-backed. So nox probes first, refuses to arm enforcement with fewer than two hosts registered, and treats the node-local fence as the floor.

The fix I credited to the wrong thing

The hardest scenario was the last one I added: the source of a live migration loses its storage in the middle of the copy. Safety held every time. The source was fenced, there was never a moment with two live copies of the guest, the verifier’s data was intact, the pool checked clean. But the guest could not be restarted afterward.

The handoff had taken each volume’s lease to shared on both sides. The fence killed the source’s guest, and nothing released those shared leases, because noxd holds its leases persistently so that a daemon restart is invisible to running guests. sanlock kept them alive as orphans. A volume was now held shared by a host with no guest and no device, and the next exclusive acquire blocked forever. Neither the repair tool nor a daemon restart cleared it. Rebooting both nodes did.

I added a reaper that releases a held lease once its device has been gone for thirty seconds, ran the scenario once, watched it pass, and wrote “both bugs fixed and validated” in the roadmap.

The confirmation run failed.

The leftover leases were held by a dead generation of the source host, and sanlock refuses a direct release of those by design. What actually recovers the guest is something else I had added for a different reason: after an iSCSI re-login the LUN’s device node is re-created, the running daemon’s file descriptor points at a device that no longer exists, and every lease operation fails until noxd is restarted. A healthcheck now notices that the current descriptor errors while a fresh open of the same path works, and exits so systemd restarts it. The restart gives the node a fresh descriptor and a fresh host generation, and the next guest start’s exclusive acquire reclaims the dead-generation shared holders the way sanlock always meant it to. No reboot, no manual step, and the scenario passes end to end including the guest coming back.

I left the correction in the roadmap under the note it corrects. The reaper stays, because it covers a different leftover. But the lesson is the same one the fence taught an hour earlier, and I needed to be taught it twice in one day: one passing run is an anecdote.

Timeouts that must agree

The last class of problem is arithmetic, and it is the part most likely to bite anyone who installs this on their own storage.

sanlock gives up on a host eight times its I/O timeout after the last successful renewal, and lets others take its leases about 45 seconds after that. The node itself must get an I/O error back from a failed path before that window closes, or it fences itself for a blip that would have cleared. At the default I/O timeout of 10 seconds the window is 80 seconds. Proxmox’s stock iSCSI replacement timeout is 120 seconds. Out of the box, those two numbers mean a short path flap resets your node.

The installer now sets the replacement timeout to 15 seconds, and the pool records the I/O timeout in its superblock so every host joins with the same value. I measured what raising it actually buys:

Failureio_timeout 10io_timeout 20
Hard reset, holder gone at once~77 s to survivor acquiring~77 s
Storage path lost, holder self-fences~150 s~224 s

Raising the timeout does not speed anything up. It buys tolerance for a storage stall shorter than the window, at the cost of slower recovery from a real path loss, and it leaves clean-crash takeover where it was, because that is floored by the survivor’s dead-host detection rather than by the holder. Lowering it to 5 would give a 40 second window, which is shorter than a single iSCSI command can take to fail. Ten is the default because it is the value the arithmetic allows, and the README says to change it only with the path timeouts measured to match.

How it compares

OptionLock livesStandalone nodesFences a wedged nodeSnapshots and clonesKernel code
LVM on iSCSI (what Proxmox ships)cluster filesystemno protectionnoqcow2 chains since PVE 9device-mapper
OCFS2 / GFS2on disk, via a DLMneeds the cluster stackwith a fencing stack to tuneyesa clustered filesystem
CetraFS / MeshXFSon disk, via COMPARE AND WRITEin principleself-fence or persistent reservationsyesDKMS module per kernel
NFS or Cephon the serveryesserver sideyesnone you manage
noxon the LUN, sanlockyes, by designwatchdog, killpath, optional PRqcow2 chains, templates, linked clonesdevice-mapper only
Honesty clause

This is a working prototype, not a product. It has run on two nodes, over 1 GbE, against a file-backed LIO target, with a software watchdog because the hardware one does not fire. Multipath is written but untested. There is no thin provisioning: a qcow2 volume reserves its full size, as Proxmox’s own LVM chains do. The persistent-reservation layer has been proven on one zvol target and nowhere else. A two-node cluster still needs pvecm expected 1 or a QDevice before Proxmox will let you start a recovered guest, which is Proxmox’s rule and not mine. Nothing in this article should be read as a recommendation to move your VMs onto it today.

What it cost

A week, dated. The design notes are from the 25th. The prototype live-migrated its first VM on the 28th. The chaos suite went green on the 29th, after the fence and the orphan leases were fixed. The roadmap I wrote on the evening of the 28th estimated 35 focused days for the phases that are now done, and I am not going to pretend I know why the estimate was that wrong, except that most of the work turned out to be configuring things that already existed rather than inventing them.

Rules about the order of work. No change to the format or the lease model after the chaos suite exists unless the suite says it is safe. The on-disk mailbox, the format version bump, the chain support and the fence all landed under that rule, and the two races the suite caught were caught because of it.

A lot of reading of other people’s design. sanlock’s orphan leases, its killpath, its shared mode, its host generations; Proxmox’s snapshot-as-volume-chain model; libvirt’s lease integration; the LIO quirk where a persistent reservation command returns a transient not-ready even as it takes effect. Almost none of nox is clever. Most of it is knowing which existing mechanism to call, and in what order.

A lab that is honest about its limits. No IPMI, no hardware watchdog that works, no second NIC for multipath, no smart plug for real power loss. Every number in the README names the hardware it came from and the script that produced it, because a takeover time measured on a mini PC against a file-backed target is a fact about that lab and not a promise.

What this isn’t

It is not a filesystem, and it will not become one. The moment shared files are needed the design changes, and I would rather say no than drift.

It is not high availability. The pool has no notion of quorum, which is what makes standalone nodes work, and it is also why Proxmox’s own HA stack still decides when a guest may be restarted. nox decides who may hold a disk. Those are different questions, and keeping them separate is the point.

It is not Ceph. The LUN is a single source of truth and redundancy is the SAN’s job. If your storage is a pile of disks across hosts, this is the wrong tool and Ceph is the right one.

And it is not, yet, something I would hand to a stranger with a SAN and walk away from. It is something I would hand to a stranger with a scratch LUN and a weekend, and ask them to run the chaos suite on hardware that is not mine.

Closing thought

The thing I keep coming back to is how little of this was storage code.

The data path is a device-mapper linear table, which LVM has been loading for twenty years. The locking is sanlock, which oVirt has been trusting for fifteen. The snapshots are qcow2. The fencing is a watchdog and a kill. What nox adds is a 4 KiB record format, a daemon that knows which of those mechanisms to call and in what order, and a Perl module that lets Proxmox treat the result as ordinary shared storage.

What it took to get there was not writing any of that but proving it: a verifier that counts fsyncs, a results file with 20 failures in it, a fence that passed twice before it failed, and a fix I announced a run too early. Every mechanism in the stack already worked. The week went into finding out where I had wired them together wrong, and the only tool that found those places was one that broke things on purpose and wrote down what happened.

The lock is on the LUN now. The nagging feeling is gone. I would like a hardware watchdog that fires before I trust the rest.