This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
initrd [2025/06/01 07:51] me |
initrd [2025/06/01 08:06] (current) me |
||
---|---|---|---|
Line 95: | Line 95: | ||
For next kernel with different options customize mkinitrd.conf again, create new initrd, make backup and so on. | For next kernel with different options customize mkinitrd.conf again, create new initrd, make backup and so on. | ||
That way you could have different initrds and saved all options to regenerate each of them. It’s safe attitude as playing with new kernel and initrd configuration you always have working old one. | That way you could have different initrds and saved all options to regenerate each of them. It’s safe attitude as playing with new kernel and initrd configuration you always have working old one. | ||
+ | |||
+ | all content below here from:- | ||
+ | |||
+ | https:// | ||
+ | |||
+ | |||
+ | How to View, Modify and Recreate initrd.img | ||
+ | by SASIKALA on JULY 10, 2009 | ||
+ | Question: How do I view, modify and recreate the new initrd.img on Ubuntu, Debian, CentOS, Fedora, Red-Hat, Arch Linux, or SUSE distributions? | ||
+ | |||
+ | |||
+ | 1. How To View Content Of initrd.img file? | ||
+ | initrd.img is in gzip format. | ||
+ | |||
+ | # cp / | ||
+ | |||
+ | # ls | ||
+ | cdrom | ||
+ | |||
+ | # 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 | ||
+ | 2. 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=' | ||
+ | 16524 blocks | ||
+ | |||
+ | # ls /tmp/ | ||
+ | cdrom initrd | ||
+ | |||
+ | # ls -l / | ||
+ | -rw-r--r-- 1 root root 8460288 Jul 2 14:50 / | ||
+ | Gzip the archive file. | ||
+ | |||
+ | # gzip newinitrd | ||
+ | |||
+ | # ls | ||
+ | cdrom initrd | ||
+ | |||
+ | # ls -l newinitrd.gz | ||
+ | -rw-r--r-- | ||
+ | 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 | ||
+ | |||
+ | all content below here from:- | ||
+ | |||
+ | https:// | ||
+ | |||
+ | How to unpack/ | ||
+ | | ||
+ | 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, | ||
+ | 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/ | ||
+ | |||
+ | Raw | ||
+ | mkdir /tmp/initrd | ||
+ | cd /tmp/initrd | ||
+ | Identify compression format of the image | ||
+ | Use the file command on the initramfs/ | ||
+ | |||
+ | Raw | ||
+ | file / | ||
+ | The $(uname -r) will use the file for the current kernel version. You may also specify a specific file, such as: | ||
+ | |||
+ | Raw | ||
+ | file / | ||
+ | The most common is a gzip-format image which displays as: | ||
+ | |||
+ | Raw | ||
+ | # file / | ||
+ | / | ||
+ | However, there may also be an XZ/ | ||
+ | |||
+ | Raw | ||
+ | # file / | ||
+ | / | ||
+ | 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 / | ||
+ | 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 > / | ||
+ | xz/LZMA format - Extract / Uncompress | ||
+ | Uncompress and extract the contents of the image in the /boot/ directory: | ||
+ | |||
+ | Raw | ||
+ | xz -dc < / | ||
+ | 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>/ | ||
+ | |||
+ | |||