{"id":6718,"date":"2017-05-08T14:33:57","date_gmt":"2017-05-08T06:33:57","guid":{"rendered":"http:\/\/rmohan.com\/?p=6718"},"modified":"2017-05-08T14:33:57","modified_gmt":"2017-05-08T06:33:57","slug":"centos-rhel-7-how-to-extract-initramfs-image-and-editview-it","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6718","title":{"rendered":"CentOS \/ RHEL 7 : How to extract initramfs image and edit\/view it"},"content":{"rendered":"<p>In some cases you may want to extract the initramfs image file to check built-in contents. This post provides steps to extract initramfs image files for RHEL 7. Unlike previous version, on RHEL 7 using cpio command for the initramfs image file will not extract all files (or will give some error). For example:<\/p>\n<p># ls -la \/boot\/initramfs-$(uname -r).img<br \/>\n-rw&#8212;&#8212;- 1 root root 19602671 Feb  4  2016 \/boot\/initramfs-3.10.0-229.el7.x86_64.img<br \/>\n# file initramfs-3.10.0-229.el7.x86_64.img<br \/>\ninitramfs-3.10.0-229.el7.x86_64.img: gzip compressed data, from Unix, last modified: Thu Feb  4 16:02:04 2016, max compression<br \/>\n# gzip -dc initramfs-3.10.0-229.el7.x86_64.img | cpio -id      &#8212; will not extract all files or will give some error<br \/>\nTo extract it on RHEL7, use skipcpio:<br \/>\n1. copy the initramfs image file to some directory.<\/p>\n<p># mkdir \/tmp\/initramfs<br \/>\n# cp \/boot\/initramfs-3.10.0-229.el7.x86_64.img<br \/>\n2. extract the contents using the \/usr\/lib\/dracut\/skipcpio command :<\/p>\n<p># cd \/tmp\/initramfs<br \/>\n# \/usr\/lib\/dracut\/skipcpio initramfs-3.10.0-229.el7.x86_64.img | zcat | cpio -ivd<br \/>\n.<br \/>\nvar<br \/>\nvar\/lock<br \/>\nvar\/run<br \/>\nlib<br \/>\nwhere skipcpio is the built-in tool from dracut.<\/p>\n<p>Listing the content of initramfs image<\/p>\n<p>To only list the contents of an initramfs image file, you can run lsinitrd:<\/p>\n<p># lsinitrd \/boot\/initramfs-3.10.0-229.el7.x86_64.img  | more<br \/>\nImage: \/boot\/initramfs-3.10.0-229.el7.x86_64.img: 19M<br \/>\n========================================================================<br \/>\nVersion: dracut-033-359.el7<\/p>\n<p>Arguments: -f<\/p>\n<p>dracut modules:<br \/>\nbash<br \/>\nnss-softokn<br \/>\ni18n<br \/>\nnetwork<br \/>\nifcfg<br \/>\ndrm<br \/>\nplymouth<br \/>\ndm<br \/>\nkernel-modules<br \/>\nlvm<br \/>\nresume<br \/>\nrootfs-block<br \/>\nterminfo<br \/>\nudev-rules<br \/>\nbiosdevname<br \/>\nsystemd<br \/>\nusrmount<br \/>\nbase<br \/>\nfs-lib<br \/>\nshutdown<br \/>\n========================================================================<br \/>\ndrwxr-xr-x  12 root     root            0 May 23 10:27 .<br \/>\ncrw-r&#8211;r&#8211;   1 root     root       5,   1 May 23 10:27 dev\/console<br \/>\ncrw-r&#8211;r&#8211;   1 root     root       1,  11 May 23 10:27 dev\/kmsg<br \/>\ncrw-r&#8211;r&#8211;   1 root     root       1,   3 May 23 10:27 dev\/null<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In some cases you may want to extract the initramfs image file to check built-in contents. This post provides steps to extract initramfs image files for RHEL 7. Unlike previous version, on RHEL 7 using cpio command for the initramfs image file will not extract all files (or will give some error). For example:<\/p>\n<p># [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6718"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6718"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6718\/revisions"}],"predecessor-version":[{"id":6719,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6718\/revisions\/6719"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}