]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Support EasyOS resize partition at first boot time.
authorlongpanda <admin@ventoy.net>
Sat, 11 Jun 2022 14:47:16 +0000 (22:47 +0800)
committerlongpanda <admin@ventoy.net>
Sat, 11 Jun 2022 14:47:16 +0000 (22:47 +0800)
IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh
IMG/cpio/ventoy/loop/easyos/ventoy-resize.sh [new file with mode: 0644]

index 7310b0d74a44f333809ddca8cf745d80c1971968..a240dcb00f05d7ac9fe92da7cb2fbe68d6cb050c 100644 (file)
@@ -1,6 +1,6 @@
 #!/ventoy/busybox/sh
 #************************************************************************************
 #!/ventoy/busybox/sh
 #************************************************************************************
-# Copyright (c) 2020, longpanda <admin@ventoy.net>
+# Copyright (c) 2022, longpanda <admin@ventoy.net>
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
 # 
 # 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
 
 #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 (file)
index 0000000..3732e0a
--- /dev/null
@@ -0,0 +1,45 @@
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2022, longpanda <admin@ventoy.net>
+# 
+# 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 <http://www.gnu.org/licenses/>.
+# 
+#************************************************************************************
+
+. /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
+