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 1489882 - dracut --include <src> <tgt> doesn't work
Summary: dracut --include <src> <tgt> doesn't work
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: dracut
Version: 7.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Lukáš Nykrýn
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-09-08 14:46 UTC by Renaud Métrich
Modified: 2021-06-10 12:59 UTC (History)
5 users (show)

Fixed In Version: dracut-033-534.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 18:11:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0964 0 None None None 2018-04-10 18:11:41 UTC

Description Renaud Métrich 2017-09-08 14:46:36 UTC
Description of problem:

When trying to include a directory in the initramfs using "--include <src> <tgt>", the initramfs gets created without including the files in the <src> top directory and following errors are printed for each file in <src> directory:

cp: failed to access '/var/tmp/initramfs.91CQHL///myfile': No such file or directory


Version-Release number of selected component (if applicable):

dracut-033-502.el7.x86_64 but also before, at least since dracut-033-240.el7.x86_64 (RHEL7.1)


How reproducible:

Always


Steps to Reproduce:
1. Create some source to include

mkdir mydir
touch mydir/myfile
mkdir mydir/mysubdir
touch mydir/mysubdir/myfile

2. Run dracut to include "mydir" and check content

dracut --include mydir / /tmp/myinitramfs -f


Actual results:

cp: failed to access '/var/tmp/initramfs.CRA4FA///myfile': No such file or directory

lsinitrd content:
drwxr-xr-x   2 root     root            0 Sep  8 16:39 mysubdir
-rw-r--r--   1 root     root            0 Sep  8 16:39 mysubdir/myfile


Expected results:

no cp error + lsinitrd content:

-rw-r--r--   1 root     root            0 Sep  8 16:39 myfile
drwxr-xr-x   2 root     root            0 Sep  8 16:39 mysubdir
-rw-r--r--   1 root     root            0 Sep  8 16:39 mysubdir/myfile


Suggested fix (/usr/sbin/dracut): 

[...]
1442                         chmod --reference="$i" "$s"
1443                     fi
1444                     cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
1445                 else

=> replace line 1446
1446                     cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
=> by
1446                     cp --reflink=auto --sparse=auto -fa -t "${initdir}/${tgt}" "$i"

1447                 fi
1448             done
[...]

Comment 2 Lukáš Nykrýn 2017-09-11 12:00:43 UTC
If I am not mistaken --include does not work recursively. It can only copy one level of files. It is written in the man page, but the formulation is kinda clumsy. But this is still a valid RFE.

Comment 3 Renaud Métrich 2017-09-11 12:52:32 UTC
Here the issue is that the files in top dir "mydir/*" are not copied (in the above case mydir/myfile).

And btw subdirs are copied as someone would expect.

Comment 5 Steve Pillinger 2017-11-27 13:28:48 UTC
I have the same issue. Having looked into /usr/bin/dracut it appears that
the line:

cp --reflink=auto --sparse=auto -fa -t "$s" "$i"

in the else clause is the culprit. It is using $s where this is the destination file not the destination directory. As a test I used 'dirname $s' instead and this worked. So I suspect the value of $s needs to checked after being initialised to see if it is a file or a directory.

Comment 6 Lukáš Nykrýn 2018-01-11 15:12:13 UTC
It looks like we need to backport

https://github.com/dracutdevs/dracut/commit/c9364f6ea296a03073bc4096756e3a61ca095c0e

Comment 7 Lukáš Nykrýn 2018-01-11 15:41:41 UTC
And the backport
https://github.com/lnykryn/dracut/tree/bz1489882

Comment 10 Jan Stodola 2018-02-23 09:52:04 UTC
Verified with dracut-033-535.el7:

[root@localhost ~]# rpm -q dracut
dracut-033-535.el7.x86_64
[root@localhost ~]# mkdir mydir
[root@localhost ~]# touch mydir/myfile
[root@localhost ~]# mkdir mydir/mysubdir
[root@localhost ~]# touch mydir/mysubdir/myfile
[root@localhost ~]# dracut --include mydir / /tmp/myinitramfs -f
[root@localhost ~]# lsinitrd /tmp/myinitramfs | grep 'myfile\|mysubdir'
-rw-r--r--   1 root     root            0 Feb 23 10:46 myfile
drwxr-xr-x   2 root     root            0 Feb 23 10:46 mysubdir
-rw-r--r--   1 root     root            0 Feb 23 10:46 mysubdir/myfile
[root@localhost ~]#

Moving to VERIFIED.

Comment 13 errata-xmlrpc 2018-04-10 18:11:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0964


Note You need to log in before you can comment on or make changes to this bug.