I build some archive for linux kernel it need an archive file with absolute path. File are under folder /data/ when I pack normally it keeps file path like this


the command I used is like this

cd /data
find|cpio -o -H newc -F ../data.cpio

but I want cpio to keep file with root path like this


I found I shuold use pax but I dont know how to write regex for path replacement

1 Answer 1


This should work as long as no filename contain the '>' characters:

pax -w -x sv4cpio -s '>^\.>>' . >../data.cpio

The -x sv4cpio should satisfy the requirement for using -H newc (SVR4 format).

  • thanx alot it saved my time, can you explain what is the meaning of ^ in your regex
    – Hamid
    Mar 19, 2019 at 18:54
  • ^ tells regex to match the start of the string. (And $ tells regex to match the end of the string). Mar 20, 2019 at 19:34
  • Please note that -x sv4cpio is non-portable and applies only to one specific pax implementation that is not pax compliant since it does not support -x pax. This specific pax implementation you have in mind therefore is still at a development state from 1992.
    – schily
    Jul 13, 2020 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .