mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-12-05 11:56:51 +01:00
Fix the boot issue for nixos 2605+ (#3813)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*Ventoy*", ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="0"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*Ventoy*", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="0"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*Ventoy*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="0"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*Ventoy*", ACTION=="add|change", IMPORT{builtin}="blkid"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*ventoy*", ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="0"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*ventoy*", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="0"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*ventoy*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="0"
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ENV{DM_NAME}=="*ventoy*", ACTION=="add|change", IMPORT{builtin}="blkid"
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -19,7 +19,17 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool:$PATH
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user