Bug: Update failed! Missing /tmp/scripts folder

405 views
Skip to first unread message

c.nienha...@gmail.com

unread,
Jul 17, 2018, 3:48:19 AM7/17/18
to swupdate
When I start my embedded devices which runs on buildroot with systemd, all thinks works fine.
After some time the /tmp folder is cleared.
After that, swupdate is not possible to proceed any updates anymore.
It cannot extract scripts to /tmp/scripts folder because the folder is missing.

So I think, before extracting scripts, recreate the tmp directory SCRIPTS_DIR_SUFFIX should fix the problem.
Should also be done for DATADST_DIR_SUFFIX.

Stefano Babic

unread,
Jul 17, 2018, 5:03:15 AM7/17/18
to c.nienha...@gmail.com, swupdate
Hi,

On 17/07/2018 09:48, c.nienha...@gmail.com wrote:
> When I start my embedded devices which runs on buildroot with systemd, all thinks works fine.
> After some time the /tmp folder is cleared.
> After that, swupdate is not possible to proceed any updates anymore.
> It cannot extract scripts to /tmp/scripts folder because the folder is missing.

Well, this happens always if you remove the basement where software is
running. Is it different if you run "sudo rm -rf /" on your Desktop ?
(Disclaimer: no responsibility if you try this..). You destroy the files
where system is running.

>
> So I think, before extracting scripts, recreate the tmp directory SCRIPTS_DIR_SUFFIX should fix the problem.
> Should also be done for DATADST_DIR_SUFFIX.

I have a better idea: do not clear /tmp.

Or you can assign a different area for SWUpdate. SWUpdate evaluates the
variable TMPDIR. You can assign TMPDIR to a different path before
starting SWUpdate.

Best regards,
Stefano Babic


--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=====================================================================

c.nienha...@gmail.com

unread,
Jul 17, 2018, 6:15:49 AM7/17/18
to swupdate

Thanks for your response and for this great software.
So then I have to find why systemd or whatelse is clearing the folders.

c.nienha...@gmail.com

unread,
Jul 19, 2018, 3:27:36 AM7/19/18
to swupdate

I have solved the issue and want to share the solution for other people.

Systemd uses systemd-tmpfiles-clean.timer to clean old files and folders.
See documentation https://www.freedesktop.org/software/systemd/man/systemd-tmpfiles.html.

The configs for the cleaner are in
```
/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf
```

Content of /usr/lib/tmpfiles.d/tmp.conf:
```
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

# See tmpfiles.d(5) for details

# Clear tmp directories separately, to make them easier to override
q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp

# Remove top-level private temporary directories on each boot
R! /tmp/systemd-private-*
R! /var/tmp/systemd-private-*
```

Line `q /tmp 1777 root root 10d` not only means create folder /tmp, it means also remove everything in /tmp which is older than 10d.

To ignore folders in /tmp add the following lines to the config file or add a new config file with the same filename in a more prioritized folder (Eg. /etc/tmpfiles.d/tmp.conf):
```
X /tmp/scripts
X /tmp/datadst
```

To test a changed config call:
```
timedatectl set-ntp false
timedatectl set-time "2200-01-01"
systemctl start systemd-tmpfiles-clean.service
```

Stefano Babic

unread,
Jul 19, 2018, 4:15:19 AM7/19/18
to c.nienha...@gmail.com, swupdate
Thanks for sharing this - I am sure this will help other users.
Reply all
Reply to author
Forward
0 new messages