Fix the hardcoded dev/dm-0

This commit is contained in:
longpanda
2022-05-05 19:11:55 +08:00
parent 3263b64b8a
commit 4d4f958429
14 changed files with 89 additions and 35 deletions

View File

@@ -25,13 +25,19 @@ else
for vtParam in $($CAT /proc/cmdline); do
if echo $vtParam | $GREP -q 'inst.ks=hd:LABEL='; then
vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}')
VTKS="inst.ks=hd:/dev/dm-0:$vtRawKs"
VTKS="inst.ks=hd:/dev/ventoy:$vtRawKs"
break
fi
if echo $vtParam | $GREP -q '^ks=.*:/'; then
vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}')
VTKS="ks=hd:/dev/dm-0:$vtRawKs"
VTKS="ks=hd:/dev/ventoy:$vtRawKs"
break
fi
if echo $vtParam | $GREP -q '^inst.ks=.*:/'; then
vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}')
VTKS="inst.ks=hd:/dev/ventoy:$vtRawKs"
break
fi
done
@@ -54,9 +60,12 @@ if [ -f $VTOY_PATH/ventoy_persistent_map ]; then
$BUSYBOX_PATH/rm -rf $VTOY_PATH/selinuxfs
fi
echo "VTKS=$VTKS VTOVERLAY=$VTOVERLAY" >> $VTLOG
if [ -n "$vtRawKs" ]; then
echo "$vtRawKs" > $VTOY_PATH/ventoy_ks_rootpath
fi
if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do
vtInstDD="$vtInstDD inst.dd=file:$vtDud"
@@ -64,7 +73,7 @@ if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then
fi
echo "vtInstDD=$vtInstDD" >> $VTLOG
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $vtInstDD#" -i /lib/dracut-lib.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/ventoy $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh
ventoy_set_inotify_script openEuler/ventoy-inotifyd-hook.sh

View File

@@ -35,19 +35,23 @@ if is_inotify_ventoy_part $3; then
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
if [ "$vtDM" = "dm-0" ]; then
vtlog "This is dm-0, OK ..."
else
vtlog "####### This is $vtDM ####### this is abnormal ..."
ventoy_swap_device /dev/dm-0 /dev/$vtDM
blkdev_num_mknod=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 660 /dev/ventoy b $blkdev_num_mknod
$BUSYBOX_PATH/modprobe isofs >/dev/null 2>&1
vtlog "mknod /dev/ventoy $blkdev_num_mknod"
if [ -f $VTOY_PATH/ventoy_ks_rootpath ]; then
vt_ks_rootpath=$(cat $VTOY_PATH/ventoy_ks_rootpath)
vtlog "ks rootpath <$vt_ks_rootpath>"
if [ -e /sbin/fetch-kickstart-disk ]; then
vtlog "fetch-kickstart-disk ..."
/sbin/fetch-kickstart-disk /dev/ventoy "$vt_ks_rootpath"
fi
fi
if [ -e /sbin/anaconda-diskroot ]; then
vtlog "set anaconda-diskroot ..."
/sbin/anaconda-diskroot /dev/dm-0
vtlog "set anaconda-diskroot ..."
/sbin/anaconda-diskroot /dev/ventoy
fi
set_ventoy_hook_finish

View File

@@ -19,17 +19,24 @@
. /ventoy/hook/ventoy-hook-lib.sh
if ! [ -e /dev/mapper/ventoy ]; then
vtlog "link to /dev/mapper/ventoy"
ln -s /dev/dm-0 /dev/mapper/ventoy
if [ ! -e /dev/dm-0 ]; then
exit 0
fi
VTLABEL=$($BUSYBOX_PATH/blkid /dev/dm-0 | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
if ! [ -e /dev/mapper/ventoy ]; then
vtlog "link /dev/$vtDM to /dev/mapper/ventoy"
ln -s /dev/$vtDM /dev/mapper/ventoy
fi
VTLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
vtlog "VTLABEL=$VTLABEL"
if [ -n "$VTLABEL" ]; then
if ! [ -e "/dev/disk/by-label/$VTLABEL" ]; then
vtlog "link to /dev/disk/by-label/$VTLABEL"
ln -s /dev/dm-0 "/dev/disk/by-label/$VTLABEL"
vtlog "link /dev/$vtDM to /dev/disk/by-label/$VTLABEL"
ln -s /dev/$vtDM "/dev/disk/by-label/$VTLABEL"
fi
fi

View File

@@ -23,12 +23,23 @@ vtlog "##### $0 $* ..."
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
blkdev_num=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
vtDM=$(ventoy_find_dm_id ${blkdev_num})
if [ ! -e /dev/ventoy ]; then
blkdev_num_mknod=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
mknod -m 660 /dev/ventoy b $blkdev_num_mknod
fi
if [ -f $VTOY_PATH/ventoy_ks_rootpath ]; then
vt_ks_rootpath=$(cat $VTOY_PATH/ventoy_ks_rootpath)
vtlog "ks rootpath <$vt_ks_rootpath>"
if [ -e /sbin/fetch-kickstart-disk ]; then
vtlog "fetch-kickstart-disk ..."
/sbin/fetch-kickstart-disk /dev/ventoy "$vt_ks_rootpath"
fi
fi
if [ -e /sbin/anaconda-diskroot ]; then
vtlog "set anaconda-diskroot ..."
/sbin/anaconda-diskroot /dev/dm-0
vtlog "set anaconda-diskroot /dev/ventoy ..."
/sbin/anaconda-diskroot /dev/ventoy
fi
PATH=$VTPATH_OLD