]>
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 if [ "$SUBSYSTEM" != "block" ] || [ "$DEVTYPE" != "partition" ]; then
26 if [ -b /dev
/${MDEV:0:-1} ]; then
27 vtlog
"/dev/${MDEV:0:-1} exist"
32 if is_ventoy_hook_finished
|| not_ventoy_disk
"${MDEV:0:-1}"; then
36 PATH
=$BUSYBOX_PATH:$VTOY_PATH/tool
:$PATH
40 # Alpine initramfs doesn't contain dm-mod or fuse module,
41 # and even the worse, the libpthread.so is not included too.
42 # So here we directly dump the modloop squashfs file from disk to rootfs.
43 # Fortunately, this file is not too big (< 100MB in alpine 3.11.3).
45 # 1. mount the squashfs file
46 # 2. find the dm-mod module from the mountpoint and insmod
47 # 3. unmount and delete the squashfs file
50 vtoydm
-i -f $VTOY_PATH/ventoy_image_map
-d /dev
/${MDEV:0:-1} > $VTOY_PATH/iso_file_list
52 vtLine
=$(grep '[-][-] modloop-lts ' $VTOY_PATH/iso_file_list)
53 sector
=$(echo $vtLine | awk '{print $(NF-1)}')
54 length=$(echo $vtLine | awk '{print $NF}')
56 vtoydm -e -f $VTOY_PATH/ventoy_image_map -d /dev/${MDEV:0:-1} -s $sector -l $length -o /vt_modloop
58 mkdir -p $VTOY_PATH/mnt
59 mount /vt_modloop $VTOY_PATH/mnt
61 KoModPath=$(find $VTOY_PATH/mnt/ -name 'dm-mod.ko*')
62 vtlog "KoModPath=$KoModPath"
64 if modinfo $KoModPath | grep -q 'depend.
*dax
'; then
65 vtlog "First install dax mod ..."
66 DaxModPath=$(echo $KoModPath | sed 's#md/dm-mod#dax/dax#')
67 vtlog "insmod $DaxModPath"
76 ventoy_udev_disk_common_hook "$MDEV" "noreplace"
79 set_ventoy_hook_finish