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 VTPATH_OLD
=$PATH; PATH
=$BUSYBOX_PATH:$VTOY_PATH/tool
:$PATH
24 ventoy_os_install_device_mapper_by_unsquashfs
() {
25 vtlog
"ventoy_os_install_device_mapper_by_unsquashfs $*"
27 vtKoExt
=$(ventoy_get_module_postfix)
28 vtlog
"vtKoExt=$vtKoExt"
30 vtoydm
-i -f $VTOY_PATH/ventoy_image_map
-d $1 > $VTOY_PATH/iso_file_list
32 vtline
=$(grep '[-][-] livecd.sqfs ' $VTOY_PATH/iso_file_list)
33 sector
=$(echo $vtline | awk '{print $(NF-1)}')
34 length=$(echo $vtline | awk '{print $NF}')
36 vtoydm -E -f $VTOY_PATH/ventoy_image_map -d $1 -s $sector -l $length -o $VTOY_PATH/fsdisk
38 dmModPath="/lib/modules/$2/kernel/drivers/md/dm-mod.$vtKoExt"
39 echo $dmModPath > $VTOY_PATH/fsextract
40 vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk
42 if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
43 vtlog "success $VTOY_PATH/sqfs${dmModPath}"
44 insmod $VTOY_PATH/sqfs${dmModPath}
51 ventoy_os_install_device_mapper() {
52 vtlog "ventoy_os_install_device_mapper"
54 if grep -q 'device
-mapper' /proc/devices; then
55 vtlog "device-mapper module already loaded"
60 if ventoy_os_install_device_mapper_by_unsquashfs $1 $vtKerVer; then
61 vtlog "unsquashfs success"
63 vterr "unsquashfs failed"
67 wait_for_usb_disk_ready
69 vtdiskname=$(get_ventoy_disk_name)
70 ventoy_os_install_device_mapper $vtdiskname
72 ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
76 set_ventoy_hook_finish