diff --git a/IMG/cpio/ventoy/hook/debian/casper-perst-wa.sh b/IMG/cpio/ventoy/hook/debian/casper-perst-wa.sh new file mode 100644 index 00000000..9da3bf70 --- /dev/null +++ b/IMG/cpio/ventoy/hook/debian/casper-perst-wa.sh @@ -0,0 +1,19 @@ + +find_cow_device() { + tgt_pers_label="${1}" + vt_pers_label="" + vt_pers_dev="" + + if [ -f /ventoy/ventoy_persistent_label -a -f /ventoy/ventoy_persistent_dev ]; then + vt_pers_label=$(cat /ventoy/ventoy_persistent_label) + vt_pers_dev=$(cat /ventoy/ventoy_persistent_dev) + fi + + if [ "$tgt_pers_label" = "$vt_pers_label" ]; then + echo "$vt_pers_dev" + else + find_cow_device_back "$@" + fi +} + +find_cow_device_back() { diff --git a/IMG/cpio/ventoy/hook/debian/default-hook.sh b/IMG/cpio/ventoy/hook/debian/default-hook.sh index 5db56e35..bc61e107 100644 --- a/IMG/cpio/ventoy/hook/debian/default-hook.sh +++ b/IMG/cpio/ventoy/hook/debian/default-hook.sh @@ -31,6 +31,19 @@ if [ -e /init ] && $GREP -q '^mountroot$' /init; then $SED "s#^ *LIVEMEDIA=.*#LIVEMEDIA=/dev/mapper/ventoy#" -i /scripts/casper fi fi + + #workaround for issue #3718 + if [ -f $VTOY_PATH/ventoy_persistent_map -a -f /scripts/casper-helpers ]; then + echo 'fix casper cow udev issue' >> $VTLOG + if $GREP -q '^find_cow_device\(\).*{' /scripts/casper-helpers; then + VTINS_LINE=$($GREP -n '^find_cow_device\(\).*{' /scripts/casper-helpers | $AWK -F':' '{print $1}') + $AWK "NR < $VTINS_LINE" /scripts/casper-helpers > /ventoy/casper-helpers-tmp + $CAT $VTOY_PATH/hook/debian/casper-perst-wa.sh >> /ventoy/casper-helpers-tmp + $AWK "NR > $VTINS_LINE" /scripts/casper-helpers >> /ventoy/casper-helpers-tmp + $CAT /ventoy/casper-helpers-tmp > /scripts/casper-helpers + fi + fi + elif [ -e "$CD_DETECT" ]; then echo "$CD_DETECT exist, now add hook in it..." >> $VTLOG $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i "$CD_DETECT" diff --git a/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh b/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh index 2b413a47..4d62264d 100644 --- a/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh +++ b/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh @@ -512,6 +512,9 @@ ventoy_create_persistent_link() { VTLABEL=casper-rw fi + echo "$VTLABEL" > $VTOY_PATH/ventoy_persistent_label + echo "/dev/$vtDM" > $VTOY_PATH/ventoy_persistent_dev + vtlog "Persistent Label: ##${VTLABEL}##" if ! [ -e /dev/disk/by-label/$VTLABEL ]; then