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

@ -38,16 +38,25 @@ monero_data_dir: /var/lib/monero
# The whole device, no partition table: this disk has one job and a partition
# table would only add a layer that can disagree with itself.
#
# monero_data_device is used ONLY to create the filesystem, once. Everything
# afterwards - fstab, the mount, the systemd unit - goes by UUID, because
# /dev/sdX ordering is decided by the kernel at boot and is not a stable name
# for anything. This estate has been bitten eight times by an identifier that
# was written down once and then moved.
monero_data_device: /dev/sdb
# The disk is known by two names, for two different moments:
#
# monero_data_label is its identity once it holds a filesystem. Every run looks
# for it first, and if it is there the device name is never consulted at all -
# a routine run cannot be broken by a device name, because it does not read one.
#
# monero_data_device is used ONLY on the first run, to find the blank disk and
# create that filesystem. It must be a name fixed before the VM boots: Proxmox
# passes the slot ("scsi1") in as the disk's serial, and udev publishes it under
# /dev/disk/by-id. That survives reboots and `qm disk move` alike. NEVER
# /dev/sdX: the kernel hands those out in probe order, and on 2026-10-04 a reboot
# after moving this disk to the SSD swapped sda and sdb - the value written here
# then named the ROOT disk.
monero_data_label: monero-data
monero_data_device: /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1
monero_data_fstype: ext4
# -m 0: the 5% ext4 reserve exists to stop root-owned daemons deadlocking a full
# root filesystem. On a dedicated data disk it is 25 GB thrown away.
monero_data_mkfs_opts: "-m 0 -L monero-data"
monero_data_mkfs_opts: "-m 0 -L {{ monero_data_label }}"
# --- Network ----------------------------------------------------------------
# P2P is OUTBOUND ONLY. No inbound port is published from the edge host, so the