Search code examples
linuxpermissionschowninitrdcpio

Change ownership in cpio archive without root


I need to add files to an initramfs file(I own the file as this is for some other device), however I do not have root permissions on my development machine. The usual way would be to unpack the initramfs, add files, change owner to root and pack again. I can not do this, as changing owner on this machine would require root permissions. If I do not change owner the system might behave weird(and it is just not a clean setup).

I can not do this on the target system as it is an embedded system, which only has read only access to the initramfs file.

Is there any way to change the permissions during or after packing the cpio archive?


Solution

  • Use fakeroot to deal with permissions during extraction and compression. it is developed to provide root environment without actually being root.

    girishp@~/incoming$ /usr/bin/fakeroot /bin/bash
    root@~/incoming$