Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2225684

Summary: dracut creates initramfs with incorrect timestamps
Product: Red Hat Enterprise Linux 9 Reporter: Andrew Schorr <ajschorr>
Component: dracutAssignee: dracut-maint-list
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: bstinson, dtardon, jwboyer, pvalena
Target Milestone: rcKeywords: Reopened
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-14 07:08:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
output from dracut -f -vvv none

Description Andrew Schorr 2023-07-25 16:46:49 UTC
Description of problem:
I have noticed on several occasions that the initramfs file created by dracut does not have correct timestamps. It somehow seems to preserve the timestamp from the previous version of the file. I don't think I am hallucinating.

Version-Release number of selected component (if applicable):
dracut-057-22.git20230530.el9.x86_64


How reproducible:
Always?

Steps to Reproduce:
1. Modify a file included in the initramfs
2. Run 'dracut -f'
3. run 'lsinitrd' and look at the listing for that file.

Actual results:
For example, I modified /etc/sysctl.conf. Prior to editing, here is what I saw:
lsinitrd | grep sysctl
-r--r--r--   1 root     root         1223 May 31 10:29 etc/sysctl.conf
...
Then I edited /etc/sysctl.conf. In the filesystem, I see:
-r--r--r-- 1 root root 1230 Jul 25 12:16 /etc/sysctl.conf
Then I ran 'dracut -f'. When I then ran 'lsinitrd | grep sysctl', I saw this:
-r--r--r--   1 root     root         1230 May 31 10:29 etc/sysctl.conf
Notice that the length of the file has changed, but it somehow preserves
the old timestamp. It is confounding.

Expected results:
The timestamps should update.

Additional info:
I have observed the same behavior with kernel modules created by dkms.

Comment 1 Pavel Valena 2023-09-13 14:01:13 UTC
Please note that dracut modules are not updated, but rather re-created. 
I don't see how there would be any content of initrd (incl. timestamp) 'preserved'; but some files can be modified or recreated for dracut runtime (before pivot).

Most likely explanation (IMO) is that the timestamp you're seeing is date of file creatin, hence no effect on file modification (or similar issue).

Note that if you want to regenerate specific initrd, you need to add '--kver=...' arg when invoking dracut (very much recommended).

If you still think there's an issue, please run `dracut` in verbose mode ('-vvv'), attach the log here, and reopen the bug.

Comment 2 Andrew Schorr 2023-09-13 20:26:36 UTC
I thought I provided a clear example of the problem above. Did you read it? I edited sysctl.conf, then re-ran dracut,
and the dracut initramfs contained the new version of sysctl.conf (based on the length change), but somehow had
the timestamp of the previous reason displayed in the lsinitrd output. How can that happen?

Let's try this again with dracut -vvv:

[root@ti128 ~]# uname -r
5.14.0-325.el9.x86_64
[root@ti128 ~]# ls -l /etc/sysctl.conf
-r--r--r-- 1 root root 1196 Sep 12 21:06 /etc/sysctl.conf
[root@ti128 ~]# lsinitrd | grep sysctl.conf
-r--r--r--   1 root     root         1196 May 31 10:29 etc/sysctl.conf
lrwxrwxrwx   1 root     root           14 May 31 10:29 etc/sysctl.d/99-sysctl.conf -> ../sysctl.conf
[root@ti128 ~]# echo "# random comment" >> /etc/sysctl.conf
[root@ti128 ~]# ls -l /etc/sysctl.conf
-r--r--r-- 1 root root 1213 Sep 13 16:20 /etc/sysctl.conf
[root@ti128 ~]# dracut -vvv -f > /tmp/dracut.log 2>&1 && echo SUCCESS
SUCCESS
[root@ti128 ~]# lsinitrd | grep sysctl.conf
-r--r--r--   1 root     root         1213 May 31 10:29 etc/sysctl.conf
lrwxrwxrwx   1 root     root           14 May 31 10:29 etc/sysctl.d/99-sysctl.conf -> ../sysctl.conf

How can it be that inside the initramfs, the file size of sysctl.conf has updated,
but it retains the previous timestamp? This is confusing and weird.

What do you mean when you say that "dracut modules are not updated, but rather re-created"? How does
that relate to this issue?

I will attach the dracut log.

Regards,
Andy

Comment 4 Andrew Schorr 2023-09-13 20:27:31 UTC
Created attachment 1988728 [details]
output from dracut -f -vvv

Comment 5 David Tardon 2023-09-14 07:08:40 UTC
(In reply to Andrew Schorr from comment #0)
> Description of problem:
> I have noticed on several occasions that the initramfs file created by
> dracut does not have correct timestamps. It somehow seems to preserve the
> timestamp from the previous version of the file.

It can't. Initrds are always created from scratch. dracut apparently changes the timestamps at some point--probably when copying them into a temp. directory--but it has nothing to do with possible older version of the initrd.

# stat /etc/sysctl.conf 
  File: /etc/sysctl.conf
  Size: 451       	Blocks: 8          IO Block: 4096   regular file
Device: 253,2	Inode: 4720653     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:system_conf_t:s0
Access: 2023-09-14 08:34:25.094316427 +0200
Modify: 2023-09-14 08:34:17.463354615 +0200
Change: 2023-09-14 08:34:17.497354447 +0200
 Birth: 2023-09-14 08:34:17.463354615 +0200

# # edit /etc/sysctl.conf

# stat /etc/sysctl.conf 
  File: /etc/sysctl.conf
  Size: 449       	Blocks: 8          IO Block: 4096   regular file
Device: 253,2	Inode: 4719020     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:system_conf_t:s0
Access: 2023-09-14 08:48:53.872152186 +0200
Modify: 2023-09-14 08:48:53.874152175 +0200
Change: 2023-09-14 08:48:53.916151951 +0200
 Birth: 2023-09-14 08:48:53.872152186 +0200

# dracut /tmp/initrd

# lsinitrd /tmp/initrd | grep -F etc/sysctl.conf
-rw-r--r--   1 root     root          449 Apr 27 02:00 etc/sysctl.conf

As can be seen, the timestamp of etc/sysctl.conf in the initrd does not match the timestamp of /etc/sysctl.conf either before or after editing. Also, many of the files in the initrd--including all kernel modules--have the same timestamp.

But unless you can show this actually matters, I'm not going to spend any more time trying to figure out what's going on. (Closing as NOTABUG, because bugzilla doesn't have resolution IDONTCARE.)

Comment 6 Andrew Schorr 2023-09-14 19:37:42 UTC
Ah, OK, I agree -- the timestamp seems to come from something in the dracut distribution and
has nothing to do with the file's actual timestamp.  I just upgraded dracut, and after remaking
the initrd, I see that timestamps have jumped to 'Aug 22 14:22', which seems to be
the timestamp of many of the files in the dracut rpm itself. I'm still not clear on why
some files inside initrd have different timestamps, but I suppose it doesn't matter.
The timestamps in there basically contain no info.