一般情况redhat系的initrd.img文件就是一个cpio然后gz的文件,可以手工解压然后解CPIO,但是这玩意儿到了debian系不灵了,initrd.img-4.19.0-amd64-desktop这种文件用file去看就是个cpio 档,但要真cpio -idm <initrd.img-4.19.0-amd64-desktop 解压又只能得到几个文件。
只能用lsinitramfs查看或者unmkinitramfs得到解包的目录。 这应该是debian系和红帽系的差异。
这些命令所在的包信息:
- xxx@xxx-PC:~/deb-test/initrd$ dpkg -l | grep initramfs
- ii cryptsetup 2:2.1.0-5+deb10u2 all transitional dummy package for cryptsetup-{run,initramfs}
- ii cryptsetup-initramfs 2:2.1.0-5+deb10u2 all disk encryption support - initramfs integration
- ii initramfs-tools 0.137.28-1+dde all generic modular initramfs generator (automation)
- ii initramfs-tools-core 0.137.28-1+dde all generic modular initramfs generator (core tools)
- ii libklibc:amd64 2.0.6-1 amd64 minimal libc subset for use with initramfs
- ii live-boot-initramfs-tools 1:20210623 all Live System Boot Components (initramfs-tools backend)
- xxx@xxx-PC:~/deb-test/initrd$ apt-cache show initramfs-tools-core
- Package: initramfs-tools-core
- Priority: optional
- Section: utils
- Installed-Size: 221
- Maintainer: Debian kernel team <debian-kernel@lists.debian.org>
- Architecture: all
- Source: initramfs-tools
- Version: 0.137.28-1+dde
- Replaces: initramfs-tools (<< 0.121~)
- Depends: klibc-utils (>= 2.0.4-8~), cpio (>= 2.12), kmod, udev, coreutils (>= 8.24), logsave | e2fsprogs
- Recommends: busybox (>= 1:1.22.0-17~) | busybox-static (>= 1:1.22.0-17~), pigz
- Suggests: bash-completion
- Breaks: busybox (<< 1:1.22.0-17~), busybox-static (<< 1:1.22.0-17~), initramfs-tools (<< 0.121~)
- Filename: pool/main/i/initramfs-tools/initramfs-tools-core_0.137.28-1+dde_all.deb
- Size: 103116
- SHA256: 6c994ae0b027e79f19300e2e3d77688071986ea4e11f5e685e4b98c7afc3bc1a
- SHA1: 5888362358063fb13b350bfd9250702da3461da9
- MD5sum: 92546132dccf439988b6b06e2c8fb1a8
- Description: generic modular initramfs generator (core tools)
- This package contains the mkinitramfs program that can be used to
- create a bootable initramfs for a Linux kernel. The initramfs should
- be loaded along with the kernel and is then responsible for mounting
- the root filesystem and starting the main init system.
- Description-md5: 8d2ce4976ab4fb33b898ed3006a086fa
- Multi-Arch: foreign
-
本来红帽系的系统还可以手工解压进去手工操作一番,虽然更新或者重新生成更好。
但debian系无法解压及还原这个initramfs的镜像就完全没这个可能,只能重新生成了。
具体的配置文件在/etc/initramfs-tools目录下,但这里面一般就定义要包含特定的ko模块,但不能定义不包含特定的ko模块。好在update-initramfs命令会去扫描/etc/modprobe.d/,可以手工写blacklist,生成新initramfs的时候会包含进去,而且这些要放到initramfs里面的ko驱动都从系统里面拷贝,不放心的可以直接先在系统里删除或者移动走,再生成initramfs 。这样就万无一失了。
具体 可以用命令 :update-initramfs -c -k `uname -r` -v >initrd.log 2>&1
把生成initramfs文件的具体过程日志输出到日志里面去,这样就可以很明显的看到他中间到底做了些什么了。