# Getting "error: fw\_setenv returned failure: exit status 2" after "Committing update" OTA update

**URL:** <https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669>\
**Category:** General Discussions\
**Tags:** debian, x86, mender-client, ota\
**Created:** [May 24, 2021, 10:44am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669 "2021-05-24T10:44:38Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 3, 2021, 1:50pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/21 "2021-06-03T13:50:49Z")

</div>

> [@kacf](#):
>
> Assuming you have put the artifact in `/data/artifact.mender` , do these steps to do a manual install:
> 
> ```auto
> mender install /data/artifact.mender
> reboot
> 
> ```

@kacf  
I have followed the steps as told above and output as below:

```
$ fw_printenv # o/p before install
bootcount=1
mender_boot_part=2
upgrade_available=0
mender_uboot_separator=
mender_boot_part_hex=2

$ sudo mender install alto_p3_upgV2.6_20210529_Testserver_v2-x86_64-mender.mender 
INFO[0000] Loaded configuration file: /var/lib/mender/mender.conf 
INFO[0000] Loaded configuration file: /etc/mender/mender.conf 
INFO[0000] Mender running on partition: /dev/sda2       
INFO[0000] Start updating from local image file: [alto_p3_upgV2.6_20210529_Testserver_v2-x86_64-mender.mender] 
INFO[0000] No public key was provided for authenticating the artifact 
INFO[0000] Opening device "/dev/sda3" for writing       
INFO[0000] Native sector size of block device /dev/sda3 is 512 bytes. Mender will write in chunks of 1048576 bytes 
.............................................................. - 100 %
INFO[1483] All bytes were successfully written to the new partition 
INFO[1483] The optimized block-device writer wrote a total of 49729 frames, where 23694 frames did need to be rewritten (i.e., skipped) 
INFO[1485] Wrote 52143587328/52143587328 bytes to the inactive partition 
INFO[1485] Enabling partition with new image installed to be a boot candidate: 3 

$ fw_printenv # After reboot, o/p as below
bootcount=1
mender_boot_part=3
upgrade_available=0
mender_uboot_separator=
mender_boot_part_hex=3

```

$ mender commit  
INFO[0000] Loaded configuration file: /var/lib/mender/mender.conf  
INFO[0000] Loaded configuration file: /etc/mender/mender.conf  
INFO[0000] Mender running on partition: /dev/sda3  
**ERRO[0000] Could not commit Artifact: There is nothing to commit**  
**WARN[0000] There is nothing to commit**

Refer post: [Fixed wrong error produced by rootfs-image commit by hacpa · Pull Request #607 · mendersoftware/mender · GitHub](https://github.com/mendersoftware/mender/pull/607)

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [June 4, 2021, 3:57pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/22 "2021-06-04T15:57:15Z")

</div>

In this scenario, what does “fw\_printenv” show after the install but before the reboot?

Drew

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 4, 2021, 4:06pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/23 "2021-06-04T16:06:55Z")

</div>

What @drewmoseley said!

And also, what does `mount` say, both before and after the reboot?

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 6, 2021, 1:19pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/24 "2021-06-06T13:19:24Z")

</div>

> [@drewmoseley](#):
>
> In this scenario, what does “fw\_printenv” show after the install but before the reboot?

@drewmoseley  
“fw\_printenv” o/p after the install but before the reboot as below

$ fw\_printenv  
bootcount=0  
mender\_boot\_part=3  
**upgrade\_available=1**  
mender\_uboot\_separator=  
mender\_boot\_part\_hex=3

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 6, 2021, 1:45pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/25 "2021-06-06T13:45:43Z")

</div>

> [@kacf](#):
>
> what does `mount` say, both before and after the reboot?

@kacf@drewmoseley

`mount` output, both before and after the reboot as below in attached file.  
[mount\_log.yml](https://hub.mender.io/uploads/short-url/hnPsVd6l9P8FQTLR9pn4tpveku1.yml) (16.8 KB)

```auto
$ sudo mender commit

INFO[0000] Loaded configuration file: /var/lib/mender/mender.conf 
INFO[0000] Loaded configuration file: /etc/mender/mender.conf 
INFO[0000] Mender running on partition: /dev/sda2       
ERRO[0000] Could not commit Artifact: There is nothing to commit 
WARN[0000] There is nothing to commit

```

Second time attempt logs with new flash image on target device for reference as  
[mount-log-attempt-2.yml](https://hub.mender.io/uploads/short-url/cdAeK7B0ajs6ro3steH5OJpsUcm.yml) (12.2 KB)

Could you please suggest me to crack this issue.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 7, 2021, 7:26am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/26 "2021-06-07T07:26:53Z")

</div>

I have to admit that I’m starting to run out of ideas. Something is modifying the boot loader environment behind your back, it’s definitely not behaving as it should. Are you using any state scripts, or modifying the sda1 partition in any way?

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 7, 2021, 7:46am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/27 "2021-06-07T07:46:40Z")

</div>

> [@kacf](#):
>
> Are you using any state scripts, or modifying the sda1 partition in any way?

@kacf  
Thanks for the quick response.

I am not using state scripts as below  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/5/5c0579d54d37352c542f68e0047e705fe7bd2a18.png)

I have used the directory update module i.e. **directory-artifact-gen** as below to modify the Home partition to create TEST folder.

> ARTIFACT\_NAME=“HOME\_TEST\_v1.0”  
> DEVICE\_TYPE=“x86\_64”  
> OUTPUT\_PATH=“HOME\_TEST\_v1.0.mender”  
> DEST\_DIR=“/home/alto/TEST/”  
> FILE\_TREE=“Test\_local”
> 
> ./directory-artifact-gen -n ${ARTIFACT\_NAME} -t ${DEVICE\_TYPE} -d ${DEST\_DIR} -o ${OUTPUT\_PATH} ${FILE\_TREE}

**Note:** I have attached **grub.cfg file** here for reference to get any clue.  
[grub.cfg.yml](https://hub.mender.io/uploads/short-url/fEOruxdrX89wIws5zJ48pmgL02T.yml) (7.8 KB)

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [June 7, 2021, 5:55pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/28 "2021-06-07T17:55:38Z")

</div>

How are you generating the initial UEFIIMG? I know you are using mender-convert from the earlier discussion but where are you getting the input image? Is it an image that already has Mender installed?

Drew

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 8, 2021, 4:56am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/29 "2021-06-08T04:56:21Z")

</div>

> [@drewmoseley](#):
>
> I know you are using mender-convert from the earlier discussion but where are you getting the input image? Is it an image that already has Mender installed?

@drewmoseley  
I am using the latest **mender\_convert v2.4** here. I am using the input image as custom **ubuntu18.04** that I am using last ~1 year without any issue.  
Here Mender is not installed in an image. mender is installing through mender\_convert utility only.

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 9, 2021, 5:21am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/30 "2021-06-09T05:21:35Z")

</div>

@drewmoseley @kacf @mirzak

Could anyone please suggest that why the statement “ **fw\_setenv** failure” (OS **x86 Ubuntu18.04** as below error logs) is _ **sometimes is failing & sometimes is working** _ in the case of the self-hosted AWS S3 bucket storage instead of minio with a **full OS filesystem update & application update** (using directory-artifact-gen & single-file-artifact-gen scripts) as below screenshots in both versions v2.6 & v2.7?

> 2021-06-08 15:40:29 +0000 UTC info: Committing update  
> 2021-06-08 15:40:30 +0000 UTC error: fw\_setenv returned failure: exit status 2  
> 2021-06-08 15:40:30 +0000 UTC error: Failed to probe the U-Boot environment for which separator to use. Got error: exit status 2  
> 2021-06-08 15:40:30 +0000 UTC error: transient error: update commit failed: exit status 2  
> 2021-06-08 15:40:30 +0000 UTC info: State transition: update-commit [ArtifactCommit\_Enter] → rollback [ArtifactRollback]  
> 2021-06-08 15:40:30 +0000 UTC info: Performing rollback  
> 2021-06-08 15:40:31 +0000 UTC info: Rolling back to the inactive partition (3).  
> 2021-06-08 15:40:32 +0000 UTC error: fw\_setenv returned failure: exit status 1  
> 2021-06-08 15:40:32 +0000 UTC error: Failed to probe the U-Boot environment for which separator to use. Got error: exit status 1  
> 2021-06-08 15:40:32 +0000 UTC error: Rollback failed: exit status 1  
> 2021-06-08 15:40:32 +0000 UTC error: fatal error: exit status 1

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/1/1b1f1c20bdcf9a6996c56009c5c8a9fc4f2cfce6.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/9/96eddbbd5f83658ecb2d4bc3d2dec2e3fe4cd508.png)

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 9, 2021, 11:53am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/31 "2021-06-09T11:53:49Z")

</div>

@Rohita83: I’m working on making it easier to get information about failures like this by logging output from child processes better. See [this pull request](https://github.com/mendersoftware/mender/pull/795). Perhaps you can retry with a development build once that has been merged.

The `exit status 1` by itself is not giving a lot of information.

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 10, 2021, 12:12pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/32 "2021-06-10T12:12:27Z")

</div>

> [@kacf](#):
>
> I’m working on making it easier to get information about failures like this by logging output from child processes better. See [this pull request](https://github.com/mendersoftware/mender/pull/795). Perhaps you can retry with a development build once that has been merged.

@kacf  
Thanks for this valuable update.  
Please let me know, whenever this package available to test above mention issue. i will wait for this.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 11, 2021, 8:19am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/33 "2021-06-11T08:19:33Z")

</div>

Can you try the package at:

- [https://mender.s3.amazonaws.com/kacf-tmp/mender-client\_2.6.1~git20210611.fd57c39-1%2BbLOCAL\_amd64.deb](https://mender.s3.amazonaws.com/kacf-tmp/mender-client_2.6.1~git20210611.fd57c39-1%2BbLOCAL_amd64.deb)

If you are using mender-convert to prepare an image, you can use something like this patch to temporarily use the development package:

```diff
diff --git a/mender-convert-modify b/mender-convert-modify
index cf8f215..925f517 100755
--- a/mender-convert-modify
+++ b/mender-convert-modify
@@ -103,14 +103,16 @@ log_info "Installing Mender client and related files"
 
 deb_arch=$(probe_debian_arch_name)
 
-if ["${MENDER_CLIENT_VERSION}" = "latest"]; then
- deb_name=$(deb_from_repo_dist_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "stable" "mender-client")
-elif ["${MENDER_CLIENT_VERSION}" = "master"]; then
- deb_name=$(deb_from_repo_dist_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-client")
-else
- DEBIAN_REVISION="-1"
- deb_name=$(deb_from_repo_pool_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "mender-client" "${MENDER_CLIENT_VERSION}${DEBIAN_REVISION}")
-fi
+# if ["${MENDER_CLIENT_VERSION}" = "latest"]; then
+# deb_name=$(deb_from_repo_dist_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "stable" "mender-client")
+# elif ["${MENDER_CLIENT_VERSION}" = "master"]; then
+# deb_name=$(deb_from_repo_dist_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-client")
+# else
+# DEBIAN_REVISION="-1"
+# deb_name=$(deb_from_repo_pool_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "mender-client" "${MENDER_CLIENT_VERSION}${DEBIAN_REVISION}")
+# fi
+wget https://mender.s3.amazonaws.com/kacf-tmp/mender-client_2.6.1~git20210611.fd57c39-1%2BbLOCAL_amd64.deb -P work/deb-packages/
+deb_name=mender-client_2.6.1~git20210611.fd57c39-1+bLOCAL_amd64.deb
 
 deb_extract_package "work/deb-packages/${deb_name}" "work/rootfs/"
 

```

(I didn’t test that last part, I hope I didn’t make a mistake…)

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 11, 2021, 1:24pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/34 "2021-06-11T13:24:32Z")

</div>

> [@kacf](#):
>
> Can you try the package at:
> 
> - [https://mender.s3.amazonaws.com/kacf-tmp/mender-client\_2.6.1~git20210611.fd57c39-1%2BbLOCAL\_amd64.deb](https://mender.s3.amazonaws.com/kacf-tmp/mender-client_2.6.1~git20210611.fd57c39-1%2BbLOCAL_amd64.deb)

@kacf Thanks for providing mender client binary for the test.

Here I have created new mender artifacts (let’s say V1 & V2) & OS image (through mender\_convert utility) by using your provided mender client binary (attached mender\_convert logs for reference  
[convert.log.uMuR.yml](https://hub.mender.io/uploads/short-url/h4jKnapjUr6XJeHGTlX7BoMBu4D.yml) (26.3 KB)  
).

I have flashed a new created OS image (having v2 artifact) on the target X86 device & **triggered full OS OTA four times** but it has **failed on the 4th OTA** as below screenshot. Attached **failed OTA log** for your reference.  
[ErrorLog11June.txt.yml](https://hub.mender.io/uploads/short-url/eJpnPUH7Jfgi5O1JUHJ7DaInULC.yml) (3.7 KB)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/2/216cd3b2a0c4094b898fc11240ffa8702a506a00.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/0/0a6b62fb2cb72f4fbbd3c3891a9d93090d4b8645.png)

For any further details for debugging, Please let me know.

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 14, 2021, 3:50am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/35 "2021-06-14T03:50:37Z")

</div>

> [@kacf](#):
>
> Can you try the package at:
> 
> - [https://mender.s3.amazonaws.com/kacf-tmp/mender-client\_2.6.1~git20210611.fd57c39-1%2BbLOCAL\_amd64.deb](https://mender.s3.amazonaws.com/kacf-tmp/mender-client_2.6.1~git20210611.fd57c39-1%2BbLOCAL_amd64.deb)

@kacf @drewmoseley

Continue I have triggered 2 more full OS OTA deployment (as below screenshot) but still ☹ they also both have failed.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/9/9bcbf1820e4c9e7c6ee6a8088fad0401b461f714.png)

**Note:** observed here “\_INCONSISTENT” appended into artifact name. [testImage\_20210611\_Testserver\_v1\_INCONSISTENT]

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/d/d72a33d05fe494fc8cba247140d7adb7895983cb.png)

**Note:** I have also tried on another different device with a new flash the same image on this device but here all three OTA OS updates have failed as below screenshot.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/3/3eb2b2cf14daad35ab85e7bc5b39f75c6374752d.png)

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [June 14, 2021, 2:00pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/36 "2021-06-14T14:00:12Z")

</div>

This is all consistent with the issue you have been seeing. [The `_INCONSISTENT` tag](https://docs.mender.io/troubleshoot/mender-client#the-current-software-installed-on-my-device-has-_inconsistent-ap) is used when something happens that the Mender client cannot understand. Usually, it is when a rollback fails for some reason outside the scope of Mender control, and everything you have described so far seems to indicate something like that is happening.

At this point, I would suggest you start with a simpler input image to help rule out some bad interaction with the software installed in your golden master.

Drew

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 15, 2021, 12:26pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/37 "2021-06-15T12:26:34Z")

</div>

> [@Rohita83](#):
>
> > [@kacf](#):
> >
> > Can you try the package at:
> > 
> > > - [https://mender.s3.amazonaws.com/kacf-tmp/mender-client\_2.6.1~git20210611.fd57c39-1%2BbLOCAL\_amd64.deb](https://mender.s3.amazonaws.com/kacf-tmp/mender-client_2.6.1~git20210611.fd57c39-1%2BbLOCAL_amd64.deb)
> 
> @kacf Thanks for providing mender client binary for the test.
> 
> Here I have created new mender artifacts (let’s say V1 & V2) & OS image (through mender\_convert utility) by using your provided mender client binary (attached mender\_convert logs for reference  
> [convert.log.uMuR.yml](https://hub.mender.io/uploads/short-url/h4jKnapjUr6XJeHGTlX7BoMBu4D.yml) (26.3 KB)

@kacf  
have you received any additional information from new log statements, generated by your shared mender client binary?

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 16, 2021, 11:45am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/38 "2021-06-16T11:45:16Z")

</div>

@Rohita83: Sorry for the delay. After having analyzed, I’m still not completely sure what’s going on, but I have a theory. Can you add the following script as state scripts:

```bash
#!/bin/sh
set -x
ENV_DIR=/boot/efi/EFI/BOOT/
which grub-editenv
which grub2-editenv
grub-editenv
grub2-editenv
for i in $ENV_DIR/mender_grubenv1/env ENV_DIR/mender_grubenv1/lock $ENV_DIR/mender_grubenv2/env ENV_DIR/mender_grubenv2/lock; do
    grub-editenv $i list
    grub2-editenv $i list
done
exit 0

```

Add the same script as state scripts for all of these states:

- `ArtifactInstall_Enter_00`
- `ArtifactInstall_Leave_00`
- `ArtifactReboot_Enter_00`
- `ArtifactReboot_Leave_00`
- `ArtifactCommit_Enter_00`
- `ArtifactCommit_Leave_00`
- `ArtifactRollback_Enter_00`
- `ArtifactRollback_Leave_00`
- `ArtifactRollbackReboot_Enter_00`
- `ArtifactRollbackReboot_Leave_00`
- `ArtifactFailure_Enter_00`
- `ArtifactFailure_Leave_00`

You might also want to double check that `ENV_DIR` is correct, and that it exists on the device. After you’ve run another deployment with this, please post the output.

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 16, 2021, 11:50am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/39 "2021-06-16T11:50:40Z")

</div>

> [@kacf](#):
>
> Can you add the following script as state scripts:
> 
> ```auto
> #!/bin/sh
> set -x
> ENV_DIR=/boot/efi/EFI/BOOT/
> which grub-editenv
> which grub2-editenv
> 
> ```

these scripts should add at path “/etc/mender/scripts/” before mender\_convert execution. right? any permission should apply?

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 16, 2021, 12:09pm UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/40 "2021-06-16T12:09:52Z")

</div>

No, they are added using `mender-artifact`. [This section](https://docs.mender.io/2.7/system-updates-debian-family/convert-a-mender-debian-image/state-scripts) describes how to add state scripts to artifacts using mender-convert. You will then need to include the `custom_config` file with `-c`.

[Previous page](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669.md?page=1)

[Next page](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669.md?page=3)
