Add a cleanup service for Ventoy udev rules files
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s

When we boot an ISO file to the live system through Ventoy.
The ISO partition (e.g. /dev/sda1) is hold by the device-mapper which will block it to be mounted.
So Ventoy will create a mirror device-mapper /dev/mapper/VentoyPart for /dev/sda1.
Most live systems with GUI environment will auto mount Ventoy ISO partition by udisk.
So in 1.1.18 Venoty will inject an udev rule in the Live system in order to:
1. Block the original ISO partition (e.g. /dev/sda1) to be auto-mounted.
2. Force /dev/mapper/VentoyPart to be auto-mounted.

But the udev rule file was injected to /etc directory of the Live system, this will make the rule mistakenly inherited into the final installed system.
Originally, the /run directory would have been the most suitable location, but in some Live systems /run is not a static directory but an overlayfs which is created dynamically during boot which make it a little bit complex.
So we add a cleanup systemd/sysvinit service.
This commit is contained in:
longpanda
2026-11-23 20:26:11 +08:00
parent 8308a527ac
commit 2248d1f807
15 changed files with 313 additions and 53 deletions
@@ -0,0 +1,22 @@
#!/bin/sh
rm -f /etc/systemd/system-preset/80-ventoy-udev.preset
rm -f /etc/systemd/system/sysinit.target.wants/ventoy-udev*.service
rm -f /etc/systemd/system/ventoy-udev*.service
if [ -f /etc/systemd/system/snap.ubuntu-desktop-bootstrap.subiquity-server.service.d/10-ventoy-curtin-wa.conf ]; then
if [ -e /etc/systemd/system/snap.ubuntu-desktop-bootstrap.subiquity-server.service ]; then
:
else
rm -f /etc/systemd/system/ventoy-curtin-wa.service
rm -f /etc/systemd/system/snap.ubuntu-desktop-bootstrap.subiquity-server.service.d/10-ventoy-curtin-wa.conf
rm -rf /etc/ventoy_curtin
fi
fi
mkdir -p /run/udev/rules.d
mv /etc/udev/rules.d/*ventoy* /run/udev/rules.d/
rm -f $0
@@ -0,0 +1,15 @@
[Unit]
Description=Ventoy DM device udev attributes
After=systemd-udevd.service
[Service]
Type=oneshot
ExecStart=-udevadm trigger --subsystem-match=block --sysname-match=yyy
ExecStart=-udevadm trigger --subsystem-match=block --sysname-match=DMXXX
ExecStart=-udevadm settle
ExecStartPost=-/bin/sh /etc/ventoy-udev-cleanup.sh
RemainAfterExit=no
[Install]
WantedBy=sysinit.target