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

@ -22,4 +22,4 @@
ventoy_set_inotify_script blackPanther/ventoy-inotifyd-hook.sh
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/blackPanther/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/00-ventoy-inotifyd-start.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1 root=/dev/dm-0 \$CMDLINE root=/dev/dm-0#" -i /lib/dracut-lib.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1 root=/dev/ventoy \$CMDLINE root=/dev/ventoy#" -i /lib/dracut-lib.sh

View File

@ -33,10 +33,8 @@ if is_inotify_ventoy_part $3; then
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
blkdev_num_dev=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
if ! [ -e /dev/dm-0 ]; then
mknod -m 660 /dev/dm-0 b $blkdev_num_dev
fi
blackPanther-root /dev/dm-0
mknod -m 660 /dev/ventoy b $blkdev_num_dev
blackPanther-root /dev/ventoy
set_ventoy_hook_finish
else

View File

@ -78,6 +78,9 @@ fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ln -s /dev/dm-0 /dev/root
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})
cp -a /dev/$vtDM /dev/ventoy
ln -s /dev/$vtDM /dev/root
PATH=$VTPATH_OLD

View File

@ -19,5 +19,5 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "s#^CDROM=.*#CDROM=/dev/dm-0#" -i /init
$SED "s#^CDROM=.*#CDROM=/dev/ventoy#" -i /init
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/easystartup/ventoy-initqueue.sh /initqueue/ventoy.sh

View File

@ -19,7 +19,7 @@
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=/dev/dm-0#" -i /lib/dracut-lib.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=/dev/ventoy#" -i /lib/dracut-lib.sh
$BUSYBOX_PATH/rm -f /usr/lib/systemd/system-generators/systemd-fstab-generator /lib/systemd/system-generators/systemd-fstab-generator

View File

@ -35,7 +35,8 @@ if is_inotify_ventoy_part $3; then
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})
mount -t iso9660 /dev/$vtDM /sysroot
cp -a /dev/$vtDM /dev/ventoy
mount -t iso9660 /dev/ventoy /sysroot
set_ventoy_hook_finish
else

View File

@ -59,7 +59,7 @@ if is_inotify_ventoy_part $3; then
$BUSYBOX_PATH/cp -a $BUSYBOX_PATH/blkid /sbin/blkid
$BUSYBOX_PATH/mkdir -p /dev/mapper
ln -s /dev/$vtDM /dev/mapper/ventoy
/sbin/mgalive-root /dev/dm-0
/sbin/mgalive-root /dev/$vtDM
fi
set_ventoy_hook_finish

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

View File

@ -64,9 +64,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"

View File

@ -54,6 +54,15 @@ if is_inotify_ventoy_part $3; then
vtlog "$vtGenRulFile not exist..."
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/ventoy

View File

@ -28,6 +28,15 @@ if [ ! -e /dev/ventoy ]; then
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 /dev/ventoy ..."
/sbin/anaconda-diskroot /dev/ventoy