monero: find the chain disk by its label, and a blank one by Proxmox slot

After the chain disk moved to the SSD, a reboot on 2026-10-04 swapped sda and
sdb, and monero_data_device: /dev/sdb then named the ROOT disk. The root-disk
guard caught it, but a routine run should never have been reading a device
name at all.

Every run now looks for the filesystem labelled monero-data first. If it is
there, monero_data_device is never consulted and the mount goes by that
filesystem's UUID. Only a blank disk is found by name, and the name is now
/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1: Proxmox passes the slot
in as the serial, so it is fixed before boot and survives `qm disk move`.

The by-id path is resolved with readlink before the root-disk guard compares
it, since a symlink path is never a prefix of /dev/sdb1 and the guard would
otherwise always pass. The UUID assert now also fails on two disks carrying
the same label.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
counterweight 2026-10-17 17:30:57 +02:00
parent c3a7ca0ba7
commit 71dbfbe5ff
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
4 changed files with 116 additions and 63 deletions

View file

@ -62,10 +62,15 @@ Three things there are load-bearing:
- **The whole device, no partition table.** One disk, one job; a partition table
is just another layer that can disagree with itself.
- **Everything after mkfs goes by UUID.** `/dev/sdX` ordering is decided by the
kernel at boot. This estate has been bitten eight times by an identifier
written down once whose thing then moved; `monero_data_device` is used *only*
to create the filesystem.
- **The device name is read once, ever.** Each run first looks for a filesystem
labelled `monero-data`; if it exists, `monero_data_device` is not consulted
and the mount goes by that filesystem's UUID. Only a blank disk is found by
name, and that name is the Proxmox slot as published under `/dev/disk/by-id`
(`...drive-scsi1`), fixed before the VM boots and kept across `qm disk move`.
Never `/dev/sdX`: the kernel assigns those in probe order, and on 2026-10-04 a
reboot swapped `sda` and `sdb`, leaving the old `/dev/sdb` value naming the
root disk. The root-disk guard caught it - but a routine run should never
have been reading the name in the first place.
- **`RequiresMountsFor=` in the unit.** `nofail` in fstab means a missing disk
does not drop a headless VM into an emergency shell - but without
`RequiresMountsFor` monerod would then start, find an empty directory, and