User Tools

Site Tools


initrd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
initrd [2025/06/01 08:03]
me
initrd [2025/06/01 08:06] (current)
me
Line 160: Line 160:
 # ls -l newinitrd.img # ls -l newinitrd.img
 -rw-r--r-- 1 root root 6649867 Jul  2 14:50 newinitrd.img -rw-r--r-- 1 root root 6649867 Jul  2 14:50 newinitrd.img
 +
 +all content below here from:-
 +
 +https://access.redhat.com/solutions/24029
 +
 +How to unpack/uncompress and repack/re-compress an initial ramdisk (initrd/initramfs) boot image file on RHEL 5,6 ?
 + SOLUTION VERIFIED - Updated August 7 2024 at 7:03 AM - English 
 +Environment
 +Red Hat Enterprise Linux 6
 +Red Hat Enterprise Linux 5
 +Note: For RHEL7 and RHEL8, refer to How to extract the contents of initramfs image on RHEL7?
 +
 +Issue
 +How do I unpack or uncompress, and then repack or re-compress, an initrd or initramfs boot image file?
 +How do I modify the contents of an initrd or initramfs?
 +How do I view an initrd or initramfs?
 +Resolution
 +First, create a temporary work directory and switch into it. This will be the location where the initramfs/initrd contents will be viewed, edited, and re-compressed if required:
 +
 +Raw
 +mkdir /tmp/initrd
 +cd /tmp/initrd
 +Identify compression format of the image
 +Use the file command on the initramfs/initrd to identify the compression format:
 +
 +Raw
 +file /boot/initramfs-$(uname -r).img
 +The $(uname -r) will use the file for the current kernel version. You may also specify a specific file, such as:
 +
 +Raw
 +file /boot/initramfs-2.6.32-754.el6.x86_64.img
 +The most common is a gzip-format image which displays as:
 +
 +Raw
 +# file /boot/initramfs-$(uname -r).img
 +/boot/initramfs-2.6.32-754.el6.x86_64.img: gzip compressed data
 +However, there may also be an XZ/LZMA-format image which displays as:
 +
 +Raw
 +# file /boot/initramfs-$(uname -r).img
 +/boot/initramfs-2.6.32-754.el6.x86_64.img: LZMA compressed data
 +Select the appropriate instructions below to extract or repack the correct image type for your system.
 +
 +gzip format - Extract / Uncompress
 +Uncompress and extract the contents of the image in the /boot/ directory:
 +
 +Raw
 +zcat /boot/initrd-$(uname -r).img | cpio -idmv
 +gzip format - Repack / Recompress
 +Still in the working directory, find all files and add them to a new boot image file:
 +
 +Raw
 +find . | cpio -o -c -R root:root | gzip -9 > /boot/new.img
 +xz/LZMA format - Extract / Uncompress
 +Uncompress and extract the contents of the image in the /boot/ directory:
 +
 +Raw
 +xz -dc < /boot/initrd-$(uname -r).img | cpio -idmv
 +xz/LZMA format - Repack / Recompress
 +Still in the working directory, find all files and add them to a new boot image file:
 +
 +Raw
 +find . 2>/dev/null | cpio -o -c -R root:root | xz -9 --format=lzma > /boot/new.img
 +
  
  
  
initrd.1748764989.txt.gz ยท Last modified: 2025/06/01 08:03 by me