]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/rhel6/udev_disk_hook.sh
Fix iPXE '-Werror=zero-length-bounds' (#202)
[Ventoy.git] / IMG / cpio / ventoy / hook / rhel6 / udev_disk_hook.sh
1 #!/ventoy/busybox/sh
2 #************************************************************************************
3 # Copyright (c) 2020, longpanda <admin@ventoy.net>
4 #
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.
9 #
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.
14 #
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/>.
17 #
18 #************************************************************************************
19
20 . /ventoy/hook/ventoy-hook-lib.sh
21
22 ventoy_os_install_dmsetup() {
23 vtlog "ventoy_os_install_dmsetup $1"
24
25 vt_usb_disk=$1
26
27 $BUSYBOX_PATH/modprobe dm-mod
28 $BUSYBOX_PATH/modprobe linear
29
30 # dump iso file location
31 $VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
32
33 # install dmsetup
34 LINE=$($GREP 'device-mapper-[0-9].*\.rpm' $VTOY_PATH/iso_file_list)
35 if [ $? -eq 0 ]; then
36 install_rpm_from_line "$LINE" ${vt_usb_disk}
37 fi
38
39 vtlog "dmsetup install finish, now check it..."
40
41 dmsetup_path=$(ventoy_find_bin_path dmsetup)
42 if [ -z "$dmsetup_path" ]; then
43 vterr "dmsetup still not found after install"
44 elif $dmsetup_path info >> $VTLOG 2>&1; then
45 vtlog "$dmsetup_path work ok"
46 else
47 vterr "$dmsetup_path not work"
48 fi
49 }
50
51
52 if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
53 # /dev/loop7 come first
54 if [ "$1" = "loop7" ] && [ -b $VTOY_DM_PATH ]; then
55 ventoy_copy_device_mapper /dev/loop7
56 fi
57 exit 0
58 fi
59
60 dmsetup_path=$(ventoy_find_bin_path dmsetup)
61 if [ -z "$dmsetup_path" ]; then
62 ventoy_os_install_dmsetup "/dev/${1:0:-1}"
63 fi
64
65
66 #some distro add there repo file to /etc/anaconda.repos.d/ which will cause error during installation
67 $BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $VTOY_PATH/hook/rhel6/anaconda-repo-listen.sh /etc/anaconda.repos.d:n &
68
69 ventoy_udev_disk_common_hook $* "noreplace"
70
71 $BUSYBOX_PATH/mount $VTOY_DM_PATH /mnt/ventoy
72
73 #
74 # We do a trick for rhel6 series here.
75 # Use /dev/loop7 and wapper it as a removable cdrom with bind mount.
76 # Then the anaconda installer will accept /dev/loop7 as the install medium.
77 #
78 ventoy_copy_device_mapper /dev/loop7
79
80 $BUSYBOX_PATH/cp -a /sys/devices/virtual/block/loop7 /tmp/ >> $VTLOG 2>&1
81 echo 19 > /tmp/loop7/capability
82 $BUSYBOX_PATH/mount --bind /tmp/loop7 /sys/block/loop7 >> $VTLOG 2>&1
83
84 # OK finish
85 set_ventoy_hook_finish