Fix the boot issue for nixos 2605+ (#3813)
Ventoy CI / build (push) Canceled after 0s
Mirror GitHub to Gitee / Sync-GitHub-to-Gitee (push) Canceled after 0s

This commit is contained in:
longpanda
2026-12-02 18:04:44 +08:00
parent 26980f9d59
commit db894fd970
5 changed files with 71 additions and 32 deletions
@@ -1,30 +0,0 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
exit 0
fi
ventoy_udev_disk_common_hook $*
# OK finish
set_ventoy_hook_finish
@@ -0,0 +1,11 @@
[Unit]
Description=Ventoy Disk Setup
After=systemd-udevd.service
Before=initrd-root-device.target sysroot.mount
ConditionPathIsDirectory=/ventoy
WantedBy=initrd-root-device.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=-/ventoy/busybox/sh /ventoy/hook/nixos/ventoy-disk.sh
+39
View File
@@ -0,0 +1,39 @@
#!/ventoy/busybox/sh
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" 'noreplace'
set_ventoy_hook_finish
rm -f /dev/mapper/ventoy
rm -f /dev/mapper/VentoyPart
mkdir -p /run/udev/rules.d/
ventoy_copy_file /ventoy/hook/default/10-dm.rules /run/udev/rules.d/10-dm.rules 0644
ventoy_copy_file /ventoy/hook/default/11-dm-enable.rules /run/udev/rules.d/11-dm-enable.rules 0644
ventoy_copy_file /ventoy/hook/default/13-dm-disk.rules /run/udev/rules.d/13-dm-disk.rules 0644
udevadm control --reload-rules
udevadm trigger --action=change --sysname-match='dm-*'
udevadm settle
rm -f /etc/systemd/system/initrd-root-device.target.wants/ventoy-disk.service
rm -f /etc/systemd/system/ventoy-disk.service
+12 -2
View File
@@ -19,7 +19,17 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh
vtRuleFile=$($FIND / -name '*.rules' -type f | $GREP udev | $HEAD -n1)
PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool:$PATH
ventoy_add_udev_rule_with_path "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace" "${vtRuleFile%/*}/99-ventoy.rules"
if [ -e /etc/systemd/system ]; then
system=$($FIND /nix -type d | $GREP 'initrd-units$')
echo "nixos with systemd $system" >> $VTLOG
mkdir -p $system/initrd-root-device.target.wants
cp -a $VTOY_PATH/hook/nixos/ventoy-disk.service $system/
ln -sf $system/ventoy-disk.service $system/initrd-root-device.target.wants/ventoy-disk.service
else
echo "nixos init script" >> $VTLOG
vtRuleFile=$($FIND / -name '*.rules' -type f | $GREP udev | $HEAD -n1)
ventoy_add_udev_rule_with_path "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace" "${vtRuleFile%/*}/99-ventoy.rules"
fi