Difference between revisions of "cpio notes"

From Noah.org
Jump to navigationJump to search
m
 
Line 1: Line 1:
 
[[Category: Engineering]]
 
[[Category: Engineering]]
  
== Create a cpio archive ==
+
== Create a cpio archive to create a Linux kernel inited ==
  
Note that '''archive''' should be outside of the directory tree that is being archived.
+
This shows how to create an '''initrd'''. Note that an '''initramfs''' is a root filesystem embedded into the Linux kernel. It is the successor of '''initrd'''.
<pre>
 
find . | cpio -o > ../archive
 
</pre>
 
 
 
<pre>
 
find . | cpio --create --format='newc' > ../archive
 
</pre>
 
 
 
== Create a Linux kernel initrd  ==
 
  
An '''initramfs''' is a root filesystem embedded into the Linux kernel. It is the successor of '''initrd'''.
+
Note that '''inited.cpio''' should be outside of the directory tree that is being archived. In this case I just assume it is in the directory above the inited.tree.
 
 
'''IMPORTANT: Do not use the '-depth' option with `find`!'''
 
 
<pre>
 
<pre>
find . | cpio -o -H newc | gzip > ../initrd.cpio.gz
+
find initrd.tree | cpio -H newc -o > initrd.cpio
 +
# find initrd.tree | cpio --format=newc --create > initrd.cpio
 +
gzip initrd.cpio
 +
mv initrd.cpio.gz initrd
 
</pre>
 
</pre>
  
Line 29: Line 21:
 
== Extract a Linux kernel ==
 
== Extract a Linux kernel ==
  
 +
Note that '''newc''' format is probably not necessary for extraction.
 
<pre>
 
<pre>
 
gunzip --to-stdout /boot/initrd.img-2.6.31-22-server | cpio -i -d -H newc --no-absolute-filenames
 
gunzip --to-stdout /boot/initrd.img-2.6.31-22-server | cpio -i -d -H newc --no-absolute-filenames
</pre>
 
 
Also, often see this; although, this does not have '''newc''' or no absolute filename support. Probably not necessary for extraction.
 
<pre>
 
cpio -id < initrd
 
 
</pre>
 
</pre>

Latest revision as of 18:26, 26 February 2014


Create a cpio archive to create a Linux kernel inited

This shows how to create an initrd. Note that an initramfs is a root filesystem embedded into the Linux kernel. It is the successor of initrd.

Note that inited.cpio should be outside of the directory tree that is being archived. In this case I just assume it is in the directory above the inited.tree.

find initrd.tree | cpio -H newc -o > initrd.cpio
# find initrd.tree | cpio --format=newc --create > initrd.cpio
gzip initrd.cpio
mv initrd.cpio.gz initrd

List the contents of initrd

gunzip --to-stdout /boot/initrd.img-2.6.31-22-server | cpio -t

Extract a Linux kernel

Note that newc format is probably not necessary for extraction.

gunzip --to-stdout /boot/initrd.img-2.6.31-22-server | cpio -i -d -H newc --no-absolute-filenames