]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh
linux raw boot
[Ventoy.git] / IMG / cpio / ventoy / hook / debian / udev_disk_hook.sh
index 6dd6882b39c12856d934db2c3b5e86c09516b8d1..a0f88b1518c661c4edb36ab40d743cabb2d410fd 100644 (file)
@@ -43,6 +43,18 @@ ventoy_os_install_dmsetup() {
     # install md-modules
     LINE=$($GREP ' md-modules.*\.udeb'  $VTOY_PATH/iso_file_list)
     if [ $? -eq 0 ]; then
+        LINTCNT=$($GREP -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 ' md-modules.*\.udeb'  $VTOY_PATH/iso_file_list | $GREP $VER)
+            LINTCNT=$($GREP ' md-modules.*\.udeb'  $VTOY_PATH/iso_file_list | $GREP -c $VER)
+            if [ $LINTCNT -gt 1 ]; then
+                vtlog "Still more than one pkgs, use the first one..."
+                LINE=$($GREP ' md-modules.*\.udeb'  $VTOY_PATH/iso_file_list | $GREP  -m1 $VER)
+            fi
+        fi
         install_udeb_from_line "$LINE" ${vt_usb_disk} 
     fi
 
@@ -50,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*")
@@ -83,6 +95,8 @@ 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}"
@@ -99,7 +113,18 @@ 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"
 else
     vtlog "$1 is NOT USB device (bus $ID_BUS)"