Re: [OE-core] [RFC PATCH V2 0/5] Fix persistent tmp

2024-03-12 Thread Randy MacLeod via lists.openembedded.org

Add Trevor who made the original commit:

commit d5d40479d706cbb382850b9479c5dd9bfb801c99
Author: Trevor Woerner 
Date:   Mon Feb 27 00:00:40 2023

    VOLATILE_TMP_DIR: add

    Provide a mechanism to allow users to choose whether the /tmp directory
    is on persistent storage (non-volatile) or a RAM-based tmpfs 
(volatile).

    The default is volatile.

    Works for both sysvinit-based and systemd-based systems.


and Ross who said he'd take a look at this RFC.


On 2024-02-03 9:58 p.m., Changqing Li via lists.openembedded.org wrote:

ping

On 12/11/23 08:58, Changqing Li wrote:

From: Changqing Li 

Hi, All

Currently, VOLATILE_TMP_DIR not works,
set VOLATILE_TMP_DIR="no", VOLATILE_LOG_DIR="no", after boot target,
/var/tmp still link to tmpfs /var/volatile/tmp

lrwxrwxrwx  1 root root   11 Mar  9  2018 lock -> ../run/lock
drwxr-xr-x  4 root root 1024 Dec  4 07:55 log
lrwxrwxrwx  1 root root    6 Mar  9  2018 run -> ../run
drwxr-xr-x  3 root root 1024 Mar  9  2018 spool
lrwxrwxrwx  1 root root   12 Mar  9  2018 tmp -> volatile/tmp
drwxrwxrwt  4 root root   80 Dec  4 07:55 volatile

So I do some research, fix this issue and do some other changes 
accordingly. Please

help to review this patch, thanks.

Targets:
1. Support persistent tmp,  For persistent tmp, only /var/tmp is 
persistent, /tmp is tmpfs,
    For volatile tmp, /tmp link to /var/tmp, /var/tmp link to 
/var/volatile/tmp

2. make systemd and SysVinit have the same directory structure.

Currently, systemd and SysVinit have different directory structure, 
the difference focus on how to handle /tmp.


when volatile is enabled, for sysVinit, /tmp link to /var/tmp, 
/var/tmp link to /var/volatile/tmp
refer [4][5]. but for systemd, /tmp is a directory, it is mounted by 
systemd as tmpfs. /var/tmp
linked to /var/volatile/tmp.  And for systemd, refer [6], set 
different age for /tmp and /var/tmp.


I find that structured text helps me understand things, so here's a 
structured version of the sentences above:



Currently, systemd and SysVinit have different directory structure; the 
difference focus on how to handle /tmp.


When volatile is enabled, for sysVinit:
      /tmp link to /var/tmp,
  /var/tmp link to /var/volatile/tmp
   refer [4][5]

but for systemd:
   /tmp is a directory, it is mounted by systemd as tmpfs.
  /var/tmp linked to /var/volatile/tmp

and for systemd, refer [6], set different age for /tmp and /var/tmp.






Since volatile disabled not works, ignore the difference when 
volatile is disabled.


With this patch, VOLATILE_TMP_DIR will behavior like this:
For both sysvinit and systemd:
1. VOLATILE_TMP_DIR="yes":
/tmp link to /var/tmp,  /var/tmp link to /var/volatile/log, 
/var/volatile is mounted as tmpfs
In this case, for systemd, /tmp and /var/tmp will set to the same 
age, 10d.


Compare to current behavior, there are 2 changes:
    1) for systemd,  /tmp changed from a directy to a symlink to 
/var/tmp

    2) age of /tmp and /var/tmp will be same



Okay but is an identical timestamp absolutely required or are you just 
trying to make things consistent


to reduce the chance that a different timestamp could cause problems?

I may have missed an explanation of why you want the 10d old timestamp 
anyway, that seems like

a separate change that should follow-up the re-org changes.




2. VOLATILE_TMP_DIR="no":
/tmp is a directory mounted as tmpfs, /var/tmp is a directory on 
persistent fs, and keep the age as [6]


Change like this in order to meet [1][2], also maybe [3] for systemd.

Compare to current behavior, there is one change:
    1) for sysVinit, /tmp changed from a symlink to a directory


You've carefully explained things but it does seem a bit complicated 
when you first read
the explaination. It may have been better to start your explaination 
with the last statement you

made, by saying something like this:

   This is going to be a detailed, lengthy explaination but the only 
change in runtime will be
   for sysVinit where /tmp is changed from a symlink to a directory to 
make it persistent.



Ross, Trevor,
Any comments or concerns ?

Changqing is no one replies today, please just rebase and repost your 
full RFC patch

to try to restart the discussion.


Thanks,

../Randy



[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html
[2] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
[3] https://systemd.io/TEMPORARY_DIRECTORIES/
[4] 
https://git.openembedded.org/openembedded/tree/docs/usermanual/chapters/recipes.xml#n3535
[5] 
https://git.openembedded.org/openembedded-core/commit/?id=12c4acd7ac5a27cf3676065b60f1c8395c96854c

[6] https://github.com/systemd/systemd/blob/main/tmpfiles.d/tmp.conf
[7] 
https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html



Test Result of following cases:
1.
SysVinit
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:~# ls -al /tmp
lrwxrwxrwx    1 root root 8 Dec  8 08:51 /tmp -> 
/var/tmp


Re: [OE-core] [RFC PATCH V2 0/5] Fix persistent tmp

2024-01-05 Thread Changqing Li

Hi, Richard

I had send a similar patch before, subjected as "bitbake.conf: support 
persistent /var/tmp",


and you have replied me with some concerns on 2021/9/13.  But I noticed 
that another variable VOLATILE_TMP_DIR is added in 2023.


but as I tested, it not works, so I make this patch to make it work for 
both sysV and systemd. Not sure if you still have those concerns now,


so just kindly ping to check.

Thanks

Changqing

On 12/11/23 08:58, Changqing Li wrote:

From: Changqing Li

Hi, All

Currently, VOLATILE_TMP_DIR not works,
set VOLATILE_TMP_DIR="no", VOLATILE_LOG_DIR="no", after boot target,
/var/tmp still link to tmpfs /var/volatile/tmp

lrwxrwxrwx  1 root root   11 Mar  9  2018 lock -> ../run/lock
drwxr-xr-x  4 root root 1024 Dec  4 07:55 log
lrwxrwxrwx  1 root root6 Mar  9  2018 run -> ../run
drwxr-xr-x  3 root root 1024 Mar  9  2018 spool
lrwxrwxrwx  1 root root   12 Mar  9  2018 tmp -> volatile/tmp
drwxrwxrwt  4 root root   80 Dec  4 07:55 volatile

So I do some research, fix this issue and do some other changes accordingly. 
Please
help to review this patch, thanks.

Targets:
1. Support persistent tmp,  For persistent tmp, only /var/tmp is persistent, 
/tmp is tmpfs,
For volatile tmp, /tmp link to /var/tmp, /var/tmp link to /var/volatile/tmp
2. make systemd and SysVinit have the same directory structure.

Currently, systemd and SysVinit have different directory structure, the 
difference focus on how to handle /tmp.

when volatile is enabled, for sysVinit, /tmp link to /var/tmp, /var/tmp link to 
/var/volatile/tmp
refer [4][5]. but for systemd, /tmp is a directory, it is mounted by systemd as 
tmpfs. /var/tmp
linked to /var/volatile/tmp.  And for systemd, refer [6], set different age for 
/tmp and /var/tmp.

Since volatile disabled not works, ignore the difference when volatile is 
disabled.

With this patch, VOLATILE_TMP_DIR will behavior like this:
For both sysvinit and systemd:
1. VOLATILE_TMP_DIR="yes":
/tmp link to /var/tmp,  /var/tmp link to /var/volatile/log,  /var/volatile is 
mounted as tmpfs
In this case, for systemd, /tmp and /var/tmp will set to the same age, 10d.

Compare to current behavior, there are 2 changes:
1) for systemd,  /tmp changed from a directy to a symlink to /var/tmp
2) age of /tmp and /var/tmp will be same

2. VOLATILE_TMP_DIR="no":
/tmp is a directory mounted as tmpfs, /var/tmp is a directory on persistent fs, 
and keep the age as [6]

Change like this in order to meet [1][2], also maybe [3] for systemd.

Compare to current behavior, there is one change:
1) for sysVinit, /tmp changed from a symlink to a directory

[1]https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html
[2]https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
[3]https://systemd.io/TEMPORARY_DIRECTORIES/
[4]https://git.openembedded.org/openembedded/tree/docs/usermanual/chapters/recipes.xml#n3535
[5]https://git.openembedded.org/openembedded-core/commit/?id=12c4acd7ac5a27cf3676065b60f1c8395c96854c
[6]https://github.com/systemd/systemd/blob/main/tmpfiles.d/tmp.conf
[7]https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html


Test Result of following cases:
1.
SysVinit
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:~# ls -al /tmp
lrwxrwxrwx1 root root 8 Dec  8 08:51 /tmp -> /var/tmp
root@qemux86-64:~# ls -al /var/log
lrwxrwxrwx1 root root17 Dec  8 08:51 /var/log -> 
/var/volatile/log
root@qemux86-64:~# ls -al /var/tmp
lrwxrwxrwx1 root root17 Dec  8 08:51 /var/tmp -> 
/var/volatile/tmp
root@qemux86-64:~# mount | grep volatile
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:~#

2.
SysVinit
VOLATILE_TMP_DIR="no"
VOLATILE_LOG_DIR="no"

root@qemux86-64:/# ls -al
drwxr-xr-x   18 root root  1024 Dec  8 09:22 .
drwxr-xr-x   18 root root  1024 Dec  8 09:22 ..
drwxr-xr-x2 root root  3072 Mar  9  2018 bin
drwxr-xr-x2 root root  1024 Mar  9  2018 boot
drwxr-xr-x   13 root root  2960 Dec  8 09:24 dev
drwxr-xr-x   20 root root  1024 Dec  8 09:24 etc
drwxr-xr-x3 root root  1024 Mar  9  2018 home
drwxr-xr-x6 root root  1024 Mar  9  2018 lib
drwx--2 root root 12288 Dec  8 09:22 lost+found
drwxr-xr-x2 root root  1024 Mar  9  2018 media
drwxr-xr-x2 root root  1024 Mar  9  2018 mnt
dr-xr-xr-x  161 root root 0 Dec  8 09:24 proc
drwxr-xr-x4 root root   240 Dec  8 09:24 run
drwxr-xr-x2 root root  3072 Mar  9  2018 sbin
dr-xr-xr-x   12 root root 0 Dec  8 09:24 sys
drwxrwxrwt2 root root40 Dec  8 09:24 tmp
drwxr-xr-x9 root root  1024 Mar  9  2018 usr
drwxr-xr-x   10 root root  1024 Dec  8 09:24 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al
drwxr-xr-x   10 root root  1024 Dec  8 

Re: [OE-core] [RFC PATCH V2 0/5] Fix persistent tmp

2023-12-18 Thread Changqing Li

kindly ping

On 12/11/23 08:58, Changqing Li wrote:

From: Changqing Li 

Hi, All

Currently, VOLATILE_TMP_DIR not works,
set VOLATILE_TMP_DIR="no", VOLATILE_LOG_DIR="no", after boot target,
/var/tmp still link to tmpfs /var/volatile/tmp

lrwxrwxrwx  1 root root   11 Mar  9  2018 lock -> ../run/lock
drwxr-xr-x  4 root root 1024 Dec  4 07:55 log
lrwxrwxrwx  1 root root6 Mar  9  2018 run -> ../run
drwxr-xr-x  3 root root 1024 Mar  9  2018 spool
lrwxrwxrwx  1 root root   12 Mar  9  2018 tmp -> volatile/tmp
drwxrwxrwt  4 root root   80 Dec  4 07:55 volatile

So I do some research, fix this issue and do some other changes accordingly. 
Please
help to review this patch, thanks.

Targets:
1. Support persistent tmp,  For persistent tmp, only /var/tmp is persistent, 
/tmp is tmpfs,
For volatile tmp, /tmp link to /var/tmp, /var/tmp link to /var/volatile/tmp
2. make systemd and SysVinit have the same directory structure.

Currently, systemd and SysVinit have different directory structure, the 
difference focus on how to handle /tmp.

when volatile is enabled, for sysVinit, /tmp link to /var/tmp, /var/tmp link to 
/var/volatile/tmp
refer [4][5]. but for systemd, /tmp is a directory, it is mounted by systemd as 
tmpfs. /var/tmp
linked to /var/volatile/tmp.  And for systemd, refer [6], set different age for 
/tmp and /var/tmp.

Since volatile disabled not works, ignore the difference when volatile is 
disabled.

With this patch, VOLATILE_TMP_DIR will behavior like this:
For both sysvinit and systemd:
1. VOLATILE_TMP_DIR="yes":
/tmp link to /var/tmp,  /var/tmp link to /var/volatile/log,  /var/volatile is 
mounted as tmpfs
In this case, for systemd, /tmp and /var/tmp will set to the same age, 10d.

Compare to current behavior, there are 2 changes:
1) for systemd,  /tmp changed from a directy to a symlink to /var/tmp
2) age of /tmp and /var/tmp will be same

2. VOLATILE_TMP_DIR="no":
/tmp is a directory mounted as tmpfs, /var/tmp is a directory on persistent fs, 
and keep the age as [6]

Change like this in order to meet [1][2], also maybe [3] for systemd.

Compare to current behavior, there is one change:
1) for sysVinit, /tmp changed from a symlink to a directory

[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html
[2] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
[3] https://systemd.io/TEMPORARY_DIRECTORIES/
[4] 
https://git.openembedded.org/openembedded/tree/docs/usermanual/chapters/recipes.xml#n3535
[5] 
https://git.openembedded.org/openembedded-core/commit/?id=12c4acd7ac5a27cf3676065b60f1c8395c96854c
[6] https://github.com/systemd/systemd/blob/main/tmpfiles.d/tmp.conf
[7] https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html


Test Result of following cases:
1.
SysVinit
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:~# ls -al /tmp
lrwxrwxrwx1 root root 8 Dec  8 08:51 /tmp -> /var/tmp
root@qemux86-64:~# ls -al /var/log
lrwxrwxrwx1 root root17 Dec  8 08:51 /var/log -> 
/var/volatile/log
root@qemux86-64:~# ls -al /var/tmp
lrwxrwxrwx1 root root17 Dec  8 08:51 /var/tmp -> 
/var/volatile/tmp
root@qemux86-64:~# mount | grep volatile
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:~#

2.
SysVinit
VOLATILE_TMP_DIR="no"
VOLATILE_LOG_DIR="no"

root@qemux86-64:/# ls -al
drwxr-xr-x   18 root root  1024 Dec  8 09:22 .
drwxr-xr-x   18 root root  1024 Dec  8 09:22 ..
drwxr-xr-x2 root root  3072 Mar  9  2018 bin
drwxr-xr-x2 root root  1024 Mar  9  2018 boot
drwxr-xr-x   13 root root  2960 Dec  8 09:24 dev
drwxr-xr-x   20 root root  1024 Dec  8 09:24 etc
drwxr-xr-x3 root root  1024 Mar  9  2018 home
drwxr-xr-x6 root root  1024 Mar  9  2018 lib
drwx--2 root root 12288 Dec  8 09:22 lost+found
drwxr-xr-x2 root root  1024 Mar  9  2018 media
drwxr-xr-x2 root root  1024 Mar  9  2018 mnt
dr-xr-xr-x  161 root root 0 Dec  8 09:24 proc
drwxr-xr-x4 root root   240 Dec  8 09:24 run
drwxr-xr-x2 root root  3072 Mar  9  2018 sbin
dr-xr-xr-x   12 root root 0 Dec  8 09:24 sys
drwxrwxrwt2 root root40 Dec  8 09:24 tmp
drwxr-xr-x9 root root  1024 Mar  9  2018 usr
drwxr-xr-x   10 root root  1024 Dec  8 09:24 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al
drwxr-xr-x   10 root root  1024 Dec  8 09:24 .
drwxr-xr-x   18 root root  1024 Dec  8 09:22 ..
drwxr-xr-x2 root root  1024 Mar  9  2018 backups
drwxr-xr-x2 root root  1024 Mar  9  2018 cache
drwxr-xr-x4 root root  1024 Mar  9  2018 lib
drwxr-xr-x2 root root  1024 Mar  9  2018 local
lrwxrwxrwx1 root root 9 Dec  8 09:24 lock -> /run/lock
drwxr-xr-x2 root 

[OE-core] [RFC PATCH V2 0/5] Fix persistent tmp

2023-12-10 Thread Changqing Li
From: Changqing Li 

Hi, All

Currently, VOLATILE_TMP_DIR not works, 
set VOLATILE_TMP_DIR="no", VOLATILE_LOG_DIR="no", after boot target, 
/var/tmp still link to tmpfs /var/volatile/tmp

lrwxrwxrwx  1 root root   11 Mar  9  2018 lock -> ../run/lock
drwxr-xr-x  4 root root 1024 Dec  4 07:55 log
lrwxrwxrwx  1 root root6 Mar  9  2018 run -> ../run
drwxr-xr-x  3 root root 1024 Mar  9  2018 spool
lrwxrwxrwx  1 root root   12 Mar  9  2018 tmp -> volatile/tmp
drwxrwxrwt  4 root root   80 Dec  4 07:55 volatile

So I do some research, fix this issue and do some other changes accordingly. 
Please
help to review this patch, thanks.

Targets:
1. Support persistent tmp,  For persistent tmp, only /var/tmp is persistent, 
/tmp is tmpfs, 
   For volatile tmp, /tmp link to /var/tmp, /var/tmp link to /var/volatile/tmp 
2. make systemd and SysVinit have the same directory structure. 

Currently, systemd and SysVinit have different directory structure, the 
difference focus on how to handle /tmp.  

when volatile is enabled, for sysVinit, /tmp link to /var/tmp, /var/tmp link to 
/var/volatile/tmp
refer [4][5]. but for systemd, /tmp is a directory, it is mounted by systemd as 
tmpfs. /var/tmp 
linked to /var/volatile/tmp.  And for systemd, refer [6], set different age for 
/tmp and /var/tmp.

Since volatile disabled not works, ignore the difference when volatile is 
disabled.

With this patch, VOLATILE_TMP_DIR will behavior like this:
For both sysvinit and systemd:
1. VOLATILE_TMP_DIR="yes":
/tmp link to /var/tmp,  /var/tmp link to /var/volatile/log,  /var/volatile is 
mounted as tmpfs
In this case, for systemd, /tmp and /var/tmp will set to the same age, 10d.

Compare to current behavior, there are 2 changes:
   1) for systemd,  /tmp changed from a directy to a symlink to /var/tmp
   2) age of /tmp and /var/tmp will be same

2. VOLATILE_TMP_DIR="no":
/tmp is a directory mounted as tmpfs, /var/tmp is a directory on persistent fs, 
and keep the age as [6]

Change like this in order to meet [1][2], also maybe [3] for systemd.

Compare to current behavior, there is one change:
   1) for sysVinit, /tmp changed from a symlink to a directory

[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html
[2] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
[3] https://systemd.io/TEMPORARY_DIRECTORIES/
[4] 
https://git.openembedded.org/openembedded/tree/docs/usermanual/chapters/recipes.xml#n3535
[5] 
https://git.openembedded.org/openembedded-core/commit/?id=12c4acd7ac5a27cf3676065b60f1c8395c96854c
[6] https://github.com/systemd/systemd/blob/main/tmpfiles.d/tmp.conf
[7] https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html


Test Result of following cases:
1.  
SysVinit 
VOLATILE_TMP_DIR="yes"
VOLATILE_LOG_DIR="yes"

root@qemux86-64:~# ls -al /tmp
lrwxrwxrwx1 root root 8 Dec  8 08:51 /tmp -> /var/tmp
root@qemux86-64:~# ls -al /var/log 
lrwxrwxrwx1 root root17 Dec  8 08:51 /var/log -> 
/var/volatile/log
root@qemux86-64:~# ls -al /var/tmp
lrwxrwxrwx1 root root17 Dec  8 08:51 /var/tmp -> 
/var/volatile/tmp
root@qemux86-64:~# mount | grep volatile
tmpfs on /var/volatile type tmpfs (rw,relatime)
root@qemux86-64:~# 

2. 
SysVinit 
VOLATILE_TMP_DIR="no"
VOLATILE_LOG_DIR="no"

root@qemux86-64:/# ls -al
drwxr-xr-x   18 root root  1024 Dec  8 09:22 .
drwxr-xr-x   18 root root  1024 Dec  8 09:22 ..
drwxr-xr-x2 root root  3072 Mar  9  2018 bin
drwxr-xr-x2 root root  1024 Mar  9  2018 boot
drwxr-xr-x   13 root root  2960 Dec  8 09:24 dev
drwxr-xr-x   20 root root  1024 Dec  8 09:24 etc
drwxr-xr-x3 root root  1024 Mar  9  2018 home
drwxr-xr-x6 root root  1024 Mar  9  2018 lib
drwx--2 root root 12288 Dec  8 09:22 lost+found
drwxr-xr-x2 root root  1024 Mar  9  2018 media
drwxr-xr-x2 root root  1024 Mar  9  2018 mnt
dr-xr-xr-x  161 root root 0 Dec  8 09:24 proc
drwxr-xr-x4 root root   240 Dec  8 09:24 run
drwxr-xr-x2 root root  3072 Mar  9  2018 sbin
dr-xr-xr-x   12 root root 0 Dec  8 09:24 sys
drwxrwxrwt2 root root40 Dec  8 09:24 tmp
drwxr-xr-x9 root root  1024 Mar  9  2018 usr
drwxr-xr-x   10 root root  1024 Dec  8 09:24 var
root@qemux86-64:/# cd /var/
root@qemux86-64:/var# ls -al
drwxr-xr-x   10 root root  1024 Dec  8 09:24 .
drwxr-xr-x   18 root root  1024 Dec  8 09:22 ..
drwxr-xr-x2 root root  1024 Mar  9  2018 backups
drwxr-xr-x2 root root  1024 Mar  9  2018 cache
drwxr-xr-x4 root root  1024 Mar  9  2018 lib
drwxr-xr-x2 root root  1024 Mar  9  2018 local
lrwxrwxrwx1 root root 9 Dec  8 09:24 lock -> /run/lock
drwxr-xr-x2 root root  1024 Dec  8 09:24 log