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
24 ventoy_os_install_dmsetup
() {
25 vtlog
"ventoy_os_install_dmsetup $1"
29 # dump iso file location
30 $VTOY_PATH/tool
/vtoydm
-i -f $VTOY_PATH/ventoy_image_map
-d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
33 LINE
=$($GREP 'kernel-[0-9].*\.rpm' $VTOY_PATH/iso_file_list)
35 install_rpm_from_line
"$LINE" ${vt_usb_disk}
38 $BUSYBOX_PATH/modprobe dm
-mod
40 vtlog
"dmsetup install finish, now check it..."
42 dmsetup_path
=/ventoy
/tool
/dmsetup
43 if [ -z "$dmsetup_path" ]; then
44 vterr
"dmsetup still not found after install"
45 elif $dmsetup_path info
>> $VTLOG 2>&1; then
46 vtlog
"$dmsetup_path work ok"
48 vterr
"$dmsetup_path not work"
53 if is_ventoy_hook_finished
|| not_ventoy_disk
"${1:0:-1}"; then
54 # /dev/vtCheatLoop come first
55 if [ "$1" = "$vtCheatLoop" ] && [ -b $VTOY_DM_PATH ]; then
56 ventoy_copy_device_mapper
/dev
/$vtCheatLoop
61 ventoy_os_install_dmsetup
"/dev/${1:0:-1}"
63 ventoy_udev_disk_common_hook $
* "noreplace"
65 $BUSYBOX_PATH/mount
$VTOY_DM_PATH /mnt
/ventoy
68 # We do a trick for rhel6 series here.
69 # Use /dev/$vtCheatLoop and wapper it as a removable cdrom with bind mount.
70 # Then the anaconda installer will accept /dev/$vtCheatLoop as the install medium.
72 ventoy_copy_device_mapper
/dev
/$vtCheatLoop
74 $BUSYBOX_PATH/cp -a /sys
/devices
/virtual
/block
/$vtCheatLoop /tmp
/ >> $VTLOG 2>&1
75 echo 19 > /tmp
/$vtCheatLoop/capability
76 $BUSYBOX_PATH/mount
--bind /tmp
/$vtCheatLoop /sys
/block
/$vtCheatLoop >> $VTLOG 2>&1
79 set_ventoy_hook_finish