From 716ffea0158d4af0d627a2703104d87dc24b3b81 Mon Sep 17 00:00:00 2001 From: apor Date: Thu, 11 Apr 2024 18:53:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D1=81=20?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D1=82=D0=BE=D0=BC=20nvme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../System/RootFS/etc/rc/resize_storage_part | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/Core/System/RootFS/etc/rc/resize_storage_part b/src/Core/System/RootFS/etc/rc/resize_storage_part index 1080bea18..3575991a7 100755 --- a/src/Core/System/RootFS/etc/rc/resize_storage_part +++ b/src/Core/System/RootFS/etc/rc/resize_storage_part @@ -19,7 +19,7 @@ # disk="${1}"; -disk_name=$(basename $disk); +disk_name="$(basename "$disk")"; # Check if the block device exists if [ ! -b "${disk}" ]; then @@ -28,21 +28,26 @@ if [ ! -b "${disk}" ]; then fi; # Determine the partition number based on whether it's a system disk or a storage disk -if [ -b "${disk}4" ]; then - # System disk - part='4'; -else - # Storage disk - part='1'; +part=4; +storageDev="$(/bin/lsblk -r -p | /bin/busybox grep "$(/bin/busybox basename "$disk")" | /bin/busybox cut -d ' ' -f 1 | /bin/busybox grep "4$" | /bin/busybox sort -u)"; +systemPart="$storageDev"; +if [ ! -b "${storageDev}" ]; then + part=1; + storageDev="$(/bin/lsblk -r -p | /bin/busybox grep "$(/bin/busybox basename "$disk")" | /bin/busybox cut -d ' ' -f 1 | /bin/busybox grep "1$" | /bin/busybox sort -u)"; +fi; + +if [ ! -b "${storageDev}" ]; then + echo " - ERROR block devise ${disk} not found"; + exit 4; fi; tmp_dir='/storage/usbdisk1'; mkdir -p "$tmp_dir"; # Mount the partition -mount "${disk}${part}" "$tmp_dir"; +mount "${storageDev}" "$tmp_dir"; if [ "$?" != "0" ]; then - echo " - ERROR mount storage disk part ${part}..."; + echo " - ERROR mount storage disk ${storageDev}..."; rm -rf "$tmp_dir"; exit 2; fi; @@ -52,20 +57,20 @@ total_byte=`busybox blockdev --getsize64 $disk`; total=`expr $total_byte / 1024 / 1024`; # Get the size of the partition in megabytes -disk_size=`/bin/busybox df -P -m | /bin/busybox grep "${disk}${part}" | busybox head -n 1 | /bin/busybox awk '{ print $2}'`; +disk_size=`/bin/busybox df -P -m | /bin/busybox grep "${storageDev}" | busybox head -n 1 | /bin/busybox awk '{ print $2}'`; # Unmount the partition -umount "${disk}${part}"; +umount "${storageDev}"; # Calculate the difference in size (delta) between the total size and partition size delta=`expr $total - $disk_size`; -echo " - disk: '${disk}'"; +echo " - disk: '${storageDev}'"; echo " - total_size: ${total}Mb"; echo " - partition_size: ${disk_size}Mb"; -if [ -b "${disk}4" ]; then - echo " - is SYSTEM disk: '${disk}'"; +if [ -b "${systemPart}" ]; then + echo " - is SYSTEM disk: '${storageDev}'"; system_size=600; if [ "$delta" -le "$system_size" ]; then delta=0; @@ -93,7 +98,7 @@ if [ "${is_mounted}x" != "x" ]; then /sbin/freestorage; fi; -echo " - delete part ${part} / add new part ${part}..."; +echo " - delete part ${storageDev} / add new part ${storageDev}..."; if [ -b "${disk}4" ]; then # Clear existing configuration for system disk @@ -126,13 +131,13 @@ fi; sleep 2; # Get the file system type for the partition -fs_type=$(/sbin/blkid -ofull "${disk}${part}"); +fs_type=$(/sbin/blkid -ofull "${storageDev}"); if [ "${fs_type}x" != "x" ]; then echo " - e2fsck ${disk} part ${part}..."; - e2fsck -f -p "${disk}${part}"; + e2fsck -f -p "${storageDev}"; sleep 2; echo " - resize2fs ${disk} part ${part}..." - resize2fs "${disk}${part}"; + resize2fs "${storageDev}"; sleep 2; else echo " - error blkid $?"