Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1489882 - dracut --include <src> <tgt> doesn't work
dracut --include <src> <tgt> doesn't work
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: dracut (Show other bugs)
7.4
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Lukáš Nykrýn
Release Test Team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-09-08 10:46 EDT by Renaud Métrich
Modified: 2018-04-10 14:11 EDT (History)
5 users (show)

See Also:
Fixed In Version: dracut-033-534.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-04-10 14:11:08 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0964 None None None 2018-04-10 14:11 EDT

  None (edit)
Description Renaud Métrich 2017-09-08 10:46:36 EDT
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 08:00:43 EDT
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 08:52:32 EDT
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 08:28:48 EST
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 10:12:13 EST
It looks like we need to backport

https://github.com/dracutdevs/dracut/commit/c9364f6ea296a03073bc4096756e3a61ca095c0e
Comment 7 Lukáš Nykrýn 2018-01-11 10:41:41 EST
And the backport
https://github.com/lnykryn/dracut/tree/bz1489882
Comment 10 Jan Stodola 2018-02-23 04:52:04 EST
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 14:11:08 EDT
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.