# Zero length files after update

**URL:** <https://hub.mender.io/t/zero-length-files-after-update/7641>\
**Category:** General Discussions\
**Created:** [March 18, 2025, 3:03pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641 "2025-03-18T15:03:53Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjsteele](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjsteele](https://hub.mender.io/u/jjsteele)\
**Post date:** [March 18, 2025, 3:03pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/1 "2025-03-18T15:03:53Z")

</div>

I am performing an update on a few thousand devices. I have an ArtifactInstall\_Enter scripts that install a few python packages. Then uses directory-artifact-gen to install a few files. After this it uses ArtifactInstall\_Exit to change permissions on a file.

95% of the devices this all works fine, but occasionally the files that are created be directory-artifact-gen produce aero length files. The update comes back as successful.

If I re-run the same deployment on the device, everything is fine.

Any ideas?

John

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [March 20, 2025, 2:26pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/2 "2025-03-20T14:26:41Z")

</div>

Hi @jjsteele,

Not sure I can follow. My first take at understanding is that you are kind of nesting updates. Is that correct? If so, no idea if that ever was tested or even thought of.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![jjsteele](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjsteele](https://hub.mender.io/u/jjsteele)\
**Post date:** [March 20, 2025, 2:55pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/3 "2025-03-20T14:55:22Z")

</div>

Hi @TheYoctoJester, yes. I needed to install some python packages before some new files. I take it that was the wrong way to do it!

John

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [March 20, 2025, 4:06pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/4 "2025-03-20T16:06:11Z")

</div>

@jjsteele well its a surprising take at it for sure. But yeah, I’m kinda sure that this will cause issues.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![jjsteele](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjsteele](https://hub.mender.io/u/jjsteele)\
**Post date:** [March 20, 2025, 4:22pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/5 "2025-03-20T16:22:18Z")

</div>

@TheYoctoJester Is there a correct way to do it? I shouldn’t listen to CoPilot😀

John

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [March 20, 2025, 4:40pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/6 "2025-03-20T16:40:38Z")

</div>

@jjsteele

My workaround would be to always include the files, and then either apply or delete them depending on the state of the device in the `ArtifactInstall` stage.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![jjsteele](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjsteele](https://hub.mender.io/u/jjsteele)\
**Post date:** [March 20, 2025, 5:13pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/7 "2025-03-20T17:13:12Z")

</div>

@TheYoctoJester Last question 😀

So, I’m installing python packages. Should I package up the.whl files and store them on the device using directory then just pip install them in the ArtifactInstall script.

John

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [March 20, 2025, 5:27pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/8 "2025-03-20T17:27:49Z")

</div>

@jjsteele I’m not really familiar with python, so can’t really help too much. My approach would, in a nutshell, be to make the artifact fully self-contained. So whatever you need, eventually as dependency should be in there. Where and how to actually install in the scripts, that’s for you to figure out.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![jjsteele](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjsteele](https://hub.mender.io/u/jjsteele)\
**Post date:** [April 9, 2025, 2:15pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/9 "2025-04-09T14:15:06Z")

</div>

@TheYoctoJester Hi Josef,  
Following on ftom this, just doing a standard directory update and two devices have all the files but all are 0 bytes long.  
Any idea what is causing this?

John

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [April 15, 2025, 2:42pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/10 "2025-04-15T14:42:00Z")

</div>

Hi @jjsteele,

Sorry, not from the top of my head. You’ll have to go digging in the logs.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![simonbuehler](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/simonbuehler/32/1828_2.png) [@simonbuehler](https://hub.mender.io/u/simonbuehler)\
**Post date:** [September 12, 2025, 11:35am UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/11 "2025-09-12T11:35:19Z")

</div>

same issue here, any idea what caused it?

some updates have all 0 byte files, is there a issue with the directory update module in not verifying if the tar command is successful?  
same artifact works on other (same hardware/mender/etc) machines… 😰

edit: perfect Friday material here …

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [September 15, 2025, 7:13am UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/12 "2025-09-15T07:13:57Z")

</div>

Hi @simonbuehler

Sounds very Friday-ish indeed, though I’m only reading it on Monday.

Can you safely reproduce it on this specific device? If so, I’d suggest sprinkling debug statements into the Update Module and see where it goes wrong. Once we have a pointer, we can help with it but at the moment I’m not aware of anything.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![simonbuehler](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/simonbuehler/32/1828_2.png) [@simonbuehler](https://hub.mender.io/u/simonbuehler)\
**Post date:** [September 19, 2025, 6:04am UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/13 "2025-09-19T06:04:05Z")

</div>

still not reproducible but it did happen, i set up some scripted testing and see if it pops up again

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [September 19, 2025, 7:02am UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/14 "2025-09-19T07:02:13Z")

</div>

@simonbuehler

Thanks! Yeah not questioning the occurrence, I was just asking about a reproducer for being able to inspect and find the reason. Ping me if something shows please.

Greetz,  
Josef

---

<div class="post-metadata">

**Author:** ![simonbuehler](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/simonbuehler/32/1828_2.png) [@simonbuehler](https://hub.mender.io/u/simonbuehler)\
**Post date:** [October 9, 2025, 12:51pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/15 "2025-10-09T12:51:08Z")

</div>

i think we can reproduce:

pulling power after the update gives the 0byte files, a `shutdown` command avoids this.  
The Directory Update module deletes the target directory and extracts new files without `sync` or `fsync`, so on ext4 with delayed allocation a sudden power loss can leave files as 0 bytes.  
i gues that to use a staging directory with atomic `mv`, add `sync`/`fsync` calls, or mount the partition with safer options like `commit=1,barrier=1,nodelalloc` will avoid it but i have to look into it and test it

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [October 9, 2025, 1:01pm UTC](https://hub.mender.io/t/zero-length-files-after-update/7641/16 "2025-10-09T13:01:00Z")

</div>

Hi @simonbuehler,

Thanks for the follow up!  
My gut feeling is that `mv` is the most robust and straightforward approach, but it will only work reliably if the unpacking partition is the same as the target one, or need an intermediate storage location.

From the bigger perspective, a partition remount is a very interesting approach. It could also be used to deal with situations like read-only filesystems and similar set ups, so just shooting from the hip I would actually love to evaluate that more.

Greetz,  
Josef
