Difference between revisions of "cpio notes"

From Noah.org
Jump to: navigation, search
m (Create a cpio archive)
m
 
(One intermediate revision by the same user not shown)
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>
+
  
 +
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.
 
<pre>
 
<pre>
find . | cpio --create --format='newc' > ../archive
+
find initrd.tree | cpio -H newc -o > initrd.cpio
</pre>
+
# find initrd.tree | cpio --format=newc --create > initrd.cpio
 
+
gzip initrd.cpio
== Create a Linux kernel initrd ==
+
mv initrd.cpio.gz initrd
 
+
An '''initramfs''' is a root filesystem embedded into the Linux kernel. It is the successor of '''initrd'''.
+
 
+
'''IMPORTANT: Do not use the '-depth' option with `find`!'''
+
<pre>
+
find . | cpio -o -H newc | gzip > ../initrd.cpio.gz
+
 
</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. Not sure why this is still used.
 
<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