I have been using the following command on my system to create the .cpio archive to create an initramfs for my embedded target device
sudo find . | cpio -H newc -oc > ~/initramfs.cpio
This has always worked for me without any problem. Yesterday I was generating a new archive and I received the following error:
cpio: Archive format multiply defined: Operation not permitted
cpio: ./etc/shadow: Function open failed: Permission denied
cpio: ./usr/lib/ssh-keysign: Function open failed: Permission denied
64842 blocks
I never received these errors in the past, the files mentions with failed opens have not been touched either so I cannot understand why this has started happening. I update my host system with Ubuntu package manager so it is possible that my cpio
package has been updated too. I obviously have no faith in the initramfs generated here due to all of the errors which confuse me greatly. The only option I can think of is to try and find out if my cpio
version has changed and if so remove and replace with the older version I had. Is there any way I can find out this information on my system (Ubuntu 12.04)? Or is there some other way I can get around this problem?
Best Answer
The first error is because you're passing both
-H newc
and-c
. You have to make up your mind on the format of the archive you want to generate. The "Operation not permitted" is a bug in GNU cpio, it's passing wrong arguments to the function that outputs that error message and should exit there.The other errors are because you're not running that command as the superuser or more likely , you're not running it from the correct location. Only the superuser can read files like
/etc/shadow
as it contains sensitive information. You should also make sure that the archive you generate can only be read by the superuser. If it's aninitramfs
you're creating, chances are/etc/shadow
has not business being there, unless thatinitramfs
contains a full operating system.