Ubuntu kernel /initramfs install

本文介绍如何通过make命令编译内核及模块,并详细解释了使用mkinitramfs和update-initramfs创建与更新initramfs的过程。

编译内核

make -j4
make -j4 modules

安装模块内核和initramfs

sudo su
make modules_install
make install

如果已经安装了内核,只是想重新做initramfs, 可以参考下面的步骤.

下面是一些使用initramfs的简单帮助

查看initramfs的内容


# mkdir temp ; cd temp
# cp /boot/initrd.img-2.6.24-16 initrd.img-2.6.24-16.gz
# gunzip initrd.img-2.6.24-16.gz
# cpio -i --make-directories < initrd.img-2.6.24-16
#

创建initramfs

两种选项: 
 
 命令:mkinitramfs, update-initramfs

1) mkinitramfs


# mkinitramfs -o /boot/initrd.img 2.6.24-16

Note: 2.6.24-16是需要创建initramfs的kernel版本号,如果是给当前kernel制作initramfs,可以用uname -r查看当前的版本号。提供kernel版本号的主要目的是为了在initramfs中添加指定kernel的驱动模块。mkinitramfs会把/lib/modules/${kernel_version}/ 目录下的一些启动会用到的模块添加到initramfs中。

2)update-initramfs

更新当前正在运行kernel所使用的initramfs

update-initramfs -u

在添加模块时,initramfs tools只会添加一些必要模块,用户可以通过在/etc/initramfs-tools/modules文件中加入模块名称来指定必须添加的模块。

amd64-microcode ethtool intel-microcode iucode-tool linux-headers-5.15.0-139-generic linux-headers-generic-hwe-20.04 linux-hwe-5.15-headers-5.15.0-139 oem-fix-misc-cnl-tlp-estar-conf oem-somerville-meta thermald tlp tlp-rdw ubuntu-oem-keyring Use 'apt autoremove' to remove them. The following packages will be REMOVED: linux-image-5.15.24+* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 313 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 280133 files and directories currently installed.) Removing linux-image-5.15.24+ (5.15.24+-10.00.Custom) ... Examining /etc/kernel/prerm.d. Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 5.15.24+ /boot/vmlinuz-5.15.24+ update-initramfs: Deleting /boot/initrd.img-5.15.24+ run-parts: executing /etc/kernel/postrm.d/zz-update-grub 5.15.24+ /boot/vmlinuz-5.15.24+ Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-6.17.0-rc7 Found initrd image: /boot/initrd.img-6.17.0-rc7 Found linux image: /boot/vmlinuz-5.10.0-051000-generic Found initrd image: /boot/initrd.img-5.10.0-051000-generic Found linux image: /boot/vmlinuz-5.4.0+ Found initrd image: /boot/initrd.img-5.4.0+ done (Reading database ... 274877 files and directories currently installed.) Purging configuration files for linux-image-5.15.24+ (5.15.24+-10.00.Custom) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 5.15.24+ /boot/vmlinuz-5.15.24+ run-parts: executing /etc/kernel/postrm.d/zz-update-grub 5.15.24+ /boot/vmlinuz-5.15.24+ rmdir: failed to remove '/lib/modules/5.15.24+': Directory not empty dpkg: warning: while removing linux-image-5.15.24+, directory '/lib/modules/5.15.24+' not empty so not removed
最新发布
10-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值