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
31 for i
in $(ls /sys/class/block/); do
32 if ! [ -e /dev
/$i ]; then
33 blkdev_num
=$(sed 's/:/ /g' /sys/class/block/$i/dev)
34 vtlog
"mknod -m 0666 /dev/$i b $blkdev_num"
35 mknod
-m 0666 /dev
/$i b
$blkdev_num
43 insmod
"$1" >> $VTOY_PATH/log
2>&1
53 vtlog
"insmod $kv $kbit"
55 check_insmod
/ventoy_openwrt
/$kv/$kbit/dax.ko
56 check_insmod
/ventoy_openwrt
/$kv/$kbit/dm
-mod.ko
60 if grep -q "device-mapper" /proc
/devices
; then
61 vtlog
"device-mapper enabled by system 0"
65 check_insmod
/ventoy
/modules
/dax.ko
66 check_insmod
/ventoy
/modules
/dm
-mod.ko
68 if grep -q "device-mapper" /proc
/devices
; then
69 vtlog
"device-mapper enabled by system 1"
73 if [ -f /ventoy_openwrt.xz
]; then
74 tar xf
/ventoy_openwrt.xz
-C /
75 rm -f /ventoy_openwrt.xz
78 if uname
-m | egrep -q "amd64|x86_64"; then
82 if lsmod
| grep -q 'dm-mod'; then
83 vterr
"insmod generic failed"
96 vtusb_disk
=$(get_ventoy_disk_name)
97 if check_usb_disk_ready
"$vtusb_disk"; then
98 vtlog
"get_ventoy_disk_name $vtusb_disk ready"
101 vtlog
"get_ventoy_disk_name $vtusb_disk not ready"
108 vtdiskname
=$(get_ventoy_disk_name)
109 if [ "$vtdiskname" = "unknown" ]; then
110 vtlog
"ventoy disk not found"
115 ventoy_udev_disk_common_hook
"${vtdiskname#/dev/}2" "noreplace"
117 blkdev_num
=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.
*\
([0-9][0-9]*\
).
*/\
1:\
2/')
118 vtDM=$(ventoy_find_dm_id ${blkdev_num})
119 echo -n $vtDM > /ventoy/vtDM
121 ventoy_create_dev_ventoy_part
127 mount /dev/ventoy2 /ventoy_rdroot
131 set_ventoy_hook_finish