Failed to sparse the raw to img due to the size of system.img.raw is not mulple of 4096

This issue would still need this patch on rel-35.1 GA to get fully fixed.

diff --git a/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh b/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh
index 37d3ad3..cd36266 100755
--- a/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh
+++ b/rfs/usr/lib/nvidia/resizefs/nvresizefs.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+# Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -103,13 +103,19 @@
 		done
 		support_resizefs="${is_last}"
 	fi
+
+	if [ "${is_last}" == "true" ]; then
+		get_app_size
+		max_available_app_size
+		size="+${max_app_size}M"
+	fi
 }
 
 function get_app_size()
 {
 	# shellcheck disable=SC2086
 	partition_size="$(cat /sys/block/${block_dev}/${root_dev}/size)"
-	echo "$((partition_size/2/1024))"
+	cur_app_size="$((partition_size/2/1024))"
 }
 
 function max_available_app_size()
@@ -123,7 +129,7 @@
 				grep "last usable sector" | \
 				awk '{print $10}')"
 
-	echo "$(((last_usable_sector - app_start_sector + 1)/2/1024))"
+	max_app_size="$(((last_usable_sector - app_start_sector + 1)/2/1024))"
 }
 
 function parse_args()
@@ -143,7 +149,7 @@
 				echo "ERROR: ${script_name} doesn't support this platform."
 				exit 1
 			fi
-			get_app_size
+			echo "${cur_app_size}"
 			exit 0
 			;;
 		-m | --max)
@@ -151,7 +157,7 @@
 				echo "ERROR: ${script_name} doesn't support this platform."
 				exit 1
 			fi
-			max_available_app_size
+			echo "${max_app_size}"
 			exit 0
 			;;
 		-s | --size)
@@ -170,6 +176,8 @@
 script_name="$(basename "${0}")"
 support_resizefs="false"
 size="0"
+cur_app_size="0"
+max_app_size="0"
 root_dev=""
 block_dev=""
1 Like