]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/easystartup/disk_hook.sh
2 #************************************************************************************
3 # Copyright (c) 2021, 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
25 if uname
-m | grep -q '64'; then
29 if grep -q '6[.]1' /etc
/redhat
-release; then
30 echo "RHAS6U1$machine"; return
33 echo "RHAS6U1$machine"
37 # dump iso file location
38 vtoydm
-i -f $VTOY_PATH/ventoy_image_map
-d ${vtdiskname} > $VTOY_PATH/iso_file_list
40 sysver
=$(get_rhel_ver)
41 vtlog
"sysver=$sysver"
43 LINE
=$(grep "$sysver" -n -m1 $VTOY_PATH/iso_file_list | awk -F: '{print $1}')
46 LINE
=$(sed -n "$LINE,\$p" $VTOY_PATH/iso_file_list | grep -m1 'initrd.img')
49 sector
=$(echo $LINE | $AWK '{print $(NF-1)}')
50 length=$(echo $LINE | $AWK '{print $NF}')
51 vtlog "sector=$sector length=$length"
54 vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${vtdiskname} -s $sector -l $length -o ./xxx.img
57 zcat ../xxx.img | cpio -idmu
58 ko=$(find -name dm-mod.ko*)
67 vtdiskname=$(get_ventoy_disk_name)
68 vtlog "vtdiskname=$vtdiskname ..."
69 if [ "$vtdiskname" = "unknown" ]; then
73 if grep -q 'device
-mapper' /proc/devices; then
74 vtlog "device-mapper module check ko"
79 ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
81 blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
82 vtDM
=$(ventoy_find_dm_id ${blkdev_num})
83 cp -a /dev
/$vtDM /dev
/ventoy
84 ln -s /dev
/$vtDM /dev
/root
88 set_ventoy_hook_finish