简体   繁体   English

如何在 RHEL7 上重新打包 initramfs 映像?

[英]How can I repack initramfs image on RHEL7?

On RHEL 7 the initramfs image file format changed.在 RHEL 7 上,initramfs 图像文件格式发生了变化。 To unpack the image the skipcpio is needed.要解压缩图像,需要使用 skipcpio。 for example例如

/usr/lib/dracut/skipcpio /boot/initramfs-3.10.0-957.el7.x86_64.img | gunzip -c | cpio -idmv

I succeeded to unpack the image with the command above but I cannot pack it back.我成功地使用上面的命令解压了图像,但我无法将它打包回来。 The old way (like it was on RHEL 6) is not working (旧方法(就像在 RHEL 6 上一样)不起作用(

find . | cpio -o -c | gzip -9 > /boot/new.img

Is it possible to pack the image back on RHEL7?是否可以将图像打包回 RHEL7 上?

Thanks谢谢

I got a solution when RHEL7 has the.img file packed in more complex way.当 RHEL7 以更复杂的方式打包 .img 文件时,我得到了解决方案。 Hints to its structure were described in https://ahelpme.com/linux/tips/unpack-centos-7-initramfs-file-with-and-without-dracut-skipcpio/ , however there were no instructions for repacking after modification. https://ahelpme.com/linux/tips/unpack-centos-7-initramfs-file-with-and-without-dracut-skipcpio/中描述了其结构的提示,但是没有修改后重新打包的说明。 Here I show the whole process:这里我展示了整个过程:

cd /tmp
rm -f tryMe.img
rm -f initramfs-tmp.img
rm -rf cc
rm -f modified.gz
mkdir cc
cd cc
cat /boot/initramfs-3.10.0-1062.4.1.el7.x86_64.img | cpio -idmv # note number of blocks in 
                                                                # output; I assume 4976
find . | cpio -o -H newc > /tmp/tryMe.img
rm -rf *
dd if=/boot/initramfs-3.10.0-1062.4.1.el7.x86_64.img of=../initramfs-tmp.img bs=512 skip=4976
zcat ../initramfs-tmp.img | cpio -idm
find . | cpio --create --format='newc' > /tmp/modified
gzip -9 /tmp/modified
cat /tmp/modified.gz >> /tmp/tryMe.img
#backup your original somehow and then
mv /tmp/tryMe.img /boot/initramfs-3.10.0-1062.4.1.el7.x86_64.img

The packing is the same as old Red Hat Enterprise Linux (RHEL) versions:包装与旧 Red Hat Enterprise Linux (RHEL) 版本相同:

find. | cpio -o -H newc >../initramfsFile

gzip -c../initramfsFile > initramfsFils.img

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM