OK, elaborating a bit on the solution, because I want to emphasize that there are basically two parts here, and to record the full solution for posterity.
First: getting the dm-NN
names to be persistent. Thanks @szz9pza for this. When creating a volume, you can add --minor NN --persistent y
to force the mapped device to use a specific dm-NN
ID. (Or use lvchange to change it later, bearing in mind that changing this involves a detach/reattach.) Note that if the requested minor block device ID is already in use, the device will silently not be mapped. Use higher numbers, to avoid this. I used 96 and 97 for my first two guinea pigs.)
Second: Keeping dom0 from interpreting the contents of those partitions. Qubes does this automatically for the volumes it creates, using a few naming conventions to keep udev from scanning them to create /dev/disk/by-*
links. We need to add our own naming convention to exclude ours too.
Here’s where I noticed an issue: I added a /usr/lib/udev/rules.d/20-exclude-custom-lvms.rules
to keep the 60-persistent-storage*
rules from giving us links, but we were getting some from 13-dm-disk.rules
too. Specifically /dev/disk/by-uuid/*
and /dev/disk/by-label/*
which (a) Qubes excludes for its internal volumes already (see 12-qubes-ignore-lvm-devices.rules
), and (b) happens at #13, which would be before #20.
So I moved my file from 20-...
to 12-qubes-ignore-custom-lvm-devices.rules
, with these contents:
# This keeps later rules from scanning the volume for a filesystem in order to
# can create symlink device entries for the volume. To do so, dom0 would
# need to interpret the disk contents, which effectively reads untrusted data
# in dom0. So, don't do that.
ACTION!="add|change", GOTO="custom_dm_end"
SUBSYSTEM!="block", GOTO="custom_dm_end"
ENV{DM_UUID}!="LVM-*", GOTO="custom_dm_end"
# This takes uses a sentinel prefix of "custom_" to signal us to treat volumes
# this way.
ENV{DM_LV_NAME}=="custom_*", GOTO="custom_dm_ignore"
# These two volumes were created before I learned about this issue, so they
# don't have the right names, but I want to treat them the same way.
# (Update: I renamed them, but I kept this section and the GOTO above to
# keep a basic block around where I could match other patterns.)
# ENV{MINOR}=="96|97", GOTO="custom_dm_ignore"
# Make later rules ignore it.
LABEL="custom_dm_ignore"
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
ENV{DM_UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}="1"
# Export it.
LABEL="custom_dm_qubes_export"
ENV{QUBES_EXPORT_BLOCK_DEVICE}="1"
# Done.
LABEL="custom_dm_end"
Then I renamed my two existing guinea pig volumes to start with custom_
, and gave them persistent minor device IDs, and used qvm-block attach --persistent VMNAME dom0:dm-NN
with my newly-stable dm-NN
.
With that file in place, now I just need to (a) name the volume custom_*
to keep it from dom0 interpretation, and (b) give it a persistent minor device number, and: problem solved.