]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - IMG/cpio/ventoy/hook/rhel7/ventoy-make-link.sh
Fix the issue that VTOY_LINUX_REMOUNT=1 does not work on some distros (e.g. Pop OS...
[Ventoy.git] / IMG / cpio / ventoy / hook / rhel7 / ventoy-make-link.sh
index ee68b12459b24331bd7ca4bd9659f96f40601c57..100815a87df4a0ae648e9ff83e52cc61dff85dd0 100644 (file)
@@ -23,17 +23,28 @@ if [ ! -e /dev/dm-0 ]; then
     exit 0
 fi
 
-if ! [ -e /dev/mapper/ventoy ]; then
-    vtlog "link to /dev/mapper/ventoy"
-    ln -s /dev/dm-0 /dev/mapper/ventoy
+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})
+
+if [ -e /dev/mapper/ventoy ]; then
+    vtlog "/dev/mapper/ventoy already exist"
+else
+    vtlog "link /dev/$vtDM to /dev/mapper/ventoy"
+    ln -s /dev/$vtDM /dev/mapper/ventoy
 fi
 
-VTLABEL=$($BUSYBOX_PATH/blkid /dev/dm-0 | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
+VTLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
 vtlog "VTLABEL=$VTLABEL"
 
 if [ -n "$VTLABEL" ]; then
-    if ! [ -e "/dev/disk/by-label/$VTLABEL" ]; then
-        vtlog "link to /dev/disk/by-label/$VTLABEL"
-        ln -s /dev/dm-0 "/dev/disk/by-label/$VTLABEL"
+    if ! [ -d /dev/disk/by-label ]; then
+        mkdir -p /dev/disk/by-label
+    fi
+
+    if [ -e "/dev/disk/by-label/$VTLABEL" ]; then
+        vtlog "/dev/disk/by-label/$VTLABEL already exist"
+    else
+        vtlog "link /dev/$vtDM to /dev/disk/by-label/$VTLABEL"
+        ln -s /dev/$vtDM "/dev/disk/by-label/$VTLABEL"
     fi
 fi