2 #************************************************************************************
3 # Copyright (c) 2020, longpanda <admin@ventoy.net>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #************************************************************************************
20 .
/ventoy
/hook
/ventoy
-hook-lib.sh
22 if is_ventoy_hook_finished
; then
26 vtlog
"####### $0 $* ########"
28 VTPATH_OLD
=$PATH; PATH
=$BUSYBOX_PATH:$VTOY_PATH/tool
:$PATH
34 insmod
"$1" >> $VTOY_PATH/log
2>&1
44 vtlog
"insmod $kv $kbit"
46 check_insmod
/ventoy_openwrt
/$kv/$kbit/dax.ko
47 check_insmod
/ventoy_openwrt
/$kv/$kbit/dm
-mod.ko
51 if grep -q "device-mapper" /proc
/devices
; then
52 vtlog
"device-mapper enabled by system 0"
56 check_insmod
/ventoy
/modules
/dax.ko
57 check_insmod
/ventoy
/modules
/dm
-mod.ko
59 if grep -q "device-mapper" /proc
/devices
; then
60 vtlog
"device-mapper enabled by system 1"
64 if [ -f /ventoy_openwrt.xz
]; then
65 tar xf
/ventoy_openwrt.xz
-C /
66 rm -f /ventoy_openwrt.xz
69 if uname
-m | egrep -q "amd64|x86_64"; then
73 if lsmod
| grep -q 'dm-mod'; then
74 vterr
"insmod generic failed"
83 for i
in $(ls /sys/class/block/); do
84 if ! [ -e /dev
/$i ]; then
85 blkdev_num
=$(sed 's/:/ /g' /sys/class/block/$i/dev)
86 vtlog
"mknod -m 0666 /dev/$i b $blkdev_num"
87 mknod
-m 0666 /dev
/$i b
$blkdev_num
91 wait_for_usb_disk_ready
93 vtdiskname
=$(get_ventoy_disk_name)
94 if [ "$vtdiskname" = "unknown" ]; then
95 vtlog
"ventoy disk not found"
100 ventoy_udev_disk_common_hook
"${vtdiskname#/dev/}2" "noreplace"
102 blkdev_num
=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.
*\
([0-9][0-9]*\
).
*/\
1:\
2/')
103 vtDM=$(ventoy_find_dm_id ${blkdev_num})
104 echo -n $vtDM > /ventoy/vtDM
106 ventoy_create_dev_ventoy_part
110 mount /dev/ventoy2 /ventoy_rdroot
114 set_ventoy_hook_finish