Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making my own initramfs following the Gentoo wiki. Instead of the familiar tar and gzip, the page is telling me to use cpio and gzip. Wikipedia says that cpio is used by the 2.6 kernel's initramfs, but does not explain why.

Is this just a convention or is cpio better for initramfs? Can I still use tar and gzip?

share|improve this question
IIRC you cannot use tar as initramfs (I don't post it as answer as I'm not 100% sure). BTW using Gentoo I find much easier to configure built-in initramfs rather then hand-made one. – Maciej Piechotka Feb 12 '11 at 12:53
@Maciej I just want to know how to do it :) Furthermore I'm seeing a big boot time improvement by using my own initramfs – phunehehe Feb 12 '11 at 14:51
You misunderstood me. The method I was talking about is by giving the kernel during configuration a spec file which files should be included in the initrd (including custom /init etc.) and kernel simply uses that one. I'm not taking about generating initramfs by genkernel or similar methods. – Maciej Piechotka Feb 12 '11 at 15:34
@Maciej That looks fun! I'll try it sometime. – phunehehe Feb 12 '11 at 15:38
Well. It's IMHO easier to set up and it autoupdates with kernel (so I don't need to remember to copy new files into initrd). – Maciej Piechotka Feb 12 '11 at 16:35
up vote 7 down vote accepted

I'm not 100% sure, but as the initial ramdisk needs to be unpacked by the kernel during boot, cpio is used because it is already implemented in kernel code.

share|improve this answer
Be 100% sure. linux/init/initramfs.c unpacks a cpio -H newc archive. – ephemient Feb 13 '11 at 1:29
@ephemient This is really something. If there is no more answer coming in a few days I'll accept that cpio is used as a convention and that we have to use cpio. – phunehehe Feb 13 '11 at 2:57
@ephemient Thanks. – firusvg Feb 13 '11 at 11:05
Any ideas why newc is the format chosen? – CMCDragonkai Feb 1 at 4:33

From what I remember of my old SysV days, cpio could handle dev files, but tar could not; this made cpio the 'raw' backup utility of choice before dump came around. It was also easier to handle partial filesets and hard links so incremental backups were easier. I think that GNU tar has caught up with cpio features so now it is just a matter of user comfortability. Both cpio and tar should be installed by default.

share|improve this answer
cpio may be able to handle tar-format archives, and vice-versa in some cases, but that doesn't matter. The kernel can only unpack newc-style cpio-format archives, which no tar I know of produces. – ephemient Feb 14 '11 at 21:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.