meta-isar: Added support for nfs based rootfs in deploy-image-wic (isar-image-installer).

Message ID 20240828114615.123711-1-alexander.heinisch@siemens.com
State Accepted, archived
Headers show
Series meta-isar: Added support for nfs based rootfs in deploy-image-wic (isar-image-installer). | expand

Commit Message

alexander.heinisch Aug. 28, 2024, 11:46 a.m. UTC
From: Alexander Heinisch <alexander.heinisch@siemens.com>

When AUTO_INSTALL is not used, the script tries to resolve possible target devices to
install the wic image to. To not overwrite the device hosting the current root
we are using, it tries to detect the current root. Which works fine when a local device
is used but does not work in the case of nfs. (most probably it won't work for cifs as well)

With this patch we are detecting nfs based mounts of / before the local device tailored handling
is applied and bypass the breaking parts (in this particular case readlink).

Thus, in case of an nfs the current root device will be "nfs".

Signed-off-by: Alexander Heinisch <alexander.heinisch@siemens.com>
---
 .../deploy-image/files/deploy-image-wic.sh             | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Uladzimir Bely Sept. 4, 2024, 8:23 a.m. UTC | #1
On Wed, 2024-08-28 at 13:46 +0200, alexander.heinisch via isar-users
wrote:
> From: Alexander Heinisch <alexander.heinisch@siemens.com>
> 
> When AUTO_INSTALL is not used, the script tries to resolve possible
> target devices to
> install the wic image to. To not overwrite the device hosting the
> current root
> we are using, it tries to detect the current root. Which works fine
> when a local device
> is used but does not work in the case of nfs. (most probably it won't
> work for cifs as well)
> 
> With this patch we are detecting nfs based mounts of / before the
> local device tailored handling
> is applied and bypass the breaking parts (in this particular case
> readlink).
> 
> Thus, in case of an nfs the current root device will be "nfs".
> 
> Signed-off-by: Alexander Heinisch <alexander.heinisch@siemens.com>
> ---
>  .../deploy-image/files/deploy-image-wic.sh             | 10
> ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-
> image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy-
> image-wic.sh
> index 8b25b1d2..95188fe3 100644
> --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-
> wic.sh
> +++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image-
> wic.sh
> @@ -47,8 +47,14 @@ DISK_BMAP=$(find "$installdata" -type f -iname
> "${DISK_IMAGE%.wic*}.wic.bmap")
>  
>  if ! $AUTO_INSTALL; then
>      target_device_list=""
> -    current_root_dev=$(readlink -f "$(findmnt / -o source -n)")
> -    current_root_dev=${current_root_dev#\/dev/}
> +    current_root_dev_type=$(findmnt / -o fstype -n)
> +    if [ ${current_root_dev_type} = "nfs" ]; then
> +        current_root_dev="nfs"
> +    else
> +        current_root_dev=$(readlink -f "$(findmnt / -o source -n)")
> +        current_root_dev=${current_root_dev#\/dev/}
> +    fi
> +
>      case $current_root_dev in
>          mmcblk*)
>              ;;
> -- 
> 2.43.0
> 

Applied to next, thanks.

Patch

diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
index 8b25b1d2..95188fe3 100644
--- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
@@ -47,8 +47,14 @@  DISK_BMAP=$(find "$installdata" -type f -iname "${DISK_IMAGE%.wic*}.wic.bmap")
 
 if ! $AUTO_INSTALL; then
     target_device_list=""
-    current_root_dev=$(readlink -f "$(findmnt / -o source -n)")
-    current_root_dev=${current_root_dev#\/dev/}
+    current_root_dev_type=$(findmnt / -o fstype -n)
+    if [ ${current_root_dev_type} = "nfs" ]; then
+        current_root_dev="nfs"
+    else
+        current_root_dev=$(readlink -f "$(findmnt / -o source -n)")
+        current_root_dev=${current_root_dev#\/dev/}
+    fi
+
     case $current_root_dev in
         mmcblk*)
             ;;