How To View Content Of initrd.img file?
First of all we should determine file type of initrd.image
root@linuxhowto.in:/boot# file initrd.img-2.6.31-14-server
initrd.img-2.6.31-14-server: gzip compressed data, from
Unix, last modified: Thu Sep 30 15:41:28 2010
initrd.img is in gzip format. So move initrd.img to initrd.gz as shown
below.
# mv initrd.img initrd.gz
Unzip the initrd.gz file as shown below.
# gunzip initrd.gz
# ls
cdrom initrd
After unziping the initrd.gz file, the initrd is further in
cpio ‘newc’ format. So extract the files from initrd using cpio ‘newc’ format
as shown below.
Note: info cpio will
give more information about ‘newc’ format.
# mkdir tmp2
# cd tmp2/
# cpio -id < ../initrd
16524 blocks
Now you can view the content of initrd.img file
# ls
bin dev etc
init modules proc sbin
selinux sys tmp
var
How To Modify Content of Image and Recreate New Image?
After extracting the file as shown below, make appropriate
modification to any of those files. Then pack the files back into the archive
using the following commands. Pack the modified files back to cpio ‘newc’
format.
# find . | cpio --create --format='newc' > /tmp/newinitrd
16524 blocks
# ls /tmp/
cdrom initrd newinitrd
tmp2
# ls -l /tmp/newinitrd
-rw-r--r-- 1 root root 8460288 Jul 2 14:50 /tmp/newinitrd
Gzip the archive file.
# gzip newinitrd
# ls
cdrom initrd newinitrd.gz
tmp2
# ls -l newinitrd.gz
-rw-r--r-- 1 root
root 6649867 Jul 2 14:50 newinitrd.gz
Move file as an image file. You can use the newinitrd.img as
your new boot image.
# mv newinitrd.gz newinitrd.img
# ls -l newinitrd.img
-rw-r--r-- 1 root root 6649867 Jul 2 14:50 newinitrd.img
Note that this document comes without warranty of any kind. But every effort
has been made to provide the information as accurate as possible. I welcome
emails from any readers with comments, suggestions, and corrections at
webmaster_at admin@linuxhowto.in
Copyright © 2012 LINUXHOWTO.IN
Copyright © 2012 LINUXHOWTO.IN
No comments:
Post a Comment