查看更改linux内核initrd.img

2.6以前的版本采用的是ext2格式的initrd,2.6及以后是cpio包形式,具体来看下吧

2.6及以后版本内核

解包

查看ubuntu的grub.cfg文件

红框是root文件系统,挂载在根目录。

解包initrd.img-4.4.0-62-generic

file initrd.img-4.4.0-62-generic
# initrd.img-4.4.0-62-generic: gzip compressed data, last modified: Fri May  4 13:36:01 2018, from Unix
mv initrd.img-4.4.0-62-generic initrd.img.gz
gunzip -d initrd.img.gz
# gunzip to initrd.img
file initrd.img
# initrd.img: ASCII cpio archive (SVR4 with no CRC)
mkdir initrd
cd initrd
cpio -idmv < ../initrd.img
# 解包成功,查看
ls
# bin  conf  etc  init  lib  lib64  run  sbin  scripts  usr  var

重新打包生成initrd.img

find .| cpio -H newc -o | gzip -9 -n > ../initrd.new.img

注:

-H newc 是必须的。-H Use given archive FORMAT,newc The new (SVR4) portable format, which supports file systems having more than 65536 i-nodes。现在的Linux内核的initramfs/initrd默认都是使用SVR4格式

2.6之前版本

mv initrd-2.4.21.img  initrd-2.4.21.img.gz
gunzip initrd-2.4.21.img
file initrd-2.4.21.img
# initrd-2.4.21.img: Linux rev 1.0 ext2 filesystem data
mount -o loop initrd-2.4.21.img /mnt/
cd /mnt
ls
#  bin  conf  etc  init  lib  lib64  run  sbin  scripts  usr  var

压缩到initrd.gz

 

umount initrd-2.4.21.img
gzip -9 -n initrd-2.4.21.img
ls
#  initrd-2.4.21.img.gz

至此又生成了initrd.gz

 

 

 

 

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值