• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 7 : How to extract initramfs image and edit/view it

by admin

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:

# ls -la /boot/initramfs-$(uname -r).img
-rw------- 1 root root 19602671 Feb  4  2016 /boot/initramfs-3.10.0-229.el7.x86_64.img
# file initramfs-3.10.0-229.el7.x86_64.img
initramfs-3.10.0-229.el7.x86_64.img: gzip compressed data, from Unix, last modified: Thu Feb  4 16:02:04 2016, max compression
# gzip -dc initramfs-3.10.0-229.el7.x86_64.img | cpio -id      --- will not extract all files or will give some error

To extract it on RHEL7, use skipcpio:
1. copy the initramfs image file to some directory.

# mkdir /tmp/initramfs
# cp /boot/initramfs-3.10.0-229.el7.x86_64.img

2. extract the contents using the /usr/lib/dracut/skipcpio command :

# cd /tmp/initramfs
# /usr/lib/dracut/skipcpio initramfs-3.10.0-229.el7.x86_64.img | zcat | cpio -ivd
.
var
var/lock
var/run
lib

where skipcpio is the built-in tool from dracut.

Listing the content of initramfs image

To only list the contents of an initramfs image file, you can run lsinitrd:

# lsinitrd /boot/initramfs-3.10.0-229.el7.x86_64.img  | more
Image: /boot/initramfs-3.10.0-229.el7.x86_64.img: 19M
========================================================================
Version: dracut-033-359.el7

Arguments: -f

dracut modules:
bash
nss-softokn
i18n
network
ifcfg
drm
plymouth
dm
kernel-modules
lvm
resume
rootfs-block
terminfo
udev-rules
biosdevname
systemd
usrmount
base
fs-lib
shutdown
========================================================================
drwxr-xr-x  12 root     root            0 May 23 10:27 .
crw-r--r--   1 root     root       5,   1 May 23 10:27 dev/console
crw-r--r--   1 root     root       1,  11 May 23 10:27 dev/kmsg
crw-r--r--   1 root     root       1,   3 May 23 10:27 dev/null
CentOS / RHEL 6 : How to extract initramfs image and edit/view it

Filed Under: CentOS/RHEL 7

Some more articles you might also be interested in …

  1. How to Migrate CentOS/RHEL 6 iptables Rules to CentOS/RHEL 7 firewalld
  2. How to enable additional scsi logging in CentOS/RHEL
  3. The /var/log/messages is empty, and so are the rotated log files such as messages.0, messages.1
  4. How to disable ICMP redirects on CentOS/RHEL
  5. How To Retain Current And Older Linux Packages While Doing Update With ‘yum’ Command
  6. Apache HTTP server – most commonly used configuration directives
  7. How to Rebuild the “initramfs” with Multipath in CentOS/RHEL 6 and 7
  8. How to Check if a Service Restart or Server Reboot is required After RPM Package Update (CentOS/RHEL/Fedora)
  9. How to blacklist a local disk using the “find_multipaths” directive in CentOS/RHEL 6
  10. How to Remove a Dead Mulitpath Device without Reboot in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright