]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/alpine/udev_disk_hook.sh
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 PATH
=$BUSYBOX_PATH:$VTOY_PATH/tool
:$PATH
24 wait_for_usb_disk_ready
26 vtdiskname
=$(get_ventoy_disk_name)
27 if [ "$vtdiskname" = "unknown" ]; then
28 vtlog
"ventoy disk not found"
35 # Alpine initramfs doesn't contain dm-mod or fuse module,
36 # and even the worse, the libpthread.so is not included too.
37 # So here we directly dump the modloop squashfs file from disk to rootfs.
38 # Fortunately, this file is not too big (< 100MB in alpine 3.11.3).
40 # 1. mount the squashfs file
41 # 2. find the dm-mod module from the mountpoint and insmod
42 # 3. unmount and delete the squashfs file
45 MDEV
="${vtdiskname#/dev/}2"
47 vtoydm
-i -f $VTOY_PATH/ventoy_image_map
-d /dev
/${MDEV:0:-1} > $VTOY_PATH/iso_file_list
49 vtLine
=$(grep '[-][-] modloop-lts ' $VTOY_PATH/iso_file_list)
50 sector
=$(echo $vtLine | awk '{print $(NF-1)}')
51 length=$(echo $vtLine | awk '{print $NF}')
53 echo -n "Mounting boot media, please wait ......"
54 vtoydm -e -f $VTOY_PATH/ventoy_image_map -d /dev/${MDEV:0:-1} -s $sector -l $length -o /vt_modloop
57 mkdir -p $VTOY_PATH/mnt
58 mount /vt_modloop $VTOY_PATH/mnt
60 KoModPath=$(find $VTOY_PATH/mnt/ -name 'dm-mod.ko*')
61 vtlog "KoModPath=$KoModPath"
63 if modinfo $KoModPath | grep -q 'depend.
*dax
'; then
64 vtlog "First install dax mod ..."
65 DaxModPath=$(echo $KoModPath | sed 's#md/dm-mod#dax/dax#')
66 vtlog "insmod $DaxModPath"
75 ventoy_udev_disk_common_hook "$MDEV" "noreplace"
78 set_ventoy_hook_finish