求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
-
- 帖子: 17
- 注册时间: 2019-07-28 14:27
- 系统: ubuntu16
求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
系统版本ubuntu16.04.本人使用mkinitramfs脚本生成的initrd.img格式为cpio,现在怎么生成zip格式的initrd.img?
发现ubuntu14.04使用mkinitramfs脚本生成的initrd.img格式为zip格式。求助,谢谢!
发现ubuntu14.04使用mkinitramfs脚本生成的initrd.img格式为zip格式。求助,谢谢!
- astolia
- 论坛版主
- 帖子: 6570
- 注册时间: 2008-09-18 13:11
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
从来就不支持zip格式。gzip/bzip2不是zip
修改 /etc/initramfs-tools/initramfs.conf 中的COMPRESS选项,或者给mkinitramfs加上-c参数来指定
修改 /etc/initramfs-tools/initramfs.conf 中的COMPRESS选项,或者给mkinitramfs加上-c参数来指定
-
- 帖子: 17
- 注册时间: 2019-07-28 14:27
- 系统: ubuntu16
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
您好:
1、/etc/initramfs-tools/initramfs.conf中的COMPRESS选项已经是gzip。
#
# initramfs.conf
# Configuration file for mkinitramfs(8). See initramfs.conf(5).
#
# Note that configuration options from this file can be overridden
# by config files in the /etc/initramfs-tools/conf.d directory.
#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add most filesystem and all harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#
MODULES=most
#
# BUSYBOX: [ y | n | auto ]
#
# Use busybox shell and utilities. If set to n, klibc utilities will be used.
# If set to auto (or unset), busybox will be used if installed and klibc will
# be used otherwise.
#
BUSYBOX=auto
#
# COMPCACHE_SIZE: [ "x K" | "x M" | "x G" | "x %" ]
#
# Amount of RAM to use for RAM-based compressed swap space.
#
# An empty value - compcache isn't used, or added to the initramfs at all.
# An integer and K (e.g. 65536 K) - use a number of kilobytes.
# An integer and M (e.g. 256 M) - use a number of megabytes.
# An integer and G (e.g. 1 G) - use a number of gigabytes.
# An integer and % (e.g. 50 %) - use a percentage of the amount of RAM.
#
# You can optionally install the compcache package to configure this setting
# via debconf and have userspace scripts to load and unload compcache.
#
COMPCACHE_SIZE=""
#
# COMPRESS: [ gzip | bzip2 | lzma | lzop | xz ]
#
COMPRESS=gzip
#
# NFS Section of the config.
#
#
# DEVICE: ...
#
# Specify a specific network interface, like eth0
# Overridden by optional ip= bootarg
#
DEVICE=
#
# NFSROOT: [ auto | HOST:MOUNT ]
#
NFSROOT=auto
-
- 帖子: 17
- 注册时间: 2019-07-28 14:27
- 系统: ubuntu16
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
root@dh:/# cd /boot/
root@dh:/boot# ls
abi-4.15.0-29-generic config-4.15.18.old initrd.img-4.15.0-29-generic memtest86+.elf System.map-4.15.0-29-generic vmlinuz-4.15.0-29-generic
config-4.15.0-29-generic efi initrd.img-4.15.18 memtest86+_multiboot.bin System.map-4.15.18 vmlinuz-4.15.18
config-4.15.18 grub memtest86+.bin retpoline-4.15.0-29-generic System.map-4.15.18.old vmlinuz-4.15.18.old
root@dh:/boot# file initrd.img-4.15.18
initrd.img-4.15.18: ASCII cpio archive (SVR4 with no CRC)
root@dh:/boot#
- astolia
- 论坛版主
- 帖子: 6570
- 注册时间: 2008-09-18 13:11
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
出现这个现象的原因是,你系统上生成的initrd.img不是一个单一格式的文件,而是在压缩包之前附加了多个cpio包
你可以用cpio -t < /boot/initrd.img-4.15.18或cpio -i < /boot/initrd.img-4.15.18,来查看/解压出第一个cpio包的内容,应该是cpu的微码
如果你非要生成纯gzip的包,删除/usr/share/initramfs-tools/hooks/下面intel-microcode和amd64-microcode两个文件,不让它们往initrd.img前添加微码和更新微码的代码应该就可以了
你可以用cpio -t < /boot/initrd.img-4.15.18或cpio -i < /boot/initrd.img-4.15.18,来查看/解压出第一个cpio包的内容,应该是cpu的微码
如果你非要生成纯gzip的包,删除/usr/share/initramfs-tools/hooks/下面intel-microcode和amd64-microcode两个文件,不让它们往initrd.img前添加微码和更新微码的代码应该就可以了
-
- 帖子: 17
- 注册时间: 2019-07-28 14:27
- 系统: ubuntu16
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
astolia 写了: ↑2019-08-15 18:05 出现这个现象的原因是,你系统上生成的initrd.img不是一个单一格式的文件,而是在压缩包之前附加了多个cpio包
你可以用cpio -t < /boot/initrd.img-4.15.18或cpio -i < /boot/initrd.img-4.15.18,来查看/解压出第一个cpio包的内容,应该是cpu的微码
如果你非要生成纯gzip的包,删除/usr/share/initramfs-tools/hooks/下面intel-microcode和amd64-microcode两个文件,不让它们往initrd.img前添加微码和更新微码的代码应该就可以了
root@dh:~/cxx#
root@dh:~/cxx# cpio -ivmd < /boot/initrd.img-4.15.18
.
kernel
kernel/x86
kernel/x86/microcode
kernel/x86/microcode/AuthenticAMD.bin
56 blocks
root@dh:~/cxx# du -sh ./*
40K ./kernel
root@dh:~/cxx# ls /boot/initrd.img-4.15.18 -l
-rw-r--r-- 1 root root 454219559 8月 21 17:28 /boot/initrd.img-4.15.18
root@dh:~/cxx# file /boot/initrd.img-4.15.18
/boot/initrd.img-4.15.18: ASCII cpio archive (SVR4 with no CRC)
root@dh:~/cxx#
root@dh:~/cxx#
删掉intel-microcode和amd64-microcode两个文件以后,还是老样子,解压不全
- astolia
- 论坛版主
- 帖子: 6570
- 注册时间: 2008-09-18 13:11
-
- 帖子: 17
- 注册时间: 2019-07-28 14:27
- 系统: ubuntu16
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
我是将文件删除以后,编译内核make modules_install && make install自动重新生成initrd。请问这这样生成的initrd有什么区别吗,正确的做法应该怎么做?
-
- 帖子: 17
- 注册时间: 2019-07-28 14:27
- 系统: ubuntu16
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
按照你的方法问题解决了,现在已经变成gzip格式
root@dh:/boot# file initrd.img-4.15.18
initrd.img-4.15.18: gzip compressed data, last modified: Sat Aug 24 06:26:25 2019, from Unix
root@dh:/boot#
非常感谢
顺便再问一句:
编译内核自动生成的initrd.img-4.15.18非常大,将近几百兆,导致开机时加载非常慢,影响了开机速度。
这个initrd.img大小可以用什么办法控制吗?
- astolia
- 论坛版主
- 帖子: 6570
- 注册时间: 2008-09-18 13:11
Re: 求助:ubuntu16.04如何使用mkinitramfs生成zip格式的initrd.img
gzip本来压缩率就不怎么样,换xz会好很多。另外你不修改内核配置的话,默认是照抄当前运行内核的配置,一般发行版为了兼容尽可能多的硬件,各种杂七杂八的驱动模块包含了一堆进去。你针对特定机器编译的话,不需要的驱动完全可以去掉。