X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/05a1b863a66bf72b26e5d87570c4e0e61b9736cd..HEAD:/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh diff --git a/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh b/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh index 7edcbe7..251f046 100644 --- a/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh +++ b/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh @@ -21,6 +21,8 @@ ventoy_os_install_dmsetup() { + vtlog "ventoy_os_install_dmsetup $1 ..." + vt_usb_disk=$1 # dump iso file location @@ -39,8 +41,20 @@ ventoy_os_install_dmsetup() { fi # install md-modules - LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list) + LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list) if [ $? -eq 0 ]; then + LINTCNT=$($GREP -i -c ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list) + if [ $LINTCNT -gt 1 ]; then + vtlog "more than one pkgs, need to filter..." + VER=$($BUSYBOX_PATH/uname -r) + + LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i $VER) + LINTCNT=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i -c $VER) + if [ $LINTCNT -gt 1 ]; then + vtlog "Still more than one pkgs, use the first one..." + LINE=$($GREP -i ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP -i -m1 $VER) + fi + fi install_udeb_from_line "$LINE" ${vt_usb_disk} fi @@ -48,7 +62,7 @@ ventoy_os_install_dmsetup() { if $GREP -q 'device-mapper' /proc/devices; then vtlog "device mapper module is loaded" else - vtlog"device mapper module is NOT loaded, now load it..." + vtlog "device mapper module is NOT loaded, now load it..." VER=$($BUSYBOX_PATH/uname -r) KO=$($FIND /lib/modules/$VER/kernel/drivers/md -name "dm-mod*") @@ -81,11 +95,17 @@ if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then exit 0 fi +vtlog "==== $0 $* ====" + dmsetup_path=$(ventoy_find_bin_path dmsetup) if [ -z "$dmsetup_path" ]; then ventoy_os_install_dmsetup "/dev/${1:0:-1}" fi +if ! $GREP -q 'device-mapper' /proc/devices; then + ventoy_os_install_dmsetup "/dev/${1:0:-1}" +fi + ventoy_udev_disk_common_hook $* # @@ -93,8 +113,20 @@ ventoy_udev_disk_common_hook $* # So if ventoy is installed on a non-USB device, we just mount /cdrom here except # for these has boot=live or boot=casper parameter in cmdline # -if echo $ID_BUS | $GREP -q -i usb; then +VT_BUS_USB="" +if [ -n "$ID_BUS" ]; then + if echo $ID_BUS | $GREP -q -i usb; then + VT_BUS_USB="YES" + fi +else + if $BUSYBOX_PATH/ls -l /sys/class/block/${1:0:-1} | $GREP -q -i usb; then + VT_BUS_USB="YES" + fi +fi + +if [ -n "$VT_BUS_USB" ]; then vtlog "$1 is USB device" + echo /dev/$1 > /ventoy/list-devices-usb-part else vtlog "$1 is NOT USB device (bus $ID_BUS)" @@ -102,8 +134,16 @@ else vtlog "boot=, or casper, don't mount" else vtlog "No boot param, need to mount" - $BUSYBOX_PATH/mkdir /cdrom - $BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH /cdrom + echo /dev/$1 > /ventoy/list-devices-usb-part + fi +fi + +#special process for Linx +if $BUSYBOX_PATH/uname -r | $GREP -q "^2\.6"; then + if $GREP -q "linx" /proc/version; then + blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/') + vtDM=$(ventoy_find_dm_id ${blkdev_num}) + echo "/dev/$vtDM" > /ventoy/list-devices-usb-part fi fi