How to View, Modify and Recreate initrd.img

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.imgis in gzip format.  So move initrd.img to initrd.gz as shown below.

# cp /tftpboot/el5/initrd.img  .

# ls
cdrom   initrd.img

# 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 usingcpio ‘newc’ formatas shown below.
Note:info cpiowill 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

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=‘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

How to View, Modify and Recreate initrd.img,布布扣,bubuko.com

时间: 2024-10-12 20:13:46

How to View, Modify and Recreate initrd.img的相关文章

笔记:View Programming Guide for iOS -1

原文:View Programming Guide for iOS View and Window Architecture Views and windows present your application’s user interface and handle the interactions with that interface. UIKit and other system frameworks provide a number of views that you can use a

[Android随笔]BroadcastReceiver广播机制

一,介绍 android四大组件之一:BroadcastReceiver 翻译成中文:广播接收者.在Android中,Broadcast是一种广泛运用在应用程序之间传输信息的机制.而BroadcastReceiver是对发送出来的Broadcast(广播)进行过滤.接收.响应的一类组件. 呵呵,作为一个android研发学习者,我们想要学习使用BroadcastReceiver这个组件,当然实践是最好的方式.下面介绍BroadcastReceiver的几种使用方式. 二,使用方式 2.1 静态注

Wix 安装部署教程(十三) -- 多语言安装包

这几天摸索WIX的多语言安装包(这里是Wix的setup 工程,不是Bundle),终于走通了,感谢网友uni的指点.WIX的多语言安装包能够根据系统环境自动切换界面语言,你也可以通过命令指定语言.下面我说一说步骤.共4步. 1.设置WixLocalization文件. Wxl文件就相当于应用程序的资源文件.让我们根据不同的语言来编写不同的文本内容. 例如我们新建一个WixUI_zh-cn.wxl ,来处理简体中文. <WixLocalization Culture="zh-cn"

排序、筛选、分页以及分组

Sorting, filtering, paging, and grouping¶ 7 of 8 people found this helpful By Tom Dykstra The Contoso University sample web application demonstrates how to create ASP.NET Core 1.0 MVC web applications using Entity Framework Core 1.0 and Visual Studio

WIX Custom Action (immediate, deffered, rollback)

Following content is directly reprinted from From MSI to WiX, Part 19 - The Art of Custom Action, Part 1 Author:Alex Shevchuk Introduction Today we will start exploring custom actions, how to write them, what makes custom action good custom action an

[转]Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application (3 of 10)

本文转自:http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application Download Completed Project The Contoso University sample web application de

Read the Humanities

Read the Humanities Keith Braithwaite iN ALL BUT THE SMALLEST DEVELOPMENT PROjECT, people work with people. In all but the most abstracted field of research, people write software for people to support them in some goal of theirs. People write softwa

Cryptographic method and system

The present invention relates to the field of security of electronic data and/or communications. In one form, the invention relates to data security and/or privacy in a distributed and/or decentralised network environment. In another form, the invent

Java Developer&#39;s Guide to SSL Certificates

https://www.codebyamir.com/blog/java-developers-guide-to-ssl-certificates Overview When developing web applications, we often need to integrate with other applications using SSL.   This could be over different protocols such as HTTPS, IMAPS, or LDAPS