mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-03-01 04:16:21 +00:00
Add create_ventoy_iso_part_dm.sh (#3497)
This commit is contained in:
38
INSTALL/tool/create_ventoy_iso_part_dm.sh
Normal file
38
INSTALL/tool/create_ventoy_iso_part_dm.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Please run with sudo ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
oldpwd=$(pwd)
|
||||
VPART=""
|
||||
|
||||
if dmsetup -h > /dev/null 2>&1; then
|
||||
VPART_MAJOR_MINOR=$(dmsetup table ventoy | head -n 1 | awk '{print $4}')
|
||||
cd /sys/class/block/
|
||||
for t in *; do
|
||||
if grep -q "^${VPART_MAJOR_MINOR}$" $t/dev; then
|
||||
VPART=$t
|
||||
echo 0 $(cat /sys/class/block/$VPART/size) linear /dev/$VPART 0 | dmsetup create $VPART
|
||||
dmsetup mknodes "$VPART" > /dev/null 2>&1
|
||||
break
|
||||
fi
|
||||
done
|
||||
cd $oldpwd
|
||||
|
||||
if [ -z "$VPART" ]; then
|
||||
echo "$VPART_MAJOR_MINOR not found"
|
||||
dmsetup ls; dmsetup info ventoy; dmsetup table ventoy
|
||||
exit 1
|
||||
else
|
||||
if [ ! -b "/dev/mapper/$VPART" ]; then
|
||||
udevadm trigger --type=devices --action=add > /dev/null 2>&1
|
||||
udevadm settle > /dev/null 2>&1
|
||||
fi
|
||||
echo "Create /dev/mapper/$VPART success"
|
||||
fi
|
||||
else
|
||||
echo "dmsetup program not avaliable"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user