From 5e607b7f9f205af0c7a0f02ad84ad6265447332d Mon Sep 17 00:00:00 2001 From: longpanda Date: Sat, 11 Jun 2022 22:47:16 +0800 Subject: [PATCH] Support EasyOS resize partition at first boot time. --- IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh | 6 +-- IMG/cpio/ventoy/loop/easyos/ventoy-resize.sh | 45 ++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 IMG/cpio/ventoy/loop/easyos/ventoy-resize.sh diff --git a/IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh b/IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh index 7310b0d7..a240dcb0 100644 --- a/IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh +++ b/IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh @@ -1,6 +1,6 @@ #!/ventoy/busybox/sh #************************************************************************************ -# Copyright (c) 2020, longpanda +# Copyright (c) 2022, longpanda # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -26,7 +26,7 @@ $SED "1a boot_dev=ventoy1;wkg_dev=ventoy2" -i /init #check for ssd will read /sys/block/ventoy, will no exist, need a workaround $SED "s#/sys/block/\${WKG_DRV}/#/sys/block/\$vtDM/#g" -i /init -#skip the resizing process, can't resizing partition -$SED "s#640M#0M#g" -i /init +#resizing process +$SED "s#partprobe.*#$BUSYBOX_PATH/sh $VTOY_PATH/loop/easyos/ventoy-resize.sh \$WKG_DEV#g" -i /init diff --git a/IMG/cpio/ventoy/loop/easyos/ventoy-resize.sh b/IMG/cpio/ventoy/loop/easyos/ventoy-resize.sh new file mode 100644 index 00000000..3732e0a5 --- /dev/null +++ b/IMG/cpio/ventoy/loop/easyos/ventoy-resize.sh @@ -0,0 +1,45 @@ +#!/ventoy/busybox/sh +#************************************************************************************ +# Copyright (c) 2022, longpanda +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +#************************************************************************************ + +. /ventoy/hook/ventoy-hook-lib.sh + +vtlog "####### $0 $* ########" + +VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH + +blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/') +vtDM0=$(ventoy_find_dm_id ${blkdev_num}) +blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy2 | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/') +vtDM2=$(ventoy_find_dm_id ${blkdev_num}) +vtlog "vtDM0=$vtDM0 vtDM2=$vtDM2" + +vtSize=$(cat /sys/block/$vtDM0/size) +vtSize1=$(sed -n "1p" /vtoy_dm_table | awk '{print $2}') +vtStart1=$(sed -n "1p" /vtoy_dm_table | awk '{print $5}') +vtSize2=$(sed -n "2p" /vtoy_dm_table | awk '{print $2}') +vtNewSize2=$(expr $vtSize - $vtSize1 - $vtStart1) +vtlog "vtSize=$vtSize vtSize1=$vtSize1 vtStart1=$vtStart1 vtSize2=$vtSize2 vtNewSize2=$vtNewSize2" + + +sed -n "2p" /vtoy_dm_table > /ventoy/resize_table +sed -i "s/$vtSize2/$vtNewSize2/" /ventoy/resize_table + +dmsetup remove ventoy2 +dmsetup create ventoy2 /ventoy/resize_table +